Move serialization round trip check before object mutation
What changed, and why it matters
This commit fixes a fuzz test so that it checks serialization round-trip correctness before modifying the object, rather than after. The change is purely a test logic correction and does not affect production code or introduce any security issue.
No security action required. This is a test-only correction.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rs, the serialization/deserialization round-trip assertions were moved to occur before the transaction object is mutated (witness stripping on inputs). Previously, the round-trip check happened after mutation, causing the test to fail because the serialized bytes no longer matched the modified transaction. This is a test-only bug fix with no runtime security implications.
Changed components
fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rsInspect captured patch +4 / −4
diff --git a/fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rs b/fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rs
index ffb29d7b..b30cca45 100644
--- a/fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rs
+++ b/fuzz/fuzz_targets/bitcoin/arbitrary_transaction.rs
@@ -10,6 +10,10 @@ fn do_test(data: &[u8]) {
if let Ok(mut tx) = t {
let serialized = serialize(&tx);
+ let deserialized: Result<Transaction, _> = deserialize(serialized.as_slice());
+ assert!(deserialized.is_ok(), "Deserialization error: {:?}", deserialized.err().unwrap());
+ assert_eq!(deserialized.unwrap(), tx);
+
let len = serialized.len();
let calculated_weight = tx.weight().to_wu() as usize;
for input in &mut tx.inputs {
@@ -25,10 +29,6 @@ fn do_test(data: &[u8]) {
} else {
assert_eq!(no_witness_len * 3 + len, calculated_weight);
}
-
- let deserialized: Result<Transaction, _> = deserialize(serialized.as_slice());
- assert!(deserialized.is_ok(), "Deserialization error: {:?}", deserialized.err().unwrap());
- assert_eq!(deserialized.unwrap(), tx);
}
}
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.