What changed, and why it matters
This commit simply moves a test from one file to another. It fixes a packaging problem where published source code would contain a broken unit test because a required data file was not included in the published package. There is no security issue in the code itself.
No security action needed. This is a routine test maintenance and packaging fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change relocates the static_vector block deserialization test from primitives/src/block.rs (an inline unit test) to a new integration-style test file primitives/tests/block.rs. The test uses include_bytes! to reference a raw block file under tests/data/, which is excluded from crates.io publication. The move ensures the test is only run from the repository source and not from published crates, preventing broken unit tests in published packages. No runtime code, cryptographic logic, or parsing behavior is modified.
Changed components
primitives/src/block.rsprimitives/tests/block.rsInspect captured patch +22 / −18
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 50573495..50d2891f 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -2066,22 +2066,4 @@ mod tests {
let real_decode2 = decode2.unwrap().assume_checked(None);
assert_eq!(real_decode2.header().version, Version::from_consensus(-2_147_483_648));
}
-
- #[test]
- #[cfg(feature = "alloc")]
- fn static_vector() {
- // testnet block 000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b
- let segwit_block = include_bytes!("../tests/data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw");
- let block: Block<Unchecked> =
- encoding::decode_from_slice(&segwit_block[..]).expect("failed to deserialize block");
- assert!(block.check_merkle_root());
-
- let (header, transactions) = block.into_parts();
- let block = Block::new_unchecked(header, transactions).assume_checked(None);
-
- // Same as `block.check_merkle_root` but do it explicitly.
- let hashes_iter = block.transactions().iter().map(Transaction::compute_txid);
- let from_iter = TxMerkleNode::calculate_root(hashes_iter.clone());
- assert_eq!(from_iter, Some(block.header().merkle_root));
- }
}
diff --git a/primitives/tests/block.rs b/primitives/tests/block.rs
new file mode 100644
index 00000000..22911a94
--- /dev/null
+++ b/primitives/tests/block.rs
@@ -0,0 +1,22 @@
+#![cfg(feature = "alloc")]
+
+use bitcoin_primitives::block::{Block, Unchecked};
+use bitcoin_primitives::merkle_tree::TxMerkleNode;
+use bitcoin_primitives::Transaction;
+
+#[test]
+fn static_vector() {
+ // testnet block 000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b
+ let segwit_block = include_bytes!("../tests/data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw");
+ let block: Block<Unchecked> =
+ encoding::decode_from_slice(&segwit_block[..]).expect("failed to deserialize block");
+ assert!(block.check_merkle_root());
+
+ let (header, transactions) = block.into_parts();
+ let block = Block::new_unchecked(header, transactions).assume_checked(None);
+
+ // Same as `block.check_merkle_root` but do it explicitly.
+ let hashes_iter = block.transactions().iter().map(Transaction::compute_txid);
+ let from_iter = TxMerkleNode::calculate_root(hashes_iter.clone());
+ assert_eq!(from_iter, Some(block.header().merkle_root));
+}
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.