-
Notifications
You must be signed in to change notification settings - Fork 38.6k
[tests] Be more strict checking dust #6822
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
[tests] Be more strict checking dust #6822
Conversation
|
init.h: not worth to change IMO transaction.h: NACK, the comment on spendable output is important there. transactions_tests: ACK - I like such changes :-) |
Spendable is mentioned in L144 as well but I am happy to revert that if others agree. (Personally, I don't like magic numbers in comments) |
|
Don't get me wrong: the comment has to be changed. Maybe change the magic numbers to some math formula there? Something like: |
54d6df9 to
6351b1e
Compare
|
Addressed comment NACK by @paveljanik |
|
Can you also change 2730 (ie. magic number :-) into the above mentioned math. formula? |
f05296f to
03a7a44
Compare
|
utACK |
|
Is it just me or does this gratuitously conflict with another outstanding PR? When proposing a PR that isnt designed to replace another, but will make it fail CI (or otherwise not merge cleanly), can you either rebase your work on the other, or, at a minimum, mention it on the PR that it effects? |
|
@TheBlueMatt Please... it's hard enough for reviewers to keep up with all
proposed patches, you can't expect all contributors to do so as well.
It would be helpful if you mentioned what PR it is, and suggest how it
could be adapted to keep working.
|
|
@paveljanik 8d02c78 is for you but imo the tests should not replace or duplicate the documentation of the source code. @TheBlueMatt No worries, I have this already in mind and request a rebase on your PR once this is merged. |
|
@sipa I only bring it up because it was mentioned in the opening commit, only to not be tagged or worked around. I almost missed this. |
|
@TheBlueMatt If you want me to change the default in this PR, making yours a little bit cleaner, I am happy to do so. (Given that dropping the minRelayTxFee for the master branch is uncontroversial) |
|
This PR could define the dust limit variable in function of minTxRelayFee?
|
|
Naa, I can do it in #6722 if this is merged first... I just wanted to make sure it was tagged so that it's visible. You could include the commit that changed the min relay fee if you prefer, but if you want to do that probably wait until mempool limiting is merged anyway. On October 14, 2015 3:16:02 AM PDT, MarcoFalke [email protected] wrote:
|
|
@MarcoFalke I just wanted to prevent this issue (forgotten update of this test) in the future. The suggested change doesn't prevent it though. |
8d02c78 to
0cae2f5
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.
Nit: 546 is only accurate for pay-to-pubkey-hash outputs.
Edit: nevermind.. I guess that's covered by "a typical spendable txout ...".
|
Addressed nit by @paveljanik and force pushed. |
On the other hand having to update the test with fixed values was a good reminder that changing minTxFee also changes the dust threshold. At least I hadn't realized this at first. |
There are potentially a few different things to test:
Using magic numbers to ensure the calculation with reference values results in expected values can be useful to pin down issues with the calculation, and the alternative could be to temporarily overwrite the global CFeeRate minRelayTxFeeOriginal = minRelayTxFee;
minRelayTxFee = CFeeRate(1234);
// dust:
t.vout[0].nValue = 672 - 1;
BOOST_CHECK(!IsStandardTx(t, reason));
// not dust:
t.vout[0].nValue = 672;
BOOST_CHECK(IsStandardTx(t, reason));
minRelayTxFee = minRelayTxFeeOriginal;In fact, and as a side note, with |
0cae2f5 to
3f4b5ac
Compare
|
@dexX7 Let me know if the nits are fixed so I can squash the commit. |
src/test/transaction_tests.cpp
Outdated
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.
There is an unneeded space at the end.
Other than that, for this line you may consider using:
CAmount nDustThreshold = t.vout[0].GetDustThreshold(minRelayTxFee);It should have a similar effect. Since hardcoded values are used (such as 546), it might be good to specify the "default relay fee" in the comment one line above.
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.
GetDustThreshold is called via IsStandardTx so for the tests it's better not used here, imo. But thanks for the white space nit.
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.
Travis passes. Looks merge ready.
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.
GetDustThreshold is called via IsStandardTx so for the tests it's better not used here, imo.
Yeah, I guess it doesn't make much difference.
But thanks for the white space nit.
You're welcome! :)
3f4b5ac to
7ba5a4a
Compare
7ba5a4a to
2f9f050
Compare
|
Rebased. |
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.
As you define this constant, please also use it in init.cpp, for example when printing the option help or when parsing the option.
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.
@laanwj ☑️ done.
* Don't allow off-by-one or more * Make clear dust is coupled with minRelayTxFee * Check rounding for odd values
f526958 to
e20d924
Compare
Bitcoin 0.12 cleanup PRs 2 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6631 - bitcoin/bitcoin#6664 - Only the first commit (we already had the second through bitcoin/bitcoin#6825). - bitcoin/bitcoin#6669 - bitcoin/bitcoin#6887 - Only the non-QT parts. - bitcoin/bitcoin#6962 - bitcoin/bitcoin#6822 - Only first and third commits (we already had the second through an earlier PR). - bitcoin/bitcoin#7136 - Excludes Travis CI changes, and fixes to documents we don't have anymore. - bitcoin/bitcoin#7084 - bitcoin/bitcoin#7509 - bitcoin/bitcoin#7617 - bitcoin/bitcoin#7726 Part of #2074.
The dust test case is too fuzzy. This PR makes transaction_tests more strict when checking dust.