-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: ensure output is large enough to pay for its fees #29283
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: ensure output is large enough to pay for its fees #29283
Conversation
Fixes a (rare) intermittency issue in wallet_import_rescan. Since we use `subtract_fee_from_outputs=[0]` in the `send` command, the output amount must at least be as large as the fee we're paying.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. 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. |
glozow
left a comment
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 3bfc5bd, didn't experience this issue but in theory a minimum of AMOUNT_DUST could be too low to pay the fees
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.
Can be replicated locally by changing line 273 to use the get_rand_amount() floor.
variant.initial_amount = Decimal(str(round(AMOUNT_DUST, 8))) * 2
furszy
left a comment
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 3bfc5bd
| )) | ||
| variant.key = self.nodes[1].dumpprivkey(variant.address["address"]) | ||
| variant.initial_amount = get_rand_amount() * 2 | ||
| # Ensure output is large enough to pay for fees: conservatively assuming txsize of |
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.
Maybe:
| # Ensure output is large enough to pay for fees: conservatively assuming txsize of | |
| # Ensure output is large enough to pay for its fees. Following transactions will contain one input and one unspendable output. Conservatively assuming... |
Also, just as an extra note (no need to do it): could calculate the floor in a more dynamic manner if you want. The input type is known here, and the future tx is always fixed to be a 1 input, 1 bech32 output tx.
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.
Thx, will consider if I need to retouch!
|
ACK 3bfc5bd |
| # Ensure output is large enough to pay for fees: conservatively assuming txsize of | ||
| # 500 vbytes and feerate of 20 sats/vbytes | ||
| variant.initial_amount = max(get_rand_amount(), (500 * 20 / COIN) + AMOUNT_DUST) | ||
| variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount) |
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.
test 2024-01-27T00:59:20.405000Z TestFramework (ERROR): JSONRPC error
Traceback (most recent call last):
File "/ci_container_base/ci/scratch/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 131, in main
self.run_test()
File "/ci_container_base/ci/scratch/build/bitcoin-i686-pc-linux-gnu/test/functional/wallet_import_rescan.py", line 277, in run_test
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)
File "/ci_container_base/ci/scratch/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/coverage.py", line 50, in __call__
return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
File "/ci_container_base/ci/scratch/build/bitcoin-i686-pc-linux-gnu/test/functional/test_framework/authproxy.py", line 129, in __call__
raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Invalid amount (-3)
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.
Does it need to be cast to an int maybe?
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.
Thanks for reporting this @maflcko, need to round the minimum value to 8 decimals to fix this. Opening a pull now.
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.
26ad2ae test: fix wallet_import_rescan unrounded minimum amount (stickies-v) Pull request description: Addresses #29283 (comment). Fixes a `JSONRPCException: Invalid amount (-3)` exception by ensuring the amount sent to `sendtoaddress` is rounded to 8 decimals. See https://cirrus-ci.com/task/5562947183837184?logs=ci#L2559 Note: since `round` can also round down, `min_amount` is not _exactly_ guaranteed, but this is not a problem for the current usage. I've added a docstring to highlight this. ACKs for top commit: sr-gi: ACK [26ad2ae](26ad2ae) Tree-SHA512: 82ce16447f30535f17fa73336f7e4f74639e33215a228294b9b8005b8050a760b90a3726de279cce98c7e439f09104172b74072be3a300dbd461bf0c3f54b954
Fixes a (rare) intermittency issue in wallet_import_rescan.py
Since we use
subtract_fee_from_outputs=[0]in thesendcommand, the output amount must at least be as large as the fee we're paying.Example in CI: https://api.cirrus-ci.com/v1/task/6107972259020800/logs/ci.log
Can be reproduced locally by forcing usage of the lowest possible value produced by
get_rand_amount()(thanks furszy):git diff on 5f3a057