Skip to content

Add additional tests for v1 send module - #556

Merged
spacebear21 merged 1 commit into
payjoin:masterfrom
benalleng:main-send-module-test
Mar 13, 2025
Merged

spacebear21 merged 1 commit into
payjoin:masterfrom
benalleng:main-send-module-test

Conversation

@benalleng

@benalleng benalleng commented Feb 27, 2025 •

Copy link
Copy Markdown
Collaborator

Relates to #539

These additional tests add more coverage for cargo mutant testing in addition to removing .unwrap() where possible. For some of the missing cargo mutant tests where the error occurs because of a change in operator I have mostly avoided for now as I mainly focused on completely missing test vectors.

Again I tried to make any modifications closely inline with #487

Below are the mutants for send/v1.rs and send/mod.rs as of df30f3b

Details
// mod.rs
caught   payjoin/src/send/mod.rs:429:21: replace > with == in serialize_url in 7.6s build + 1.1s test
caught   payjoin/src/send/mod.rs:288:33: replace != with == in check_single_payee in 5.5s build + 1.1s test
caught   payjoin/src/send/mod.rs:241:45: replace < with > in PsbtContext::check_outputs in 6.0s build + 1.2s test
***MISSED   payjoin/src/send/mod.rs:431:67: replace / with * in serialize_url in 5.4s build + 1.5s test
caught   payjoin/src/send/mod.rs:154:54: replace == with != in PsbtContext::check_inputs in 6.3s build + 1.2s test
caught   payjoin/src/send/mod.rs:238:51: replace == with != in PsbtContext::check_outputs in 6.5s build + 1.3s test
caught   payjoin/src/send/mod.rs:241:45: replace < with == in PsbtContext::check_outputs in 5.7s build + 1.4s test
caught   payjoin/src/send/mod.rs:334:5: replace check_fee_output_amount -> Result<bitcoin::Amount, InternalBuildSenderError> with Ok(Default::default()) in 5.6s build + 0.9s test
***MISSED   payjoin/src/send/mod.rs:239:21: replace && with || in PsbtContext::check_outputs in 2.7s build + 0.8s test
***MISSED   payjoin/src/send/mod.rs:431:67: replace / with % in serialize_url in 13.5s build + 0.9s test
***MISSED   payjoin/src/send/mod.rs:262:53: replace == with != in PsbtContext::check_outputs in 1.6s build + 0.8s test
caught   payjoin/src/send/mod.rs:389:29: replace == with != in check_change_index in 1.6s build + 0.6s test
***MISSED   payjoin/src/send/mod.rs:123:30: replace > with < in PsbtContext::check_fees in 1.8s build + 0.8s test
***MISSED   payjoin/src/send/mod.rs:356:63: replace == with != in find_change_index in 1.7s build + 0.7s test
caught   payjoin/src/send/mod.rs:208:50: replace == with != in PsbtContext::restore_original_utxos in 4.5s build + 0.7s test
caught   payjoin/src/send/mod.rs:284:5: replace check_single_payee -> Result<(), InternalBuildSenderError> with Ok(()) in 2.0s build + 0.7s test
***MISSED   payjoin/src/send/mod.rs:250:54: replace == with != in PsbtContext::check_outputs in 1.9s build + 0.7s test
caught   payjoin/src/send/mod.rs:286:33: replace == with != in check_single_payee in 1.8s build + 0.7s test
***MISSED   payjoin/src/send/mod.rs:334:21: replace < with == in check_fee_output_amount in 1.8s build + 0.9s test
caught   payjoin/src/send/mod.rs:352:5: replace find_change_index -> Result<Option<AdditionalFeeContribution>, InternalBuildSenderError> with Ok(None) in 2.5s build + 0.7s test
caught   payjoin/src/send/mod.rs:239:47: replace == with != in PsbtContext::check_outputs in 78.2s build + 0.8s test
caught   payjoin/src/send/mod.rs:242:65: replace - with + in PsbtContext::check_outputs in 1.7s build + 0.6s test
caught   payjoin/src/send/mod.rs:334:21: replace < with > in check_fee_output_amount in 1.8s build + 0.7s test
***MISSED   payjoin/src/send/mod.rs:354:64: replace == with != in find_change_index in 1.8s build + 0.8s test
caught   payjoin/src/send/mod.rs:404:5: replace determine_fee_contribution -> Result<Option<AdditionalFeeContribution>, InternalBuildSenderError> with Ok(None) in 2.4s build + 0.7s test
***MISSED   payjoin/src/send/mod.rs:429:21: replace > with < in serialize_url in 1.9s build + 0.8s test
caught   payjoin/src/send/mod.rs:366:50: replace != with == in find_change_index in 1.9s build + 0.7s test
caught   payjoin/src/send/mod.rs:306:5: replace clear_unneeded_fields with () in 1.9s build + 0.7s test
caught   payjoin/src/send/mod.rs:115:28: replace + with - in PsbtContext::check_fees in 1.8s build + 0.7s test
***MISSED   payjoin/src/send/mod.rs:123:30: replace > with == in PsbtContext::check_fees in 2.4s build + 0.7s test
// v1.rs
***MISSED   payjoin/src/send/v1.rs:122:30: replace < with == in SenderBuilder<'a>::build_recommended in 8.1s build + 1.7s test
***MISSED   payjoin/src/send/v1.rs:90:51: replace == with != in SenderBuilder<'a>::build_recommended in 5.7s build + 1.6s test
***MISSED   payjoin/src/send/v1.rs:89:47: replace == with != in SenderBuilder<'a>::build_recommended in 5.9s build + 1.5s test
***MISSED   payjoin/src/send/v1.rs:116:65: replace + with - in SenderBuilder<'a>::build_recommended in 6.6s build + 1.5s test
***MISSED   payjoin/src/send/v1.rs:122:30: replace < with > in SenderBuilder<'a>::build_recommended in 5.7s build + 1.5s test
***MISSED   payjoin/src/send/v1.rs:90:13: replace && with || in SenderBuilder<'a>::build_recommended in 5.5s build + 1.4s test
***MISSED   payjoin/src/send/v1.rs:90:13: replace && with || in SenderBuilder<'a>::build_recommended in 5.0s build + 1.5s test
***MISSED   payjoin/src/send/v1.rs:116:61: replace + with - in SenderBuilder<'a>::build_recommended in 3.5s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:122:30: replace < with == in SenderBuilder<'a>::build_recommended in 1.7s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:116:61: replace + with - in SenderBuilder<'a>::build_recommended in 1.5s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:116:61: replace + with * in SenderBuilder<'a>::build_recommended in 1.5s build + 0.7s test
caught   payjoin/src/send/v1.rs:102:65: replace != with == in SenderBuilder<'a>::build_recommended in 1.6s build + 0.6s test
***MISSED   payjoin/src/send/v1.rs:116:65: replace + with - in SenderBuilder<'a>::build_recommended in 1.5s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:116:65: replace + with * in SenderBuilder<'a>::build_recommended in 1.5s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:116:61: replace + with * in SenderBuilder<'a>::build_recommended in 1.6s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:116:65: replace + with * in SenderBuilder<'a>::build_recommended in 1.6s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:189:57: replace || with && in SenderBuilder<'a>::build in 4.4s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:122:30: replace < with > in SenderBuilder<'a>::build_recommended in 1.7s build + 0.8s test
caught   payjoin/src/send/v1.rs:102:65: replace != with == in SenderBuilder<'a>::build_recommended in 83.1s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:116:21: replace + with - in SenderBuilder<'a>::build_recommended in 1.9s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:116:21: replace + with - in SenderBuilder<'a>::build_recommended in 1.8s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:112:47: replace != with == in SenderBuilder<'a>::build_recommended in 1.9s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:90:51: replace == with != in SenderBuilder<'a>::build_recommended in 1.8s build + 0.7s test
***MISSED   payjoin/src/send/v1.rs:189:57: replace || with && in SenderBuilder<'a>::build in 1.8s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:112:47: replace != with == in SenderBuilder<'a>::build_recommended in 1.6s build + 0.8s test
***MISSED   payjoin/src/send/v1.rs:89:47: replace == with != in SenderBuilder<'a>::build_recommended in 6.5s build + 0.8s test
110 mutants tested in 3m 59s: 35 missed, 21 caught, 54 unviable

