Use matches! instead of match for error assertion
What changed, and why it matters
This commit is a minor test-code cleanup. It replaces a verbose match statement with Rust's built-in matches! macro to check that an error is the expected type. There is no change to production code, no security fix, and no vulnerability.
No action needed. This is a non-security refactoring of test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies a single unit test in primitives/src/transaction.rs. It changes an error-variant assertion from an explicit match with a panic arm to assert!(matches!(…)). The behavior being tested is identical; only the assertion style is more concise. No runtime logic is altered.
Changed components
primitives/src/transaction.rs (test code only)Inspect captured patch +1 / −4
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 80ff35a3..5cfd7db4 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -2545,10 +2545,7 @@ mod tests {
decoder.push_bytes(&mut slice).unwrap();
let err = decoder.end().expect_err("sum of output values > MAX_MONEY should be rejected");
- match err.0 {
- TransactionDecoderErrorInner::OutputValueSumTooLarge(_) => (),
- e => panic!("unexpected error: {:?}", e),
- }
+ assert!(matches!(err.0, TransactionDecoderErrorInner::OutputValueSumTooLarge(_)));
}
#[test]
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.