From 446d480cb22c6645ac75981dad180b579ef3283d Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Fri, 5 Jan 2024 18:41:50 -0500 Subject: [PATCH] test: Remove legacy wallet tests from wallet_backwards_compatibility.py --- test/functional/test_runner.py | 1 - .../wallet_backwards_compatibility.py | 49 ++++++++----------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 3df1644622c..a8e3d0c6b1b 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -278,7 +278,6 @@ BASE_SCRIPTS = [ 'wallet_multisig_descriptor_psbt.py --descriptors', 'wallet_miniscript_decaying_multisig_descriptor_psbt.py --descriptors', 'wallet_txn_doublespend.py --descriptors', - 'wallet_backwards_compatibility.py --legacy-wallet', 'wallet_backwards_compatibility.py --descriptors', 'wallet_txn_clone.py --mineblock', 'feature_notifications.py', diff --git a/test/functional/wallet_backwards_compatibility.py b/test/functional/wallet_backwards_compatibility.py index 003fb32cb98..d5bed2a204a 100755 --- a/test/functional/wallet_backwards_compatibility.py +++ b/test/functional/wallet_backwards_compatibility.py @@ -29,7 +29,7 @@ from test_framework.util import ( class BackwardsCompatibilityTest(BitcoinTestFramework): def add_options(self, parser): - self.add_wallet_options(parser) + self.add_wallet_options(parser, legacy=False) def set_test_params(self): self.setup_clean_chain = True @@ -204,12 +204,12 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): self.test_v19_addmultisigaddress() self.log.info("Test that a wallet made on master can be opened on:") - # In descriptors wallet mode, run this test on the nodes that support descriptor wallets - # In legacy wallets mode, run this test on the nodes that support legacy wallets - for node in descriptors_nodes if self.options.descriptors else legacy_nodes: + # This test only works on the nodes that support descriptor wallets + # since we can no longer create legacy wallets. + for node in descriptors_nodes: self.log.info(f"- {node.version}") for wallet_name in ["w1", "w2", "w3"]: - if self.major_version_less_than(node, 22) and wallet_name == "w1" and self.options.descriptors: + if self.major_version_less_than(node, 22) and wallet_name == "w1": # Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below continue # Also try to reopen on master after opening on old @@ -249,28 +249,23 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): ) # Check that descriptor wallets don't work on legacy only nodes - if self.options.descriptors: - self.log.info("Test descriptor wallet incompatibility on:") - for node in legacy_only_nodes: - self.log.info(f"- {node.version}") - # Descriptor wallets appear to be corrupted wallets to old software - assert self.major_version_less_than(node, 21) - for wallet_name in ["w1", "w2", "w3"]: - assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node.loadwallet, wallet_name) + self.log.info("Test descriptor wallet incompatibility on:") + for node in legacy_only_nodes: + self.log.info(f"- {node.version}") + # Descriptor wallets appear to be corrupted wallets to old software + assert self.major_version_less_than(node, 21) + for wallet_name in ["w1", "w2", "w3"]: + assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node.loadwallet, wallet_name) - # When descriptors are enabled, w1 cannot be opened by 0.21 since it contains a taproot descriptor - if self.options.descriptors: - self.log.info("Test that 0.21 cannot open wallet containing tr() descriptors") - assert_raises_rpc_error(-1, "map::at", node_v21.loadwallet, "w1") + # w1 cannot be opened by 0.21 since it contains a taproot descriptor + self.log.info("Test that 0.21 cannot open wallet containing tr() descriptors") + assert_raises_rpc_error(-1, "map::at", node_v21.loadwallet, "w1") self.log.info("Test that a wallet can upgrade to and downgrade from master, from:") - for node in descriptors_nodes if self.options.descriptors else legacy_nodes: + for node in descriptors_nodes: self.log.info(f"- {node.version}") wallet_name = f"up_{node.version}" - if self.major_version_at_least(node, 21): - node.rpc.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors) - else: - node.rpc.createwallet(wallet_name=wallet_name) + node.rpc.createwallet(wallet_name=wallet_name, descriptors=True) wallet_prev = node.get_wallet_rpc(wallet_name) address = wallet_prev.getnewaddress('', "bech32") addr_info = wallet_prev.getaddressinfo(address) @@ -288,12 +283,8 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): # Restore the wallet to master load_res = node_master.restorewallet(wallet_name, backup_path) - # Make sure this wallet opens with only the migration warning. See https://github.com/bitcoin/bitcoin/pull/19054 - if not self.options.descriptors: - # Legacy wallets will have only a deprecation warning - assert_equal(load_res["warnings"], ["Wallet loaded successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. Legacy wallets can be migrated to a descriptor wallet with migratewallet."]) - else: - assert "warnings" not in load_res + # There should be no warnings + assert "warnings" not in load_res wallet = node_master.get_wallet_rpc(wallet_name) info = wallet.getaddressinfo(address) @@ -308,7 +299,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): # Check that taproot descriptors can be added to 0.21 wallets # This must be done after the backup is created so that 0.21 can still load # the backup - if self.options.descriptors and self.major_version_equals(node, 21): + if self.major_version_equals(node, 21): assert_raises_rpc_error(-12, "No bech32m addresses available", wallet.getnewaddress, address_type="bech32m") xpubs = wallet.gethdkeys(active_only=True) assert_equal(len(xpubs), 1)