-
Notifications
You must be signed in to change notification settings - Fork 715
Property Tests: make_reward_set proptest and documentation #6640
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
base: develop
Are you sure you want to change the base?
Property Tests: make_reward_set proptest and documentation #6640
Conversation
* force duplication
|
|
||
| ## Reusing Strategies | ||
|
|
||
| Writing new input strategies may be the most tedious part of writing property tests, so it is worthwhile figuring out if the input you are looking for (or maybe a component of the input you're looking for) already has a strategy in the codebase. If you search for functions that return `impl Strategy<Value = ?>` in the codebase, you should find the set of functions that have already been written. |
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.
Should we have a convention of defining these all in some common place, for discoverability?
| 1. Executes once a PR has been approved. | ||
| 2. Discovers the set of new tests (this is probably easiest to achieve by running `cargo nextest list` on the source and target branches and then diffing the outputs). | ||
| 3. Executes only the new tests with the environment variable `PROPTEST_CASES` set to 2500. |
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.
Great idea!
| } | ||
| ``` | ||
|
|
||
| This technique allows to be sure that proptest generates a lot of cases where there are multiple entries for the same reward address. Unfortunately, this kind of thing tends to be more art than science, which means that PR authors and reviewers will need to be careful about the input strategies for property tests (this should also be aided by the CI task for PRs). This is one of the reasons that property tests can't totally supplant unit tests. However, a lot of the work of property tests helps with writing unit tests: many unit tests can be essentially fixed inputs to the property test. |
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.
I like the idea of using a common function which is called in the property test(s) and also called with some known edge cases in standard unit test style. Can we include that in the example here?
Co-authored-by: Brice <[email protected]>
This PR adds some docs for how we should handle property testing in this repo going forward, and it includes an example property test for the
make_reward_setfunction.