From 936ab1a66f8ca8d3e5c3e0ae660d91e3aa159c25 Mon Sep 17 00:00:00 2001 From: mplsgrant <58152638+mplsgrant@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:07:17 -0500 Subject: [PATCH] Improve script_x_only_key test. Co-authored-by: Dr. Maxim Orlovsky --- src/blockdata/script.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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]