Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify coin selection balancing errors. #2993

Merged
merged 11 commits into from
Oct 28, 2021

Conversation

jonathanknowles
Copy link
Contributor

@jonathanknowles jonathanknowles commented Oct 27, 2021

Issue Number

ADP-1037

Summary

This PR finalizes the verification of selection balancing errors returned from CoinSelection.performSelection.

Details

This PR:

  • adds verification for errors of the following types:
    • EmptyUTxO.
    • BalanceInsufficientError.
    • InsufficientMinCoinValueError.
    • UnableToConstructChangeError.
  • adds helper functions to simplify verification functions.

@jonathanknowles jonathanknowles self-assigned this Oct 27, 2021
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-11 branch 2 times, most recently from ae4cb23 to 6bea6b8 Compare October 27, 2021 10:17
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/adp-1037/test-coin-selection-11 branch from 6bea6b8 to 98bdb29 Compare October 27, 2021 10:26
@jonathanknowles jonathanknowles changed the title Finalize verification of selection errors Verify selection balancing errors. Oct 27, 2021
@jonathanknowles jonathanknowles changed the title Verify selection balancing errors. Verify coin selection balancing errors. Oct 27, 2021
--
resultWithMinimalConstraints :: Either SelectionError Selection
resultWithMinimalConstraints =
runIdentity $ runExceptT $ performSelection cs' ps
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
runIdentity $ runExceptT $ performSelection cs' ps
-- By using our Identity instance of MonadRandom, we always generate the
-- same number. This means we'll always pick the same numbered entry in
-- our UTxO set. This isn't an issue however, because when we select
-- elements from the UTxO set, we remove them, so we won't always select
-- the same input.
runIdentity $ runExceptT $ performSelection cs' ps

What do you think of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an excellent suggestion: I'll add it in!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7e8aced.

We move main types to the top of the module, so that they appear right
next to the `performSelection` function.
@jonathanknowles
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 28, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit c0a1f86 into master Oct 28, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/adp-1037/test-coin-selection-11 branch October 28, 2021 07: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.

2 participants