-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: create random and coins utils, add amount helper, dedupe add_coin #26940
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
test: create random and coins utils, add amount helper, dedupe add_coin #26940
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
43c7ff8
to
3cd4609
Compare
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.
utACK 3cd4609
I like the idea of having more intelligent "random" data that includes edge cases a significant portion of the time.
884a5f8
to
4e5bf23
Compare
Updated with feedback from @john-moffett and @fanquake (thanks!) |
bc24055
to
4c3d011
Compare
4c3d011
to
866917c
Compare
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.
No objection, but not seeing the benefit over a fuzz test either?
632a581
to
0196907
Compare
Rebased, squashed the money helper changes to one commit, and de-duplicated a shared |
0196907
to
d34bc34
Compare
concept ACK |
ACK d34bc34 The location of the random functions isn't a blocker for me. Show Signature
pinheadmz's public key is on keybase |
as many of the unit tests don't use this code
d34bc34
to
e6de5ad
Compare
Trivial rebase per I don't have a strong opinion on extracting the random utils to a helper. As most of the test files don't need them to be a part of their compilation unit, it might be beneficial to speed up builds a bit, and it provides clearer code organization. OTOH it's more to review so am happy also to leave them in |
ACK e6de5ad verified rebase change is minimal, also double checked that all Show Signature
pinheadmz's public key is on keybase |
I still don't understand why this change is being made. #26940 (comment) It claims to add coverage, without providing any evidence or even intuition. I am thinking that, absent that, it should be assumed that it will remove coverage. For example, sanitizers, such as the UB signed integer overflow sanitizer require large enough values to detect an overflow. If a majority of the values are now |
e6de5ad
to
25ea24d
Compare
Only 1% was 0 and 1% was 1. I liked that it would check edge cases often enough to provide feedback when running Anyway, that's gone now; removed the edge cases in the last push. It uses the money range rather than only uint32, while remaining in the same vein as the existing unit test rand helpers, and updated the PR description. |
to generate semi-random CAmounts up to MAX_MONEY rather than only uint32, and use it in the unit tests.
25ea24d
to
4275195
Compare
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.
ACK 4275195
ACK 4275195 Show Signature
pinheadmz's public key is on keybase |
ACK 4275195 |
What was the rationale for 81f5ade? test/util/random.h depends on test/util/setup_common because it's using |
@glozow Thanks for bringing it up! The rationale was in this thread: #26940 (comment). I noticed this as well, and that |
Addressed with #27425. |
…/setup_common to util/random 1cd45d4 test: move random.h include header from setup_common.h to cpp (Jon Atack) 1b246fd test: move remaining random test util code from setup_common to random (jonatack) Pull request description: and drop the `util/random` dependency on `util/setup_common`. This improves code separation and allows `util/setup_common` to call `util/random` functions without creating a circular dependency, thereby addressing bitcoin/bitcoin#26940 (comment) by glozow (thanks!) ACKs for top commit: MarcoFalke: lgtm ACK 1cd45d4 🌂 Tree-SHA512: 6ce63d9103ba9b04eebbd8ad02fe9aa79e356296533404034a1ae88e9b7ca0bc9a5c51fd754b71cf4e7b55b18bcd4d5474b2d588edee3851e3b3ce0e4d309a93
Move random test utilities from
setup_common
to a newrandom
file, as many tests don't use this code.Create a helper to generate semi-random CAmounts up to
MONEY_RANGE
rather than only uint32, and use the helper in the unit tests.De-duplicate a shared
add_coin
method by extracting it to acoins
test utility.