-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: refactor: support sending funds with outpoint result #28264
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: refactor: support sending funds with outpoint result #28264
Conversation
|
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. 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. |
1c21e51 to
63eacf6
Compare
|
Force-pushed with the feedback #28264 (comment) tackled and adapted the PR description accordingly. |
maflcko
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.
lgtm, two nits only
63eacf6 to
f1d685b
Compare
|
Rebased on master (tiny merge conflict due to #28232) and tackled the comments #28264 (comment) and #28264 (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.
Review ACK 7154542
The proposed refactor is a commendable improvement, streamlining test cases by leveraging the create_outpoints(...) function to consolidate calls to nodes.sendtoaddress() and find_vout_for_address() into a single invocation.
Suggestion: It might be beneficial to add documentation clarifying that the outputs argument should be an array of dictionaries following the format {address: amount_to_send}. This would enhance usability for future users, eliminating the need to inspect example invocations.
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: It might be beneficial to add documentation clarifying that the outputs argument should be an array of dictionaries following the format {address: amount_to_send}. This would enhance usability for future users, eliminating the need to inspect example invocations.
Good idea. Made the following (simple) change, I hope that's clear enough for users:
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 045fd2f5cb..70b3943478 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -699,7 +699,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
return blocks
def create_outpoints(self, node, *, outputs):
- """Send funds to a given list of address/amount targets using the bitcoind
+ """Send funds to a given list of `{address: amount}` targets using the bitcoind
wallet and return the corresponding outpoints as a list of dictionaries
`[{"txid": txid, "vout": vout1}, {"txid": txid, "vout": vout2}, ...]`.
The result can be used to specify inputs for RPCs like `createrawtransaction`,
|
Are you still working on this? |
I considered the PR ready since my latest force-push weeks ago (#28264 (comment)). However, will tackle the suggestion in #28264 (comment) though, I must have missed that last paragraph back then. |
f1d685b to
4bec09e
Compare
|
Rebased on master and tackled #28264 (comment). |
This commit introduces a helper `create_outpoints` to execute the `send` RPC and immediately return the target address outpoints as UTXO dictionary in the common format, making the tests more readable and avoiding unnecessary duplication.
4bec09e to
50d1ac1
Compare
|
Rebased on master again (due to conflict after #28609 has been merged). |
BrandonOdiwuor
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.
ACK 50d1ac1
maflcko
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.
ACK 50d1ac1 🖨
Show signature
Signature:
untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: ACK 50d1ac120716ab17f32b28513c0ac9940001a783 🖨
f/xrAIdGqM2CyeNbY9XT0oGt51+NcrDKS00Nej69S1xkQelpkubslZL0jaHX+RUdivnyh2xEo3bJJ/00I7AsDQ==
|
ACK 50d1ac1 |
This commit introduces a helper `create_outpoints` to execute the `send` RPC and immediately return the target address outpoints as UTXO dictionary in the common format. Github-Pull: bitcoin#28264 Partial-Rebased-From: 73a339a
In wallet-related functional tests we often want to send funds to an address and use the resulting (non-change) UTXO directly after as input for another transaction. Doing that is currently tedious, as it involves finding the index part of the outpoint manually by calling helpers like
find_vout_for_addressorfind_outputfirst. This results in two different txid/vout variables which then again have to be combined to a single dictionary{"txid": ..., "vout": ...}in order to be specified as input for RPCs likecreaterawtransactionorcreatepsbt. For example:This PR introduces a helper
create_outpointsto immediately return the outpoint asUTXO dictionary in the common format, making the tests more readable and avoiding unnecessary duplication:
Tests are switched to work with UTXO-objects rather than two individual txid/vout variables accordingly.
The
find_outputhelper is removed, as it seems generally a bad idea to search for an outpoint only based on the output value. If that's really ever needed in the future, it makes probably more sense to add it as an additional parameter tofind_vout_of_address. Note thatfind_outputsupported specifying a block-hash for where to look for the transaction (being passed on to thegetrawtransactionRPC). This seems to be unneeded, as txids are always unique and for the only test that used that parameter (rpc_psbt.py) there was no observed difference in run-time, so it was not reintroduced in the new helper.There are still some
find_vout_of_addresscalls remaining, used for detecting change outputs or for whenever the sending happens viasendrawtransactioninstead, so this PR tackles not all, but the most common case.