From 32b05132b542a657911feb5f8477d17c84334502 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Tue, 11 Feb 2025 17:45:14 +0000 Subject: [PATCH 1/2] Reorganize mutants.toml Generalize `deserialize` as an exception for everywhere. Reword comment to make clearer --- .cargo/mutants.toml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml index b6ed18c553..9247476897 100644 --- a/.cargo/mutants.toml +++ b/.cargo/mutants.toml @@ -8,20 +8,14 @@ exclude_re = [ "impl Arbitrary", "impl Display", ".*Error", - # --------------------------------------------Crate-specific exclusions-------------------------------------------- + "deserialize", # Skip serde mutation tests + + # ----------------------------------Crate-specific exclusions---------------------------------- # Units # src/amount/mod.rs "parse_signed_to_satoshi", # Can't kill all mutants since there is no denomination smaller than Satoshi "fmt_satoshi_in", # Related to formatting/display "dec_width", # Replacing num /= 10 with num %=10 in a loop causes a timeout due to infinite loop - # src/fee_rate/serde.rs - "as_sat_per_kwu::opt::deserialize::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) - "as_sat_per_vb_floor::opt::deserialize::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) - "as_sat_per_vb_ceil::opt::deserialize::.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) - # src/amount/serde.rs - "as_sat::opt::deserialize::>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) - "as_btc::opt::deserialize::>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) - "as_str::opt::deserialize::>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None) # src/locktime/relative.rs - "Time::to_consensus_u32" # It will replace | with ^, which will return the same value since the XOR is always taken against the u16 and an all-zero bitmask + "Time::to_consensus_u32", # Mutant from replacing | with ^, this returns the same value since the XOR is taken against the u16 with an all-zero bitmask ] From 3c12d4eb1fcdfc8d7569ef3f4024811017abd15c Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Tue, 11 Feb 2025 17:52:32 +0000 Subject: [PATCH 2/2] Add primitives to mutants.toml Add exceptions for `primitives` to `mutants.toml`. Add `primitives` to the list of paths to run cargo mutants on. --- .cargo/mutants.toml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml index 9247476897..6477f498ed 100644 --- a/.cargo/mutants.toml +++ b/.cargo/mutants.toml @@ -1,5 +1,5 @@ additional_cargo_args = ["--all-features"] -examine_globs = ["units/src/**/*.rs"] +examine_globs = ["units/src/**/*.rs", "primitives/src/**/*.rs"] exclude_globs = [ "units/src/amount/verification.rs" # kani tests ] @@ -9,6 +9,7 @@ exclude_re = [ "impl Display", ".*Error", "deserialize", # Skip serde mutation tests + "Iterator", # Mutating operations in an iterator can result in an infinite loop # ----------------------------------Crate-specific exclusions---------------------------------- # Units @@ -18,4 +19,14 @@ exclude_re = [ "dec_width", # Replacing num /= 10 with num %=10 in a loop causes a timeout due to infinite loop # src/locktime/relative.rs "Time::to_consensus_u32", # Mutant from replacing | with ^, this returns the same value since the XOR is taken against the u16 with an all-zero bitmask + + # primitives + "Sequence::from_512_second_intervals", # Mutant from replacing | with ^, this returns the same value since the XOR is taken against the u16 with an all-zero bitmask + "Opcode::classify", # Not possible to kill all mutants without individually checking every opcode classification + "Block::cached_witness_root", # Skip getters + "Block::transactions", # Skip getters + "Script::to_bytes", # Deprecated + "decode_cursor", # Mutating operations in decode_cursor can result in an infinite loop + "fmt_debug", # Mutants from formatting/display changes + "fmt_debug_pretty", # Mutants from formatting/display changes ]