Add test to kill mutant in current_chunk
What changed, and why it matters
This commit only adds new unit tests for an existing code path. It does not change any production code, fix a bug, or alter behavior. There is no security issue present in the diff.
No security action needed. Treat as routine test-coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds two test cases in consensus_encoding/tests/encode.rs covering Option
Changed components
consensus_encoding/tests/encode.rsInspect captured patch +20 / −0
diff --git a/consensus_encoding/tests/encode.rs b/consensus_encoding/tests/encode.rs
index 0b9846ba..ed887e33 100644
--- a/consensus_encoding/tests/encode.rs
+++ b/consensus_encoding/tests/encode.rs
@@ -198,3 +198,23 @@ fn encode_encoder_advance_multiple_times_when_exhausted() {
assert!(!encoder.advance());
assert!(encoder.current_chunk().is_empty());
}
+
+#[test]
+fn encode_option_encoder_some() {
+ use bitcoin_consensus_encoding::Encoder;
+
+ let mut encoder = Some(ArrayEncoder::<3>::without_length_prefix([1, 2, 3]));
+ assert_eq!(encoder.current_chunk(), &[1, 2, 3]);
+ assert!(!encoder.advance());
+ assert!(encoder.current_chunk().is_empty());
+}
+
+#[test]
+fn encode_option_encoder_none() {
+ use bitcoin_consensus_encoding::Encoder;
+
+ let mut encoder: Option<ArrayEncoder<3>> = None;
+ assert!(encoder.current_chunk().is_empty());
+ assert!(!encoder.advance());
+ assert!(encoder.current_chunk().is_empty());
+}
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.