-
Notifications
You must be signed in to change notification settings - Fork 37.8k
test: get and decode tx with a single gettransaction
RPC call
#23287
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: get and decode tx with a single gettransaction
RPC call
#23287
Conversation
Tested ACK c045207. Ran the tests and reviewed the changes. |
Concept ACK I think mempool_packages.py (line 68 and 69) could be also included here, couldn't it? |
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.
Code review ACK c045207. Didn't check if same approach could be applied in other places.
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.
Concept ACK
This PR simplifies the code and RPC calls around getting a transaction and decoding it. I was able to successfully compile the PR on Ubuntu 20.04 without any errors. Nice catch, @theStack!
I think mempool_packages.py (line 68 and 69) could be also included here, couldn't it?
I think this is a valid suggestion. I tried to implement this myself while testing, and I was able to successfully do so in the following way:
# We need the wtxids to check P2P announcements
- fulltx = self.nodes[0].getrawtransaction(txid)
- witnesstx = self.nodes[0].decoderawtransaction(fulltx, True)
+ witnesstx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded']
witness_chain.append(witnesstx['hash'])
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.
tACK c045207
Great! I am gonna check if there are other places it could be applied |
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.
Rather than subsequently calling `gettransaction` and `decoderawtransaction` to get the decoded information for a specific tx-id, we can simply use the verbose version of `gettransaction`, which returns this in a 'decoded' key. I.e. node.decoderawtransaction(node.gettransaction(txid)['hex']) can be replaced by: node.gettransaction(txid=txid, verbose=True)['decoded']
c045207
to
130ee48
Compare
Thanks for all the reviews! @stratospher: Note that I intentionally didn't change anything in rpc_rawtransaction.py, as I think this test's focus are RPCs that cope with raw transactions (like decoderawtransaction). |
tested ACK 130ee48
@theStack, Thanks for clarifying. That makes total sense! |
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.
Tested ACK 130ee48 on Ubuntu 20.04.
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 130ee48
tACK 130ee48 |
@@ -65,8 +65,7 @@ def run_test(self): | |||
value = sent_value | |||
chain.append(txid) | |||
# We need the wtxids to check P2P announcements | |||
fulltx = self.nodes[0].getrawtransaction(txid) | |||
witnesstx = self.nodes[0].decoderawtransaction(fulltx, True) | |||
witnesstx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded'] |
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.
this is a wallet rpc and eventually the mempool tests shouldn't depend on bdb or sqlite
…ction` RPC call 130ee48 test: get and decode tx with a single `gettransaction` RPC call (Sebastian Falbesoner) Pull request description: Rather than subsequently calling `gettransaction` and `decoderawtransaction` to get the decoded information for a specific tx-id, we can simply use the verbose version of `gettransaction`, which returns this in a 'decoded' key. I.e. ``` node.decoderawtransaction(node.gettransaction(txid)['hex']) ``` can simply be replaced by: ``` node.gettransaction(txid=txid, verbose=True)['decoded'] ``` Rationale: shorter code, shorter test logs, less RPC calls. ACKs for top commit: stratospher: tested ACK 130ee48 amadeuszpawlik: tACK 130ee48 lsilva01: Tested ACK 130ee48 on Ubuntu 20.04. shaavan: ACK 130ee48 Tree-SHA512: cf0bd26e1e21b8022fb8062857906e0706f0ee32d3277f985c461e2519405afe445ab005f5f763fb268c7b4d6e48b2d47eda7af8621b3bce67cece8dfc9bc153
Rather than subsequently calling
gettransaction
anddecoderawtransaction
to get the decoded information for a specific tx-id, we can simply use the verbose version ofgettransaction
, which returns this in a 'decoded' key. I.e.can simply be replaced by:
Rationale: shorter code, shorter test logs, less RPC calls.