-
Notifications
You must be signed in to change notification settings - Fork 37.7k
tests: Update more tests to work with descriptor wallets #18788
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
Conversation
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, but I'd prefer if we got the current tests green first: #18800 |
fa6ca74
to
f98e7d6
Compare
f98e7d6
to
367cef4
Compare
367cef4
to
8266e43
Compare
Tests pass on macOS. The commit messages could be more descriptive than "Fix wallet_importprunedfunds", if only to aid the lazy reviewer in understanding what problems you're solving. |
Concept ACK |
8266e43
to
5cbebc0
Compare
I've updated the commit messages to be more descriptive. |
5cbebc0
to
f57cacf
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.
@@ -480,22 +490,39 @@ def test_spend_2of2(self): | |||
oldBalance = self.nodes[1].getbalance() | |||
inputs = [] | |||
outputs = {self.nodes[1].getnewaddress():1.1} | |||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs) |
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.
In e3dc503 it seems problematic to replace createrawtransaction
and fundrawtransaction
with PSBT methods in rpc_fundrawtransaction.py
.
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.
I think it's fine in some instances (like this one) because the funding code is the same and the goal is to check that the funding works.
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.
Do we still sufficiently test the createrawtransaction
and fundrawtransaction
RPC elsewhere? Those are rather ancient, with all cool kids using PSBT it might be a while before we see a regression.
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.
IMO we do. createrawtransaction
and fundrawtransaction
are still being tested in rpc_fundrawtransaction.py
as well is in other tests. Additionally, fundrawtransaction
basically only calls FundTransaction
after a bit of options parsing, and walletcreatefundedpsbt
calls this function as well, right after transaction creation.
Descriptor wallets output slightly different information in the wallet tool, so check that output when in descriptor wallet mode.
dumpprivkey and watchonly behavior don't work with descriptor wallets. Test for multisigs is modified to not rely on watchonly behavior for those multisigs. This has a side effect of removing listunspent, but that's not the target of this test, so that's fine.
…wallet.py sethdseed and importmulti are not available for descriptor wallets, so when doing descriptor wallet tests, use importdescriptors instead. Also changes some output to match what descriptor wallets will return.
…ypes.py addmultisigaddress is not available in descriptor wallets, so only run these when testing legacy wallets
The traditional multisig workflow doesn't work with descriptor wallets so make these tests legacy wallet only.
Some tests are legacy wallet only (and make legacy wallets) so they shouldn't be run when doing descriptor wallet tests.
…ptors Although legacy wallet is still the default, for future use, add a --legacy-wallet option to the test framework. Additional tests for descriptor wallets have been enabled with the --descriptors option. Tests that must be legacy wallet only are being started with --legacy-wallet. Even though this option does not currently do anything, this will be helpful in the future when descriptor wallets become the default.
a62855c
to
c7b7e0a
Compare
review ACK c7b7e0a 🎿 Show signature and timestampSignature:
Timestamp of file with hash |
ACK c7b7e0a |
…P2{PKH,SH,WPKH,WSH} scripts 905d672 test: use script_util helpers for creating P2W{PKH,SH} scripts (Sebastian Falbesoner) 285a65c test: use script_util helpers for creating P2SH scripts (Sebastian Falbesoner) b57b633 test: use script_util helpers for creating P2PKH scripts (Sebastian Falbesoner) 61b6a01 test: wallet util: fix multisig P2SH-P2WSH script creation (Sebastian Falbesoner) Pull request description: PR #18788 (commit 08067ae) introduced functions to generate output scripts for various types. This PR replaces all manual CScript creations in the P2PKH, P2SH, P2WPKH, P2WSH formats with those helpers in order to increase readability and maintainability over the functional test codebase. The first commit fixes a bug in the wallet_util helper module w.r.t. to P2SH-P2WSH script creation (the result is not used in any test so far, hence it can still be seen as refactoring). The following table shows a summary of the output script patterns tackled in this PR: | Type | master branch | PR branch | | ---------- | ------------- | ------------- | | P2PKH | `CScript([OP_DUP, OP_HASH160, hash160(key), OP_EQUALVERIFY, OP_CHECKSIG])` | `key_to_p2pkh_script(key)` | | | `CScript([OP_DUP, OP_HASH160, keyhash, OP_EQUALVERIFY, OP_CHECKSIG])` | `keyhash_to_p2pkh_script(keyhash)` | | P2SH | `CScript([OP_HASH160, hash160(script), OP_EQUAL])` | `script_to_p2sh_script(script)` | | P2WPKH | `CScript([OP_0, hash160(key)])` | `key_to_p2wpkh_script(key)` | | P2WSH | `CScript([OP_0, sha256(script)])` | `script_to_p2wsh_script(script)` | Note that the `key_to_...` helpers can't be used if an invalid key size (not 33 or 65 bytes) is passed, which is the case in some rare instances where the scripts still have to be created manually. Possible follow-up ideas: * further simplify by identifying P2SH-wrapped scripts and using `key_to_p2sh_p2wpkh_script()` and `script_to_p2sh_p2wsh_script()` helpers * introduce and use `key_to_p2pk_script()` helper for P2PK scripts ACKs for top commit: rajarshimaitra: tACK 905d672 LarryRuane: tACK 905d672 0xB10C: ACK 905d672 MarcoFalke: review ACK 905d672 🕹 Tree-SHA512: 7ccfe69699bc81168ac122b03536720013355c1b2fbb088355b616015318644c4d1cd27e20c4f56c89ad083ae609add4bc838cf6316794d0edb0ce9cf7fa0fd8
Summary: Removes the use of dumpprivkey so that descriptor wallets can pass on this. Also does a few descriptor wallet specific changes due to different `IsMine` semantics. PR description: > This PR updates more tests to have to the --descriptors switch in test_runner.py. Additionally a mutually exclusive --legacy-wallet option has been added to force legacy wallets. This does nothing currently but will be useful in the future when descriptor wallets are the default. For the tests that rely on legacy wallet behavior, this option is being set so that we don't forget in the future. Those tests are wallet_watchonly.py, wallet_import_with_label.py. Note: this is a PR with many commits, but the commits are mostly independant and can be merged as soon as they are reviewed. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [1/16] bitcoin/bitcoin@a357111 Test Plan: ``` test/functional/test_runner.py wallet_importprunedfunds ``` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10653
Summary: Import things into a separate watchonly wallet to work with descriptor wallets. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [2/16] bitcoin/bitcoin@dc81418 Test Plan: `test/functional/test_runner.py rpc_fundrawtransaction` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10654
Summary: Existing import* RPCs are disabled for descriptor wallets, so only do these tests for legacy wallets. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [3/16] bitcoin/bitcoin@553dbf9 Test Plan: `test/functional/test_runner.py wallet_listtransactions` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10655
Summary: Generate a privkey in the test framework instead of using dumpprivkey so that descriptor wallets work in this test. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [4/16] & [[bitcoin/bitcoin#20322 | core#20322]] (adds a `sync_all`) bitcoin/bitcoin@c2711e4 bitcoin/bitcoin@4444128 I also had to add a `key_to_p2pkh_cashaddr` function to get the address in the correct format. This has the added benefit of adding coverage for `cashaddr.encode[_full]` which was unused before this commit, as far as I can tell. Test Plan: `test/functional/test_runner.py wallet_listsinceblock` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10656
…lance.py Summary: Imports and watchonly behavior are legacy wallet only, so make them only run when the test is in legacy wallet mode. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [5/16] bitcoin/bitcoin@a42652e Test Plan: `test/functional/test_runner.py wallet_balance` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10657
Summary: This test works without any changes, for Bitcoin ABC. For Bitcoin Core, there were some changes in segwit related tests. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [6/15] bitcoin/bitcoin@0bd1860 Test Plan: `test/functional/test_runner.py rpc_signrawtransaction` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10659
…wallet.py Summary: sethdseed and importmulti are not available for descriptor wallets, so when doing descriptor wallet tests, use importdescriptors instead The keypool size when using descriptor wallets is unaffected for Bitcoin ABC, because our descriptors wallets have only the p2pkh keys. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [7/15] bitcoin/bitcoin@25bc5dc Test Plan: `test/functional/test_runner.py wallet_createwallet` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10669
Summary: The traditional multisig workflow doesn't work with descriptor wallets so make these tests legacy wallet only. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [9/15] bitcoin/bitcoin@47d3243 Notes for reviewers: - the sanity checks introduced in D2546 belong to the indented code, so I had to move them up (move & indent only) - the "RAW TX MULTISIG TESTS 2of2 tests" are indented only. The only changes are code formatting to keep lines below 80 characters. Test Plan: `test/functional/test_runner.py wallet_createwallet` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10671
…ypes.py Summary: addmultisigaddress is not available in descriptor wallets, so only run these when testing legacy wallets This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [8/15] bitcoin/bitcoin@59d3da5 Test Plan: `test/functional/test_runner.py wallet_address_types` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10664
Summary: Some tests are legacy wallet only (and make legacy wallets) so they shouldn't be run when doing descriptor wallet tests. This is a backport of [[bitcoin/bitcoin#18788 | core#18788]] [10/15] bitcoin/bitcoin@388053e Test Plan: `test/functional/test_runner.py tool_wallet` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10672
I went through all the tests and checked whether they passed with descriptor wallets. This partially informed some changes in #16528. Some tests needed changes to work with descriptor wallets. These were primarily due to import and watchonly behavior. There are some tests and test cases that only test legacy wallet behavior so those tests won't be run with descriptor wallets.
This PR updates more tests to have to the
--descriptors
switch intest_runner.py
. Additionally a mutually exclusive--legacy-wallet
option has been added to force legacy wallets. This does nothing currently but will be useful in the future when descriptor wallets are the default. For the tests that rely on legacy wallet behavior, this option is being set so that we don't forget in the future. Those tests arefeature_segwit.py
,wallet_watchonly.py
,wallet_implicitsegwit.py
,wallet_import_with_label.py
, andwallet_import_with_label.py
.If you invert the
--descriptors
/--legacy-wallet
default so that descriptor wallets are the default, all tests (besides the legacy wallet specific ones) will pass.