-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: add test for decoding PSBT with per-input preimage types #25625
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: add test for decoding PSBT with per-input preimage types #25625
Conversation
0095429
to
4dc573e
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
Concept ACK |
ACK 4dc573e |
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.
crACK 4dc573e
concept ACK, moving the PSBT utility functions into the testing framework proper is something I wanted regardless |
…ner) -BEGIN VERIFY SCRIPT- sed -i s/FromBinary/from_binary/g ./contrib/signet/miner -END VERIFY SCRIPT-
Can be easily reviewed with `--color-moved=dimmed-zebra`.
Can be easily reviewed with `--color-moved=dimmed-zebra`.
Also take use of the constants in the signet miner to get rid of magic numbers and increase readability and maintainability.
4dc573e
to
94dbcdc
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.
looks good aside from one question of mine
test/functional/rpc_psbt.py
Outdated
@@ -775,5 +788,37 @@ def test_psbt_input_keys(psbt_input, keys): | |||
self.nodes[0].sendrawtransaction(rawtx) | |||
self.generate(self.nodes[0], 1) | |||
|
|||
self.log.info("Test decoding PSBT with per-input preimage types") | |||
# note that the decodepsbt RPC doesn't check whether preimages and hashes match | |||
hash_ripemd160, preimage_ripemd160 = os.urandom(20), os.urandom(50) |
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 the first instance of urandom
in the test framework. Can we make it seed-determined instead, so that failures can be diagnosed easier?
If we don't expect failures due to randomness, we probably shouldn't do it at all then.
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.
Good point, I agree that seed-determined randomness is preferred here. Moved the random_bytes
helper (which uses random.getrandbits
) from the taproot test to the utils library and used that instead. Note that Python 3.9 offers random.randbytes()
, but unfortunately we have Python 3.6 as minimum requirement.
Can be easily reviewed with `--color-moved=dimmed-zebra`.
94dbcdc
to
71a751f
Compare
Force-pushed with feedback taken from instagibb's review comment, i.e. the random bytes are now generated with the |
ACK 71a751f |
This PR adds missing test coverage for the
decodepsbt
RPC in the case that a PSBT with on of the per-input preimage types (PSBT_IN_RIPEMD160
,PSBT_IN_SHA256
,PSBT_IN_HASH160
,PSBT_IN_HASH256
; see BIP 174) is passed. As preparation, the first four commits move the already existing helpers for (de)serialization of PSBTs and PSBTMaps from the signet miner to the test framework (in a new modulepsbt.py
), which should be quite useful for further tests to easily create PSBTs.