Split out error test into its own test
What changed, and why it matters
This commit simply reorganizes existing test code. It takes a portion of one unit test and moves it into a separate, standalone test function. There are no changes to production code, no bug fixes, and no security-relevant behavior changes.
No action needed. This is a non-functional test refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff splits an existing test in primitives/src/witness.rs into two tests. The original test now ends after asserting a valid 4,000,000-byte witness element can be decoded. A new test, decode_length_prefix_error, contains the remaining code that checks decoding fails when a witness element exceeds the 4,000,000-byte limit. The logic and assertions are unchanged; only test structure is modified.
Changed components
primitives/src/witness.rs (test code only)Inspect captured patch +4 / −0
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index 21767b9a..82ed1f04 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -1419,7 +1419,11 @@ mod test {
decoder.push_bytes(&mut slice).unwrap();
let witness = decoder.end().unwrap();
assert_eq!(witness[0].len(), 4_000_000);
+ }
+ #[test]
+ #[cfg(feature = "alloc")]
+ fn decode_length_prefix_error() {
let mut encoded = Vec::new();
encoded.extend_from_slice(crate::compact_size_encode(1usize).as_slice());
encoded.extend_from_slice(crate::compact_size_encode(4_000_001usize).as_slice());
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.