-
Notifications
You must be signed in to change notification settings - Fork 217
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
Strengthen tests for applyTx
and filterByAddress
.
#2867
Merged
jonathanknowles
merged 9 commits into
sevanspowell/adp-1092/apply-tx-testable
from
jonathanknowles/apply-tx-testable
Sep 3, 2021
Merged
Strengthen tests for applyTx
and filterByAddress
.
#2867
jonathanknowles
merged 9 commits into
sevanspowell/adp-1092/apply-tx-testable
from
jonathanknowles/apply-tx-testable
Sep 3, 2021
Conversation
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 allows the definition of a `CoArbitrary` instance for `Address`, which makes it possible for QuickCheck to generate arbitrary functions of type `Address -> t`, provided that type `t` has an `Arbitrary` instance.
Instead of using constant functions, we use arbitrary functions of type `Address -> Bool`.
…sts. Instead of using constant functions, we use arbitrary functions of type `Address -> Bool`.
It's perfectly valid for a transaction to have no outputs if all incoming value is consumed in some other way (either through the fee, or by burning tokens).
By conservatively reducing coverage expectations, this change reduces the overall run time from around 20 seconds to around 1 second.
jonathanknowles
changed the title
Strengthen tests for PR 2848
Strengthen tests for Sep 3, 2021
applyTx
and filterByAddress
.
jonathanknowles
commented
Sep 3, 2021
Comment on lines
1486
to
1488
cover 10 | ||
(lhs /= mempty && lhs `leq` rhs) | ||
"lhs /= mempty && lhs `leq` rhs" $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
cover 10 | |
(lhs /= mempty && lhs `leq` rhs) | |
"lhs /= mempty && lhs `leq` rhs" $ | |
cover 10 | |
(lhs /= mempty && lhs `leq` rhs && lhs /= rhs) | |
"lhs /= mempty && lhs `leq` rhs && lhs /= rhs" $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7cfc013.
What we really want here is to capture the notion of "strictly less than", but `leq` gives us "less than OR equal". We can't use `<`, as token maps are only partially ordered. So we have to use a combination of `leq` and `/=`. In response to review comment: https://github.com/input-output-hk/cardano-wallet/pull/2867/files#r701595441
jonathanknowles
force-pushed
the
jonathanknowles/apply-tx-testable
branch
from
September 3, 2021 05:42
ff9ef8a
to
7cfc013
Compare
sevanspowell
approved these changes
Sep 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Comments
This PR strengthens test coverage for PR 2848.
Issue Number
#2848
Changes
CoArbitrary
instance forAddress
, which enables us to generate arbitrary functions of typeAddress -> Bool
.Address -> Bool
functions to strengthen property tests that formerly relied on constant functions.