What changed, and why it matters
This commit only rearranges existing test code and renames one test. No production code was changed, and no security issue is present.
No action required; this is a non-security test reorganization.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff in units/src/amount/result.rs swaps the order of two existing unit tests and renames test_sum_signed_amount_results to test_sum_amount_with_error_propagation (and vice versa). The actual test bodies are moved verbatim. This is a code-move/refactoring change with no functional modifications to the Amount/SignedAmount arithmetic or error handling logic.
Changed components
units/src/amount/result.rs (tests only)Inspect captured patch +12 / −12
diff --git a/units/src/amount/result.rs b/units/src/amount/result.rs
index 86291bde..607fd8a0 100644
--- a/units/src/amount/result.rs
+++ b/units/src/amount/result.rs
@@ -327,26 +327,26 @@ mod tests {
}
#[test]
- fn test_sum_signed_amount_results() {
+ fn test_sum_amount_with_error_propagation() {
let amounts = [
- NumOpResult::Valid(SignedAmount::from_sat_i32(100)),
- NumOpResult::Valid(SignedAmount::from_sat_i32(-50)),
- NumOpResult::Valid(SignedAmount::from_sat_i32(200)),
+ NumOpResult::Valid(Amount::from_sat_u32(100)),
+ NumOpResult::Error(NumOpError::while_doing(MathOp::Add)),
+ NumOpResult::Valid(Amount::from_sat_u32(200)),
];
- let sum: NumOpResult<SignedAmount> = amounts.into_iter().sum();
- assert_eq!(sum, NumOpResult::Valid(SignedAmount::from_sat_i32(250)));
+ let sum: NumOpResult<Amount> = amounts.into_iter().sum();
+ assert!(matches!(sum, NumOpResult::Error(_)));
}
#[test]
- fn test_sum_with_error_propagation() {
+ fn test_sum_signed_amount_results() {
let amounts = [
- NumOpResult::Valid(Amount::from_sat_u32(100)),
- NumOpResult::Error(NumOpError::while_doing(MathOp::Add)),
- NumOpResult::Valid(Amount::from_sat_u32(200)),
+ NumOpResult::Valid(SignedAmount::from_sat_i32(100)),
+ NumOpResult::Valid(SignedAmount::from_sat_i32(-50)),
+ NumOpResult::Valid(SignedAmount::from_sat_i32(200)),
];
- let sum: NumOpResult<Amount> = amounts.into_iter().sum();
- assert!(matches!(sum, NumOpResult::Error(_)));
+ let sum: NumOpResult<SignedAmount> = amounts.into_iter().sum();
+ assert_eq!(sum, NumOpResult::Valid(SignedAmount::from_sat_i32(250)));
}
}
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.