rust-payjoin icon indicating copy to clipboard operation
rust-payjoin copied to clipboard

feat(receive): Add tests for InputPair constructors Closes #583

Open Johnosezele opened this issue 8 months ago • 2 comments

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 sequence argument.
  • Removed assertions checking non-existent fields on psbt::Input (e.g., script_sig, tap_control_block).
  • Renamed tap_leaf_scripts to the correct field tap_scripts in assertions.

Johnosezele avatar Apr 10 '25 16:04 Johnosezele

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.

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 Coverage Status
Change from base Build 14519980933: 1.0%
Covered Lines: 5723
Relevant Lines: 6912

💛 - Coveralls

coveralls avatar Apr 10 '25 17:04 coveralls

PR Updated:

  • Removed test_new_p2wpkh as suggested
  • Cleaned up test comments for better readability
  • All tests are passing
  • Added comprehensive test coverage:
    • test_privacy_based_input_selection: Tests UIH avoidance
    • test_fee_rate_based_selection: Validates fee rate enforcement
    • test_minimum_fee_requirements: Tests end-to-end fee handling

Ready for another review! 👍

Johnosezele avatar Apr 11 '25 04:04 Johnosezele

Closing this as it has been mainly addressed by #712 #753, with some small follow-ups still needed.

spacebear21 avatar Jun 09 '25 19:06 spacebear21