Merge rust-bitcoin/rust-bitcoin#4287: units: Kill mutants found in weekly mutation testing

f15e461baf Add an exclusion for a mutant in a deprecated fn (Jamil Lambert, PhD)
9a2b56f381 Modify test in Amount to kill mutants (Jamil Lambert, PhD)
1d1cf00b1e Add test to BlockTime to kill mutants (Jamil Lambert, PhD)

Pull request description:

  Weekly mutation testing found mutants in `Amount` and `BlockTime`.

  Add a test to `BlockTime`.
  Add two asserts to `Amount` tests.
  Exclude deprecated function from mutation testing.

  Closes #4225, #4243, #4278

ACKs for top commit:
  apoelstra:
    ACK f15e461baf463da0bf9d89018180c1d5032106c1; successfully ran local tests

Tree-SHA512: 18a405362db1b2eabac7c7ac01a56d306a1bf5f705626b5c217ec329e6420daa2f2e62b37c72537f29b7ee76b9fd795adde2da71b226fec3a74d0f25dca6cd96
This commit is contained in:
merge-script 2025-03-28 12:29:14 +00:00
commit 171c779c01
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 17 additions and 0 deletions

View File

@ -21,6 +21,7 @@ exclude_re = [
"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 "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
"FeeRate::fee_vb", # Deprecated "FeeRate::fee_vb", # Deprecated
"FeeRate::fee_wu", # Deprecated "FeeRate::fee_wu", # Deprecated
"SignedAmount::checked_abs", # Deprecated
# primitives # 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 "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

View File

@ -104,8 +104,13 @@ fn from_str_zero_without_denomination() {
fn from_int_btc() { fn from_int_btc() {
let amt = Amount::from_btc_u16(2); let amt = Amount::from_btc_u16(2);
assert_eq!(sat(200_000_000), amt); assert_eq!(sat(200_000_000), amt);
let amt = Amount::from_int_btc(2_u16);
assert_eq!(sat(200_000_000), amt);
let amt = SignedAmount::from_btc_i16(-2); let amt = SignedAmount::from_btc_i16(-2);
assert_eq!(ssat(-200_000_000), amt); assert_eq!(ssat(-200_000_000), amt);
let amt = SignedAmount::from_int_btc(-2_i16);
assert_eq!(ssat(-200_000_000), amt);
} }
#[test] #[test]

View File

@ -56,3 +56,14 @@ impl<'a> Arbitrary<'a> for BlockTime {
Ok(BlockTime::from(t)) Ok(BlockTime::from(t))
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn block_time_round_trip() {
let t = BlockTime::from(1_742_979_600); // 26 Mar 2025 9:00 UTC
assert_eq!(u32::from(t), 1_742_979_600);
}
}