diff options
author | Andrew Chow <github@achow101.com> | 2023-07-03 22:51:09 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-08-23 16:49:41 -0400 |
commit | afd9a673c458e97305da49a70a1ddbf60e651876 (patch) | |
tree | 9361439b9127405c3142a5e2b28cd6a0857246a6 /test/functional/wallet_backwards_compatibility.py | |
parent | bbf43c63b9472a79462e625a1f0592973c22b47c (diff) |
test: roundtrip wallet backwards compat downgrade
Test that old nodes don't mess up new wallets by loading a downgraded
wallet in master again.
Diffstat (limited to 'test/functional/wallet_backwards_compatibility.py')
-rwxr-xr-x | test/functional/wallet_backwards_compatibility.py | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/test/functional/wallet_backwards_compatibility.py b/test/functional/wallet_backwards_compatibility.py index 29c4f72607..4d6e6024c5 100755 --- a/test/functional/wallet_backwards_compatibility.py +++ b/test/functional/wallet_backwards_compatibility.py @@ -226,30 +226,41 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): if self.major_version_less_than(node, 22) and wallet_name == "w1" and self.options.descriptors: # Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below continue - node.loadwallet(wallet_name) - wallet = node.get_wallet_rpc(wallet_name) - info = wallet.getwalletinfo() - if wallet_name == "w1": - assert info['private_keys_enabled'] == True - assert info['keypoolsize'] > 0 - txs = wallet.listtransactions() - assert_equal(len(txs), 5) - assert_equal(txs[1]["txid"], tx1_id) - assert_equal(txs[2]["walletconflicts"], [tx1_id]) - assert_equal(txs[1]["replaced_by_txid"], tx2_id) - assert not txs[1]["abandoned"] - assert_equal(txs[1]["confirmations"], -1) - assert_equal(txs[2]["blockindex"], 1) - assert txs[3]["abandoned"] - assert_equal(txs[4]["walletconflicts"], [tx3_id]) - assert_equal(txs[3]["replaced_by_txid"], tx4_id) - assert not hasattr(txs[3], "blockindex") - elif wallet_name == "w2": - assert info['private_keys_enabled'] == False - assert info['keypoolsize'] == 0 - else: - assert info['private_keys_enabled'] == True - assert info['keypoolsize'] == 0 + # Also try to reopen on master after opening on old + for n in [node, node_master]: + n.loadwallet(wallet_name) + wallet = n.get_wallet_rpc(wallet_name) + info = wallet.getwalletinfo() + if wallet_name == "w1": + assert info['private_keys_enabled'] == True + assert info['keypoolsize'] > 0 + txs = wallet.listtransactions() + assert_equal(len(txs), 5) + assert_equal(txs[1]["txid"], tx1_id) + assert_equal(txs[2]["walletconflicts"], [tx1_id]) + assert_equal(txs[1]["replaced_by_txid"], tx2_id) + assert not txs[1]["abandoned"] + assert_equal(txs[1]["confirmations"], -1) + assert_equal(txs[2]["blockindex"], 1) + assert txs[3]["abandoned"] + assert_equal(txs[4]["walletconflicts"], [tx3_id]) + assert_equal(txs[3]["replaced_by_txid"], tx4_id) + assert not hasattr(txs[3], "blockindex") + elif wallet_name == "w2": + assert info['private_keys_enabled'] == False + assert info['keypoolsize'] == 0 + else: + assert info['private_keys_enabled'] == True + assert info['keypoolsize'] == 0 + + # Copy back to master + wallet.unloadwallet() + if n == node: + shutil.rmtree(node_master.wallets_path / wallet_name) + shutil.copytree( + n.wallets_path / wallet_name, + node_master.wallets_path / wallet_name, + ) # Check that descriptor wallets don't work on legacy only nodes if self.options.descriptors: |