You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pr adds complete mutation coverage onto the payjoin crate within
rust-payjoin.
We did discover an outstanding mutant that we still want to explore more
as to whether we should modify the source code or keep the behavior as
is in #948.
Copy file name to clipboardExpand all lines: .cargo/mutants.toml
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,12 @@
1
1
additional_cargo_args = ["--all-features"]
2
2
gitignore = true
3
3
examine_globs = [
4
-
"payjoin/src/core/ohttp.rs",
5
-
"payjoin/src/core/uri/*.rs",
6
-
"payjoin/src/core/receive/**/*.rs",
7
-
"payjoin/src/core/send/**/*.rs"
4
+
"payjoin/src/**/*.rs"
5
+
]
6
+
exclude_globs = [
8
7
]
9
-
exclude_globs = []
10
8
exclude_re = [
11
-
"impl Debug",
12
-
"impl Display",
9
+
"impl (fmt::)?(Debug|Display)",
13
10
"deserialize",
14
11
"Iterator",
15
12
".*Error",
@@ -41,4 +38,5 @@ exclude_re = [
41
38
"replace > with >= in WantsInputs::avoid_uih", # This mutation I am unsure about whether or not it is a trivial mutant and have not decided on how the best way to approach testing it is
42
39
# payjoin/src/core/send/mod.rs
43
40
"replace match guard proposed_txout.script_pubkey == original_output.script_pubkey with true in PsbtContext::check_outputs", # This non-deterministic mutation has a possible test to catch it
41
+
"replace == with != in Receiver<Initialized>::unchecked_from_payload", #This mutant is something we intend to address in issue #948
Copy file name to clipboardExpand all lines: payjoin/src/core/persist.rs
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
use std::fmt;
1
2
/// Handles cases where the transition either succeeds with a final result that ends the session, or hits a static condition and stays in the same state.
2
3
/// State transition may also be a fatal error or transient error.
let validated_pairs = psbt.validate_input_utxos();
419
+
assert!(validated_pairs.is_ok());
420
+
}
421
+
422
+
#[test]
423
+
fninput_pairs_validate_witness_utxo(){
424
+
let psbt:Psbt = PARSED_ORIGINAL_PSBT.clone();
425
+
let txin = &psbt.unsigned_tx.input[0];
426
+
let psbtin = &psbt.inputs[0];
427
+
428
+
let pair:InternalInputPair = InternalInputPair{ txin, psbtin };
429
+
assert!(pair.validate_utxo().is_ok());
430
+
}
431
+
432
+
#[test]
433
+
fninput_pairs_validate_non_witness_utxo(){
434
+
// This test checks each variation of the validate_utxo match block with no
435
+
// non_witness_utxo
436
+
let psbt:Psbt = PARSED_ORIGINAL_PSBT.clone();
437
+
let raw_tx = "010000000001015721029046ec1840d5bc8f4e59ae8ac4b576191d5e7994c8d1c44ddeaffc176c0300000000fdffffff018e8d00000000000017a9144a87748bc7bcfee8290e36700eeca3112f53ecbe870140239d1975e0fc9b8345bce9a170a0224cf8eb327bfcaccf0f8b9434d17345579e4dcbb68f7be39eac7987dfaa08293b11fdc76ac28e26bd85e99a46b69675418100000000";
438
+
439
+
letmut txin = psbt.unsigned_tx.input[0].clone();
440
+
letmut psbtin = psbt.inputs[0].clone();
441
+
442
+
let transaction:Transaction = bitcoin::consensus::encode::deserialize_hex(raw_tx).unwrap();
let pair:InternalInputPair = InternalInputPair{txin:&txin,psbtin:&psbtin };
448
+
assert!(pair.validate_utxo().is_ok());
449
+
}
450
+
451
+
#[test]
452
+
fninput_pairs_unequal_txid(){
453
+
// This test checks each variation of the validate_utxo match block where is it expected to
454
+
// return an unequal_txid error
455
+
let psbt:Psbt = PARSED_ORIGINAL_PSBT.clone();
456
+
let raw_tx = "010000000001015721029046ec1840d5bc8f4e59ae8ac4b576191d5e7994c8d1c44ddeaffc176c0300000000fdffffff018e8d00000000000017a9144a87748bc7bcfee8290e36700eeca3112f53ecbe870140239d1975e0fc9b8345bce9a170a0224cf8eb327bfcaccf0f8b9434d17345579e4dcbb68f7be39eac7987dfaa08293b11fdc76ac28e26bd85e99a46b69675418100000000";
457
+
458
+
let txin = &psbt.unsigned_tx.input[0];
459
+
letmut psbtin = psbt.inputs[0].clone();
460
+
461
+
let transaction:Transaction = bitcoin::consensus::encode::deserialize_hex(raw_tx).unwrap();
462
+
psbtin.non_witness_utxo = Some(transaction);
463
+
464
+
let pair:InternalInputPair = InternalInputPair{ txin,psbtin:&psbtin };
let raw_tx = "010000000001015721029046ec1840d5bc8f4e59ae8ac4b576191d5e7994c8d1c44ddeaffc176c0300000000fdffffff018e8d00000000000017a9144a87748bc7bcfee8290e36700eeca3112f53ecbe870140239d1975e0fc9b8345bce9a170a0224cf8eb327bfcaccf0f8b9434d17345579e4dcbb68f7be39eac7987dfaa08293b11fdc76ac28e26bd85e99a46b69675418100000000";
484
+
485
+
letmut txin = psbt.unsigned_tx.input[0].clone();
486
+
letmut psbtin = psbt.inputs[0].clone();
487
+
488
+
let transaction:Transaction = bitcoin::consensus::encode::deserialize_hex(raw_tx).unwrap();
0 commit comments