Skip to content

Commit

Permalink
Merge rust-bitcoin#4038: Update mutants.toml
Browse files Browse the repository at this point in the history
3c12d4e Add primitives to mutants.toml (Jamil Lambert, PhD)
32b0513 Reorganize mutants.toml (Jamil Lambert, PhD)

Pull request description:

  All of the mutants found by `cargo mutants` in primitives have been killed in: rust-bitcoin#3948, rust-bitcoin#3971, rust-bitcoin#3987, rust-bitcoin#4012, rust-bitcoin#4019, rust-bitcoin#4020, rust-bitcoin#4024, rust-bitcoin#4033, rust-bitcoin#4036, rust-bitcoin#4037.

  Add `deserialize` as a general exception.  The mutant is changing the return value to Ok(Default::default()), and a test to kill it doesn't prove anything other than the function can return something.

  Reword comments to make them clearer.

  Add the required exceptions for cases in primitives that need to be skipped.

  Add primitives to the examine paths.

ACKs for top commit:
  tcharding:
    ACK 3c12d4e
  apoelstra:
    ACK 3c12d4e; successfully ran local tests

Tree-SHA512: 8848164bfea8f44c49c3055d3c6daa9bbc6d65de86b36b1f2022e6cb872602ee878a1dcf62c10da615b26c906d97a606ab4b96cf12d1a2bced2984ec03cc6d67
  • Loading branch information
apoelstra committed Feb 13, 2025
2 parents 58bb2b1 + 3c12d4e commit 20e970d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions .cargo/mutants.toml
Original file line number Diff line number Diff line change
@@ -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
]
Expand All @@ -8,20 +8,25 @@ exclude_re = [
"impl Arbitrary",
"impl Display",
".*Error",
# --------------------------------------------Crate-specific exclusions--------------------------------------------
"deserialize", # Skip serde mutation tests
"Iterator", # Mutating operations in an iterator can result in an infinite loop

# ----------------------------------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::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_sat_per_vb_floor::opt::deserialize::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_sat_per_vb_ceil::opt::deserialize::<impl Visitor for VisitOpt>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
# src/amount/serde.rs
"as_sat::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_btc::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # Replaces return value with Ok(Default::default()), which is the same as Ok(None)
"as_str::opt::deserialize::<impl Visitor for VisitOptAmt<X>>.*", # 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

# 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<Checked>::cached_witness_root", # Skip getters
"Block<Checked>::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
]

0 comments on commit 20e970d

Please sign in to comment.