Note that most of the missed mutants are operand switches that could be handled by possibly more asserts in tests?

@coveralls

coveralls commented Feb 27, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 13838340636

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

  • 157 of 164 (95.73%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.4%) to 80.566%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/send/mod.rs 139 146 95.21%
Files with Coverage Reduction New Missed Lines %
payjoin/src/send/mod.rs 2 94.34%
Totals Coverage Status
Change from base Build 13825165112: 0.4%
Covered Lines: 4784
Relevant Lines: 5938

💛 - Coveralls

@spacebear21

Copy link
Copy Markdown
Collaborator

Is there anywhere we can see which mutants the new tests kill specifically? The test coverage is going up, which is great, but I'm curious to see the progress on the mutation testing front. Do you think we could introduce mutation testing one PR at a time as you add these tests so we can ensure no regressions in the future?

Comment thread payjoin/src/send/v1.rs Resolved
Comment thread payjoin/src/send/v1.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
@benalleng
benalleng force-pushed the main-send-module-test branch from 201a4c8 to c0f96bd Compare March 4, 2025 16:37
Comment thread payjoin/src/receive/v1/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
@benalleng
benalleng force-pushed the main-send-module-test branch 2 times, most recently from 058629e to 95de976 Compare March 4, 2025 19:41
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved
Comment thread payjoin/src/send/mod.rs Resolved

@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.

ACK 5100d78 with minor nits. There are merge conflicts so this needs to be rebased on latest master.

Comment thread payjoin/src/send/v1.rs Resolved
Comment thread payjoin/src/send/v2/mod.rs Resolved
These additional tests add more coverage for cargo mutant
testing in addition to removing `.unwrap()` where possible.
For some of the missing cargo mutant tests where the error occurs
because of a change in operator I have mostly avoided for now as I
mainly focused on completely missing test vectors.
@benalleng
benalleng force-pushed the main-send-module-test branch from 5100d78 to 28ef23e Compare March 13, 2025 15:24

@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.

ACK 28ef23e

@spacebear21
spacebear21 merged commit 4c52cbc into payjoin:master Mar 13, 2025
@benalleng
benalleng deleted the main-send-module-test branch March 27, 2026 15:37
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.

5 participants