What changed, and why it matters
This is a minor code cleanup inside a single test file. It removes unnecessary cloning of test data and renames a loop variable for clarity. There is no change to production code, no security fix, and no behavior change.
No security action needed. Treat as a normal refactoring/test-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies p2p/src/bip152.rs in a test module only. It destructures the test tuple in the loop pattern (for (encoded_offsets, indices) in testcases) so that the inner code can borrow slices (extend_from_slice) instead of cloning vectors. The deserialization and serialization assertions remain identical in meaning. No runtime logic, protocol handling, or cryptographic code is affected.
Changed components
p2p/src/bip152.rs test moduleInspect captured patch +6 / −7
diff --git a/p2p/src/bip152.rs b/p2p/src/bip152.rs
index 74c8ca81..b567800a 100644
--- a/p2p/src/bip152.rs
+++ b/p2p/src/bip152.rs
@@ -930,24 +930,23 @@ mod test {
vec![2, 255, 254, 255, 255, 255, 255, 255, 255, 255, 0], // .., 255, 254, .., 255] == CompactSize(u64::MAX-1)
vec![1, 255, 255, 255, 255, 255, 255, 255, 255, 255], // .., 255, 255, .., 255] == CompactSize(u64::MAX)
];
- for testcase in testcases {
+ for (encoded_offsets, indices) in testcases {
{
// test deserialization
let mut raw: Vec<u8> = vec![0u8; 32];
- raw.extend(testcase.0.clone());
- let btr: BlockTransactionsRequest =
- encoding::decode_from_slice(&raw.clone()).unwrap();
- assert_eq!(testcase.1, btr.indices().unwrap());
+ raw.extend_from_slice(&encoded_offsets);
+ let btr: BlockTransactionsRequest = encoding::decode_from_slice(&raw).unwrap();
+ assert_eq!(indices, btr.indices().unwrap());
}
{
// test serialization
let raw: Vec<u8> =
encoding::encode_to_vec(&BlockTransactionsRequest::from_indices_unchecked(
BlockHash::from_byte_array([0; 32]),
- testcase.1,
+ indices,
));
let mut expected_raw: Vec<u8> = [0u8; 32].to_vec();
- expected_raw.extend(testcase.0);
+ expected_raw.extend(encoded_offsets);
assert_eq!(expected_raw, raw);
}
}
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.