diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 78edab6170..73abff7124 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -1124,16 +1124,13 @@ mod test { #[test] fn script_x_only_key() { - let mut comp = vec![]; - let mut script = Builder::new(); - assert_eq!(&script[..], &comp[..]); // Notice the "20" which prepends the keystr. That 20 is hexidecimal for "32". The Builder automatically adds the 32 opcode // to our script in order to give a heads up to the script compiler that it should add the next 32 bytes to the stack. - // To mimic the Builder's automatic insertion of the 32 opcode, we manually add it to the Vec and slice it out in the from_str. // From: https://github.com/bitcoin-core/btcdeb/blob/e8c2750c4a4702768c52d15640ed03bf744d2601/doc/tapscript-example.md?plain=1#L43 let keystr = "209997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be"; let x_only_key = XOnlyPublicKey::from_str(&keystr[2..]).unwrap(); - script = script.push_x_only_key(&x_only_key); comp.extend(Vec::from_hex(keystr).unwrap().iter().cloned()); assert_eq!(&script[..], &comp[..]); + let script = Builder::new().push_x_only_key(&x_only_key); + assert_eq!(&script[..], &Vec::from_hex(keystr).unwrap()); } #[test]