Skip to content

Commit ca5d136

Browse files
committed
Merge rust-bitcoin#4666: Kill new mutants
f056250 Exclude deprecated fn from mutation testing (Jamil Lambert, PhD) 4d31b14 Improve is_too_precise test (Jamil Lambert, PhD) a2bae3b Add test for impl Display for Script (Jamil Lambert, PhD) Pull request description: Weekly mutation testing found new mutants. There are also some untested mutants in match statements that will be included in future mutation testing once rust-bitcoin#4654 goes in. - Add a regression test for the mutants in the `Display` impl for `Script`. - Improve the existing test for `is_too_precise` to check all four cases. - Exclude the two deprecated functions that have untested mutants. Closes rust-bitcoin#4646 ACKs for top commit: benalleng: **tACK** no missed mutants on f056250 I ran with rust-bitcoin@63b61e9 rebased in to make sure the match arm and match guard mutations were included tcharding: ACK f056250 Tree-SHA512: d109e30be91da2ab243a152b9ef17147337328282ac418fa9d2eebd17c2e2d9b6f7ee095d91ccf58e287c9620cb71a090b0d929c9bf35011feb26e6f28457dd3
2 parents 7ba49d6 + f056250 commit ca5d136

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.cargo/mutants.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ exclude_re = [
2424
"SignedAmount::checked_abs", # Deprecated
2525
"NumberOfBlocks::value", # Deprecated
2626
"NumberOf512Seconds::to_consensus_u32", # Deprecated
27+
"MedianTimePast::to_consensus_u32", # Deprecated
28+
"Height::to_consensus_u32", # Deprecated
2729

2830
# primitives
2931
"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

primitives/src/script/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,21 @@ mod tests {
802802
assert!(!format!("{:?}", script).is_empty());
803803
}
804804

805+
#[test]
806+
fn script_display_pushdata() {
807+
// OP_PUSHDATA1
808+
let script = Script::from_bytes(&[0x4c, 0x02, 0xab, 0xcd]);
809+
assert_eq!(format!("{}", script), "OP_PUSHDATA1 abcd");
810+
811+
// OP_PUSHDATA2
812+
let script = Script::from_bytes(&[0x4d, 0x02, 0x00, 0x12, 0x34]);
813+
assert_eq!(format!("{}", script), "OP_PUSHDATA2 1234");
814+
815+
// OP_PUSHDATA4
816+
let script = Script::from_bytes(&[0x4e, 0x02, 0x00, 0x00, 0x00, 0x56, 0x78]);
817+
assert_eq!(format!("{}", script), "OP_PUSHDATA4 5678");
818+
}
819+
805820
#[test]
806821
fn scriptbuf_display() {
807822
let script_buf = ScriptBuf::from(vec![0x00, 0xa1, 0xb2]);

units/src/amount/tests.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ fn sanity_check() {
5252

5353
#[test]
5454
fn check_if_num_is_too_precise() {
55-
assert_eq!(is_too_precise("1234", 3).unwrap(), 3);
56-
assert_eq!(is_too_precise("1234.1234", 3).unwrap(), 3);
55+
// Has decimal, not too precise
56+
assert_eq!(is_too_precise("1234.5678", 4), Some(0));
57+
// Has decimal, is too precise
58+
assert_eq!(is_too_precise("1234.5678", 3), Some(3));
59+
// No decimal, not too precise
60+
assert_eq!(is_too_precise("1234", 4), Some(0));
61+
// No decimal, is too precise
62+
assert_eq!(is_too_precise("1234", 2), Some(3));
5763
}
5864

5965
#[test]

0 commit comments

Comments
 (0)