Skip to content

Commit 674ac57

Browse files
committed
Merge rust-bitcoin#5000: Kill new mutants
81e149e Add mutant excludes for serde expecting messages (Jamil Lambert, PhD) 8d3d504 Add mutant excludes for deprecated to_hex methods (Jamil Lambert, PhD) e6ea5f4 Add missing SignedAmount tests (Jamil Lambert, PhD) f808546 Move Amount test (Jamil Lambert, PhD) Pull request description: Weekly mutation testing found new mutants. There are also two in primitives found locally from changes since the last weekly run. - Move a test for `Amount` to be with the others instead of under the `SignedAmount` test. - Add two tests for `SignedAmount` that were previously only done for `Amount`. - Exclude two deprecated `to_hex` functions that created mutants. - Add an exclude that covers two `serde` `expecting` messages that created mutants. Closes rust-bitcoin#4987 ACKs for top commit: tcharding: ACK 81e149e apoelstra: ACK 81e149e; successfully ran local tests Tree-SHA512: e85e0f68562a1e3e850ac00e44d9d9467ef45c3aa82beb5163141d852f2bd76d783cdb6655e8ed3afdbb778b2614c3ee9e467a698909f712524879708746466b
2 parents f5c87b6 + 81e149e commit 674ac57

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

.cargo/mutants.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exclude_re = [
99
"impl fmt::Debug",
1010
".*Error",
1111
"deserialize", # Skip serde mutation tests
12+
"serde_details::<impl de::Visitor<'_>", # Skip serde mutation tests
1213
"Iterator", # Mutating operations in an iterator can result in an infinite loop
1314

1415
# ----------------------------------Crate-specific exclusions----------------------------------
@@ -39,5 +40,7 @@ exclude_re = [
3940
"fmt_debug_pretty", # Mutants from formatting/display changes
4041
"CompactTarget::to_hex", # Deprecated
4142
"Script::to_hex", # Deprecated
43+
"Script<T>::to_hex", # Deprecated
4244
"ScriptBuf::to_hex", # Deprecated
45+
"ScriptBuf<T>::to_hex", # Deprecated
4346
]

units/src/amount/result.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@ mod tests {
326326
assert_eq!(sum, NumOpResult::Valid(Amount::from_sat_u32(600)));
327327
}
328328

329+
#[test]
330+
fn test_sum_amount_with_error_propagation() {
331+
let amounts = [
332+
NumOpResult::Valid(Amount::from_sat_u32(100)),
333+
NumOpResult::Error(NumOpError::while_doing(MathOp::Add)),
334+
NumOpResult::Valid(Amount::from_sat_u32(200)),
335+
];
336+
337+
let sum: NumOpResult<Amount> = amounts.into_iter().sum();
338+
assert!(matches!(sum, NumOpResult::Error(_)));
339+
}
340+
329341
#[test]
330342
fn test_sum_signed_amount_results() {
331343
let amounts = [
@@ -339,14 +351,26 @@ mod tests {
339351
}
340352

341353
#[test]
342-
fn test_sum_with_error_propagation() {
354+
fn test_sum_signed_amount_results_with_references() {
343355
let amounts = [
344-
NumOpResult::Valid(Amount::from_sat_u32(100)),
356+
NumOpResult::Valid(SignedAmount::from_sat_i32(100)),
357+
NumOpResult::Valid(SignedAmount::from_sat_i32(-50)),
358+
NumOpResult::Valid(SignedAmount::from_sat_i32(200)),
359+
];
360+
361+
let sum: NumOpResult<SignedAmount> = amounts.iter().sum();
362+
assert_eq!(sum, NumOpResult::Valid(SignedAmount::from_sat_i32(250)));
363+
}
364+
365+
#[test]
366+
fn test_sum_signed_amount_with_error_propagation() {
367+
let amounts = [
368+
NumOpResult::Valid(SignedAmount::from_sat_i32(100)),
345369
NumOpResult::Error(NumOpError::while_doing(MathOp::Add)),
346-
NumOpResult::Valid(Amount::from_sat_u32(200)),
370+
NumOpResult::Valid(SignedAmount::from_sat_i32(200)),
347371
];
348372

349-
let sum: NumOpResult<Amount> = amounts.into_iter().sum();
373+
let sum: NumOpResult<SignedAmount> = amounts.into_iter().sum();
350374
assert!(matches!(sum, NumOpResult::Error(_)));
351375
}
352376
}

0 commit comments

Comments
 (0)