What changed, and why it matters
This commit only adds a new unit test to verify that different ways of reading a transaction hash (Txid) return the same underlying bytes. It does not change any production code, APIs, or behavior. There is no security relevance.
No action required. This is a routine test-coverage improvement with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single test, as_ref_and_borrow_match_as_byte_array, in primitives/src/hash_types/mod.rs. The test constructs a Txid from a fixed 32-byte array and checks that AsRef<[u8; 32]>, AsRef<[u8]>, and Borrow<[u8; 32]> all match as_byte_array(). No library code is modified.
Changed components
primitives/src/hash_types/mod.rs (tests only)Inspect captured patch +13 / −0
diff --git a/primitives/src/hash_types/mod.rs b/primitives/src/hash_types/mod.rs
index 6436207c..52401f8d 100644
--- a/primitives/src/hash_types/mod.rs
+++ b/primitives/src/hash_types/mod.rs
@@ -226,6 +226,19 @@ mod tests {
assert_eq!(got, want);
}
+ #[test]
+ fn as_ref_and_borrow_match_as_byte_array() {
+ let tc = Txid::from_byte_array([0x11; 32]);
+
+ let as_array: &[u8; 32] = tc.as_ref();
+ let as_slice: &[u8] = tc.as_ref();
+ let borrowed: &[u8; 32] = core::borrow::Borrow::<[u8; 32]>::borrow(&tc);
+
+ assert_eq!(as_array, tc.as_byte_array());
+ assert_eq!(borrowed, tc.as_byte_array());
+ assert_eq!(as_slice, tc.as_byte_array());
+ }
+
#[test]
// This is solely to test that we can debug print WITHOUT "hex" so its ok to require "alloc".
#[cfg(feature = "alloc")]
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.