feat(receive): Add tests for InputPair constructors Closes #583
Add unit tests for the new_p2wpkh and new_p2tr constructors within the receive module (payjoin/src/receive/mod.rs). These tests verify that the constructors correctly initialize the InputPair struct, ensuring both the TxIn and psbt::Input components match expected values.
This improves code quality by confirming constructor behavior and guarding against regressions.
Also addresses compilation errors found during testing:
- Corrected call to new_p2wpkh to include the
sequenceargument. - Removed assertions checking non-existent fields on
psbt::Input(e.g.,script_sig,tap_control_block). - Renamed
tap_leaf_scriptsto the correct fieldtap_scriptsin assertions.
Pull Request Test Coverage Report for Build 14538496834
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.
- For more information on this, see Tracking coverage changes with pull request builds.
- To avoid this issue with future PRs, see these Recommended CI Configurations.
- For a quick fix, rebase this PR at GitHub. Your next report should be accurate.
Details
- 399 of 405 (98.52%) changed or added relevant lines in 1 file are covered.
- 2 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+1.0%) to 82.798%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| payjoin/src/receive/mod.rs | 399 | 405 | 98.52% |
| <!-- | Total: | 399 | 405 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| payjoin/src/send/mod.rs | 2 | 94.46% |
| <!-- | Total: | 2 |
| Totals | |
|---|---|
| Change from base Build 14519980933: | 1.0% |
| Covered Lines: | 5723 |
| Relevant Lines: | 6912 |
💛 - Coveralls
PR Updated:
- Removed
test_new_p2wpkhas suggested - Cleaned up test comments for better readability
- All tests are passing
- Added comprehensive test coverage:
test_privacy_based_input_selection: Tests UIH avoidancetest_fee_rate_based_selection: Validates fee rate enforcementtest_minimum_fee_requirements: Tests end-to-end fee handling
Ready for another review! 👍
Closing this as it has been mainly addressed by #712 #753, with some small follow-ups still needed.