Skip to content

Update select_first_candidate to return InternalSelectionError::Empty#542

Merged
spacebear21 merged 1 commit intopayjoin:masterfrom
pseudoramdom:535-select_first_candidate-error
Mar 24, 2025
Merged

Update select_first_candidate to return InternalSelectionError::Empty#542
spacebear21 merged 1 commit intopayjoin:masterfrom
pseudoramdom:535-select_first_candidate-error

Conversation

@pseudoramdom
Copy link
Contributor

Fix #535

Update select_first_candidate to return InternalSelectionError::Empty when there are no candidates available for selection

@pseudoramdom
Copy link
Contributor Author

Hi there! I'm new here. I didn't see this covered in any existing tests, unless you'd like me to add one?

@DanGould
Copy link
Contributor

If you are up to adding a test that'd be a welcome addition

@coveralls
Copy link
Collaborator

coveralls commented Feb 18, 2025

Pull Request Test Coverage Report for Build 14044611583

Details

  • 32 of 33 (96.97%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.08%) to 81.424%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/receive/v1/mod.rs 32 33 96.97%
Files with Coverage Reduction New Missed Lines %
payjoin/src/receive/v1/mod.rs 1 95.27%
Totals Coverage Status
Change from base Build 14043365381: 0.08%
Covered Lines: 5089
Relevant Lines: 6250

💛 - Coveralls

@spacebear21
Copy link
Collaborator

Also, currently we actually check for an empty candidates set twice: the first one is here.

So this specific code change would be unreachable unless calling select_first_candidate directly, but it's a private function so I'm not sure that would a be a useful test. Perhaps we should remove the empty check in try_preserving_privacy and have it in avoid_uih and select_first_candidate only?

@DanGould
Copy link
Contributor

Yes please remove the empty check in try_... and leave it to avoid_uih and select_first_candidate only

@pseudoramdom pseudoramdom force-pushed the 535-select_first_candidate-error branch from c113c09 to 57d21c0 Compare March 1, 2025 06:28
@pseudoramdom
Copy link
Contributor Author

pseudoramdom commented Mar 1, 2025

I made the requested changes.
I was able to add a test but InternalSelectionError has an access level of pub(crate).
I had to resort to a string check . Let me know if that works.

@arminsabouri
Copy link
Collaborator

@pseudoramdom Do you mind squashing your commits into one?

Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

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

Just a small nit to keep the test signatures consistent

Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

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

The test looks good

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK 5066eef

Thanks @pseudoramdom and reviewers!

nit: looks like all previous commit messages got squashed into this one, it would be nice to clean up the commit message before merging this. We generally follow the commit guidelines established in https://cbea.ms/git-commit/

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

LGTM other than the commit messages. Please follow the seven rules from cbeams.

Thank you for your contribution 😎

@pseudoramdom pseudoramdom force-pushed the 535-select_first_candidate-error branch from 5066eef to 25d2af5 Compare March 5, 2025 02:27
@pseudoramdom
Copy link
Contributor Author

Thanks for the reviews folks! Fixed the commit message. Let me know if it looks good.

@pseudoramdom pseudoramdom requested a review from DanGould March 5, 2025 02:40
Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I think there is one sincere issue with the test, as discovered by @elnosh in another PR that I've repeated in my comments below.

I would like to understand the rationale of the change in the PR body, in complete sentences, rather than just a repeat of the title. The commit message is closer but I still need it to follow the seven rules, namely 2, 6, and 7, seem broken to me. Much more important than the what is the why, or rationale for the change.

@spacebear21 spacebear21 force-pushed the 535-select_first_candidate-error branch from 25d2af5 to b37bdce Compare March 24, 2025 16:53
@spacebear21 spacebear21 requested a review from DanGould March 24, 2025 16:59
Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

ACK b37bdce

@spacebear21 spacebear21 force-pushed the 535-select_first_candidate-error branch 2 times, most recently from f01e357 to 4c3c70e Compare March 24, 2025 19:51
Fixes payjoin#535. If there are no candidates, it should return
`InternalSelectionError::Empty` instead of `NotFound`. The check in
try_preserving_privacy was redundant so it is removed.
@spacebear21 spacebear21 force-pushed the 535-select_first_candidate-error branch from 4c3c70e to 96fe0c0 Compare March 24, 2025 19:52
@spacebear21
Copy link
Collaborator

Fixed the commit message and removed the redundant assert in the unit test.

@spacebear21 spacebear21 merged commit 02091df into payjoin:master Mar 24, 2025
7 checks passed
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.

select_first_candidate returns a InternalSelectionError::NotFound

6 participants