Catch new match arm cargo mutants#686
Conversation
Pull Request Test Coverage Report for Build 14887651084Details
💛 - Coveralls |
| warn!("only one additional-fee parameter specified: {params:?}"); | ||
| } | ||
| _ => (), | ||
| (None, None) => (), |
There was a problem hiding this comment.
This is a notable change to prevent the mutant, seeing as it is the only remaining possibility I thought it was an ok change to make here.
| } | ||
| }, | ||
| ("minfeerate", fee_rate) => | ||
| ("minfeerate", fee_rate) => { |
There was a problem hiding this comment.
These bracket changes seem like a lint. Were these fixes autogen or is this your preferred syntax or something else?
There was a problem hiding this comment.
definitely autogen, I have been struggling a bit after I reset my dev environment to try out nixos
1f5c7c3 to
8ef8b21
Compare
spacebear21
left a comment
There was a problem hiding this comment.
tACK 8ef8b21
I ran cargo mutants on master then this branch and confirmed the 7 missed mutants are gone. I also got 3-4 timeouts on both branches that seem unrelated to this PR but may be worth a follow up if others can replicate.
Any traces for those timeouts? |
DanGould
left a comment
There was a problem hiding this comment.
Would you pretty please change the error so that we can test the pattern (which is different from exact equality)?
We should be able to use this pattern elsewhere to get rid of the string checks, which, check out the following review, can be buggy for actually testing desired behavior
payjoin/src/uri/mod.rs
Outdated
| assert_eq!( | ||
| pjuri.unwrap_err().to_string(), | ||
| bitcoin_uri::de::Error::Extras(PjParseError::from( | ||
| InternalPjParseError::DuplicateParams("pjos") | ||
| )) | ||
| .to_string() |
There was a problem hiding this comment.
This is a very weird assert, testing string equality but from a differently produced error. DuplicateParams("pjos") not DuplicateParams("pj"), which error matching would catch
IMO this test should be updated to
fn test_pj_duplicate_params() {
let uri =
"bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?pjos=1&pjos=1&pj=HTTPS://EXAMPLE.COM/\
%23OH1QYPM5JXYNS754Y4R45QWE336QFX6ZR8DQGVQCULVZTV20TFVEYDMFQC";
let pjuri = Uri::try_from(uri);
assert!(matches!(
pjuri,
Err(bitcoin_uri::de::Error::Extras(PjParseError(
InternalPjParseError::DuplicateParams("pjos")
)))
));
let uri =
"bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?pjos=1&pj=HTTPS://EXAMPLE.COM/\
%23OH1QYPM5JXYNS754Y4R45QWE336QFX6ZR8DQGVQCULVZTV20TFVEYDMFQC&pj=HTTPS://EXAMPLE.COM/\
%23OH1QYPM5JXYNS754Y4R45QWE336QFX6ZR8DQGVQCULVZTV20TFVEYDMFQC";
let pjuri = Uri::try_from(uri);
assert!(matches!(
pjuri,
Err(bitcoin_uri::de::Error::Extras(PjParseError(
InternalPjParseError::DuplicateParams("pj")
)))
));
}before merge, which requires one setup commit that changes visibility PjParseError(pub(crate) InternalPjParseError)
There was a problem hiding this comment.
Wow, definitely an oversight on that mistake! Ok, I get it now, didn't quite understand the intention from the previous review, but I like this pattern.
There was a problem hiding this comment.
fwiw I didn't quite understand the difference between equality and pattern matching until I dug in here, so my intention was unclear. I could just smell we weren't testing the right thing
To allow for better error pattern matching and not string comparison for errors it would be helpful to have internal error types at least public within the payjoin crate for comparison.
The newest version of cargo mutants v25.0.1 added a new type of mutation that attempts to delete entire match arms.
master: this branch: |
DanGould
left a comment
There was a problem hiding this comment.
ACK 7b3ea49
@spacebear21 must the timeouts you mentioned block merge or may we proceed with what we have here?
|
They seem unrelated and I can't replicate reliably so this is fine to merge. |
The newest version of cargo mutants v25.0.1 added a new type of mutation that attempts to delete entire match arms.
Mutants passing on 7b3ea49
259 mutants tested in 8m 49s: 163 caught, 96 unviableCloses #671