What changed, and why it matters
This commit only changes test code inside the rust-bitcoin library. It swaps internal struct-literal construction of script hash types for public constructor methods. There is no change to production code, no security fix, and no behavior change.
No action required. This is a non-security refactoring of unit tests.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies primitives/src/script/mod.rs test functions script_hash_from_script_unchecked and wscript_hash_from_script_unchecked. Previously the tests constructed ScriptHash/WScriptHash by directly wrapping a hash value (ScriptHash(…)). The patch uses the public from_byte_array constructor and renames variables for clarity. The commit message explicitly states ‘Test code only. No logic change or test coverage change.’
Changed components
primitives/src/script/mod.rs (tests only)Inspect captured patch +12 / −4
diff --git a/primitives/src/script/mod.rs b/primitives/src/script/mod.rs
index ba6dbc73..1888f606 100644
--- a/primitives/src/script/mod.rs
+++ b/primitives/src/script/mod.rs
@@ -774,8 +774,12 @@ mod tests {
#[test]
fn script_hash_from_script_unchecked() {
let script = WitnessScript::from_bytes(&[0x51; 521]);
- let hash = ScriptHash::from_script_unchecked(script);
- assert_eq!(hash, ScriptHash(hash160::Hash::hash(script.as_bytes())));
+
+ let got = ScriptHash::from_script_unchecked(script);
+ let want =
+ ScriptHash::from_byte_array(hash160::Hash::hash(script.as_bytes()).to_byte_array());
+
+ assert_eq!(got, want);
}
#[test]
@@ -790,8 +794,12 @@ mod tests {
#[test]
fn wscript_hash_from_script_unchecked() {
let script = WitnessScript::from_bytes(&[0x51; 10_001]);
- let hash = WScriptHash::from_script_unchecked(script);
- assert_eq!(hash, WScriptHash(sha256::Hash::hash(script.as_bytes())));
+
+ let got = WScriptHash::from_script_unchecked(script);
+ let want =
+ WScriptHash::from_byte_array(sha256::Hash::hash(script.as_bytes()).to_byte_array());
+
+ assert_eq!(got, want);
}
#[test]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.