diff --git a/primitives/src/script/mod.rs b/primitives/src/script/mod.rs index a9c436e68..619a948ec 100644 --- a/primitives/src/script/mod.rs +++ b/primitives/src/script/mod.rs @@ -650,6 +650,15 @@ mod tests { assert_eq!(script_buf.as_bytes(), &[0x50, 0x51, 0x53]); } + #[test] + fn scriptbuf_borrow_mut() { + let mut script_buf = ScriptBuf::from(vec![0x51, 0x52, 0x53]); + let script_mut: &mut Script = script_buf.borrow_mut(); + script_mut.as_mut_bytes()[0] = 0x50; + + assert_eq!(script_buf.as_bytes(), &[0x50, 0x52, 0x53]); + } + #[test] #[allow(clippy::useless_asref)] fn script_as_ref() { @@ -831,6 +840,14 @@ mod tests { assert_eq!(script_buf2, script_buf); } + #[test] + fn cow_owned_to_scriptbuf() { + let script_buf = ScriptBuf::from(vec![0x51, 0x52, 0x53]); + let cow_owned: Cow