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

Make assertion failures more descriptive in BalanceSpec. #2868

Merged
merged 1 commit into from
Sep 7, 2021

Conversation

jonathanknowles
Copy link
Contributor

@jonathanknowles jonathanknowles commented Sep 6, 2021

Issue Number

https://input-output.atlassian.net/browse/ADP-1113

Description

The BalanceSpec module contains several properties that make multiple internal assertions. When one of them fails, it's currently rather difficult to determine exactly which one has failed.

This PR adds an assertWith function, making it possible to provide a description with each assertion that is printed out when the assertion fails.

Example:

Assertion failed: onBalanceInsufficient: not $ balanceSufficient criteria
Assertion failed: onBalanceInsufficient: balanceAvailable == errorBalanceAvailable
Assertion failed: onBalanceInsufficient: balanceRequired == errorBalanceRequired

The `BalanceSpec` module contains several properties that make multiple
internal assertions. When one of them fails, it's rather difficult to
determine exactly which one has failed.

This commit adds an `assertWith` function, making it possible to provide
a description with each assertion that is printed out when the assertion
fails.
Copy link
Contributor

@sevanspowell sevanspowell left a comment

Choose a reason for hiding this comment

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

Ah! This is great. I remember having this issue when modifying CoinSelection code, you couldn't tell which assert went wrong and why easily.

@jonathanknowles
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 7, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit ef0af55 into master Sep 7, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/more-descriptive-assertions branch September 7, 2021 02:55
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