Skip to content

Full mutation coverage on send in the payjoin crate - #748

Merged
spacebear21 merged 4 commits into
payjoin:masterfrom
benalleng:sender-mutants-2
Jun 12, 2025
Merged

spacebear21 merged 4 commits into
payjoin:masterfrom
benalleng:sender-mutants-2

Conversation

@benalleng

@benalleng benalleng commented Jun 6, 2025 •

Copy link
Copy Markdown
Collaborator

This adds full mutation coverage for our sender. After this merges we will have full mutation coverage on send and receive! A nice step forward for adversarial tests!

@coveralls

coveralls commented Jun 6, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 15618943659

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 118 of 131 (90.08%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 85.931%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/send/v2/mod.rs 3 4 75.0%
payjoin/src/send/multiparty/mod.rs 18 20 90.0%
payjoin/src/send/v1.rs 90 92 97.83%
payjoin/src/send/multiparty/error.rs 0 8 0.0%
Totals Coverage Status
Change from base Build 15616178603: 0.3%
Covered Lines: 7128
Relevant Lines: 8295

💛 - Coveralls

I got a bit confused on the error comparison when working with the
InternalBuilderSender error and the error comparison here. This is
cleaner to just compare to an Err type and not an Option of the internal
error.
@benalleng

This comment was marked as outdated.

@benalleng
benalleng marked this pull request as ready for review June 11, 2025 17:30
Comment thread payjoin/src/send/v1.rs

#[test]
fn test_build_recommended_multiple_inputs() -> Result<(), BoxError> {
let mut psbt = Psbt::from_str(MULTIPARTY_ORIGINAL_PSBT_ONE).unwrap();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use the multiparty original psbt here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this to be a quick way to introduce an additional set of input_pairs for build_recommended to ensure that the for loop there runs at least once. I will go ahead and add some docstring comments to clarify these 2 tests.

Comment thread payjoin/src/send/v1.rs Outdated
}

#[test]
fn test_build_recommended_modified_outputs() -> Result<(), BoxError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may help to add some comments or a docstring that explains the purpose of these tests. For example, I can tell that this test takes the vector original PSBT and modifies output 0 and adds a new output (duplicated from output 1) so we now have 3 outputs, builds a Sender, and expects a success. Then it repeats, removing output 0 this time. But I don't have an intuition of what this proves and why?

test_build_recommended_fee_contribution is pretty self-explanatory. test_build_recommended_modified_outputs and test_build_recommended_multiple_inputs less so. I assume the reason they're there is they explicitly kill some mutants?

@benalleng
benalleng force-pushed the sender-mutants-2 branch 2 times, most recently from a04db96 to 3763460 Compare June 11, 2025 21:01
Comment thread payjoin/src/send/v1.rs Resolved
@benalleng
benalleng force-pushed the sender-mutants-2 branch 3 times, most recently from bf2fe2e to b22a918 Compare June 12, 2025 18:56
This adds the tests to cover mutations for the send directory in
its entirety.
With full mutation coverage we can now include the whole send directory
in our mutants toml.
In payjoin#660 we added a process_get_res and process_post_res methods in
ohttps to pull away some of the logic from our send module but
multiparty remained the same.

This PR attempts pull sync the multiparty sender error handling with
this new approach. As well this change gets rid of the remaining mutant
on this status code match block.

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 2531308

Ran it locally and got:

❯ cargo mutants -j 2
Found 415 mutants to test
ok       Unmutated baseline in 16.2s build + 19.6s test
 INFO Auto-set test timeout to 1m 39s
TIMEOUT  payjoin/src/receive/v1/mod.rs:641:74: replace -= with += in ProvisionalProposal::apply_fee in 2.0s build + 99.0s test
415 mutants tested in 17m 45s: 251 caught, 163 unviable, 1 timeouts

I get unreproducible timeouts on my machine for unknown reasons so that one is safe to ignore.

@spacebear21

Copy link
Copy Markdown
Collaborator

86% coverage and no mutants in all of send/receive!!! 🚀

@spacebear21
spacebear21 merged commit ab191b4 into payjoin:master Jun 12, 2025
@benalleng
benalleng deleted the sender-mutants-2 branch March 27, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants