Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2968: Unify success post-condition for `performSelection`. r=jonathanknowles a=jonathanknowles ## Issue Number ADP-1037 ## Summary This PR: - adds coverage to verify that selections returned by `performSelection` respect the `SelectionLimit` returned by `computeSelectionLimit`. - unifies the various post conditions for `performSelection` into a single post condition. ## Details This PR follows the [pattern](https://github.com/input-output-hk/cardano-wallet/blob/24cd824fa3bb17a913e17756cb94a59b788de7c4/lib/core/src/Cardano/Wallet/Primitive/Migration/Selection.hs#L648) used in the [`Migration.Selection`](https://github.com/input-output-hk/cardano-wallet/blob/24cd824fa3bb17a913e17756cb94a59b788de7c4/lib/core/src/Cardano/Wallet/Primitive/Migration/Selection.hs) module: - all post conditions are unified into a single post condition: ```>>> verifySelection cs ps s == SelectionCorrect``` - the comment for `performSelection` refers to this single post condition. This pattern has the following advantages: - we can avoid a violation of the [DRY principle](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself): we only need to state the properties we expect of a `Selection` **in a single place**. (The alternative is to repeat these properties in both the comment for `performSelection` and within `CoinSelectionSpec` itself.) - every failure condition has a record type that includes a detailed description of why the failure has occurred. - every failure condition is automatically pretty-printed by the test suite. ## Example Test Failure ![example-test-failure](https://user-images.githubusercontent.com/206319/136889194-c2f7b16e-b709-4d95-84c1-84ce26fe2aea.png) Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
- Loading branch information
Showing
2 changed files
with
181 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters