From 013dffa65d8f59b19e7e2da6faeab26aa9ff17ef Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 18 May 2023 12:44:32 +1000 Subject: [PATCH] tests: Use script hash methods We have methods to convert a script to a `WScritpHash` and `ScriptHash`, no need to do this manually, let alone use the `psbt::Serialize` trait to do so. --- bitcoin/src/blockdata/script/tests.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bitcoin/src/blockdata/script/tests.rs b/bitcoin/src/blockdata/script/tests.rs index 464c121f..7b4a68a3 100644 --- a/bitcoin/src/blockdata/script/tests.rs +++ b/bitcoin/src/blockdata/script/tests.rs @@ -9,8 +9,7 @@ use super::*; use crate::blockdata::opcodes; use crate::consensus::encode::{deserialize, serialize}; use crate::crypto::key::{PublicKey, XOnlyPublicKey}; -use crate::hash_types::{PubkeyHash, ScriptHash, WPubkeyHash, WScriptHash}; -use crate::psbt::serialize::Serialize; +use crate::hash_types::{PubkeyHash, WPubkeyHash}; #[test] #[rustfmt::skip] @@ -213,12 +212,12 @@ fn script_generators() { assert!(ScriptBuf::new_v0_p2wpkh(&wpubkey_hash).is_v0_p2wpkh()); let script = Builder::new().push_opcode(OP_NUMEQUAL).push_verify().into_script(); - let script_hash = ScriptHash::hash(&script.serialize()); + let script_hash = script.script_hash(); let p2sh = ScriptBuf::new_p2sh(&script_hash); assert!(p2sh.is_p2sh()); assert_eq!(script.to_p2sh(), p2sh); - let wscript_hash = WScriptHash::hash(&script.serialize()); + let wscript_hash = script.wscript_hash(); let p2wsh = ScriptBuf::new_v0_p2wsh(&wscript_hash); assert!(p2wsh.is_v0_p2wsh()); assert_eq!(script.to_v0_p2wsh(), p2wsh);