primitives: Add test to kill mutants in Witness::size
What changed, and why it matters
This commit only adds a new unit test for an existing function (Witness::size). It does not change any production code, fix any bug, or alter behavior. There is no security relevance.
No security action needed. This is a routine test-coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single test, witness_size, in primitives/src/witness.rs. The test verifies that Witness::size correctly returns the serialized byte length of an empty witness, a single-element witness, and a two-element witness. No implementation code is modified.
Changed components
primitives/src/witness.rs (test module only)Inspect captured patch +15 / −0
diff --git a/primitives/src/witness.rs b/primitives/src/witness.rs
index 193bbdc2..ff0547f9 100644
--- a/primitives/src/witness.rs
+++ b/primitives/src/witness.rs
@@ -1032,6 +1032,21 @@ mod test {
assert_eq!(witness_from_nested_array, witness);
}
+ #[test]
+ fn witness_size() {
+ let mut witness = Witness::new();
+ let want = 1; // Number of elements compact size encoded.
+ assert_eq!(witness.size(), want);
+
+ witness.push([1, 2, 3]);
+ let want = 5; // 1 + 1 + 3
+ assert_eq!(witness.size(), want);
+
+ witness.push([4, 5]);
+ let want = 8; // 5 + 1 + 2
+ assert_eq!(witness.size(), want);
+ }
+
#[test]
fn partial_eq() {
const EMPTY_BYTES: &[u8] = &[];
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.