test: Remove legacy wallet tests from wallet_backwards_compatibility.py

This commit is contained in:
Ava Chow 2024-01-05 18:41:50 -05:00
parent aff80298d0
commit 446d480cb2
2 changed files with 20 additions and 30 deletions

View file

@ -278,7 +278,6 @@ BASE_SCRIPTS = [
'wallet_multisig_descriptor_psbt.py --descriptors', 'wallet_multisig_descriptor_psbt.py --descriptors',
'wallet_miniscript_decaying_multisig_descriptor_psbt.py --descriptors', 'wallet_miniscript_decaying_multisig_descriptor_psbt.py --descriptors',
'wallet_txn_doublespend.py --descriptors', 'wallet_txn_doublespend.py --descriptors',
'wallet_backwards_compatibility.py --legacy-wallet',
'wallet_backwards_compatibility.py --descriptors', 'wallet_backwards_compatibility.py --descriptors',
'wallet_txn_clone.py --mineblock', 'wallet_txn_clone.py --mineblock',
'feature_notifications.py', 'feature_notifications.py',

View file

@ -29,7 +29,7 @@ from test_framework.util import (
class BackwardsCompatibilityTest(BitcoinTestFramework): class BackwardsCompatibilityTest(BitcoinTestFramework):
def add_options(self, parser): def add_options(self, parser):
self.add_wallet_options(parser) self.add_wallet_options(parser, legacy=False)
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
@ -204,12 +204,12 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
self.test_v19_addmultisigaddress() self.test_v19_addmultisigaddress()
self.log.info("Test that a wallet made on master can be opened on:") 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 # This test only works on the nodes that support descriptor wallets
# In legacy wallets mode, run this test on the nodes that support legacy wallets # since we can no longer create legacy wallets.
for node in descriptors_nodes if self.options.descriptors else legacy_nodes: for node in descriptors_nodes:
self.log.info(f"- {node.version}") self.log.info(f"- {node.version}")
for wallet_name in ["w1", "w2", "w3"]: 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 # Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below
continue continue
# Also try to reopen on master after opening on old # 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 # Check that descriptor wallets don't work on legacy only nodes
if self.options.descriptors: self.log.info("Test descriptor wallet incompatibility on:")
self.log.info("Test descriptor wallet incompatibility on:") for node in legacy_only_nodes:
for node in legacy_only_nodes: self.log.info(f"- {node.version}")
self.log.info(f"- {node.version}") # Descriptor wallets appear to be corrupted wallets to old software
# Descriptor wallets appear to be corrupted wallets to old software assert self.major_version_less_than(node, 21)
assert self.major_version_less_than(node, 21) for wallet_name in ["w1", "w2", "w3"]:
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)
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 # 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")
self.log.info("Test that 0.21 cannot open wallet containing tr() descriptors") assert_raises_rpc_error(-1, "map::at", node_v21.loadwallet, "w1")
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:") 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}") self.log.info(f"- {node.version}")
wallet_name = f"up_{node.version}" wallet_name = f"up_{node.version}"
if self.major_version_at_least(node, 21): node.rpc.createwallet(wallet_name=wallet_name, descriptors=True)
node.rpc.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors)
else:
node.rpc.createwallet(wallet_name=wallet_name)
wallet_prev = node.get_wallet_rpc(wallet_name) wallet_prev = node.get_wallet_rpc(wallet_name)
address = wallet_prev.getnewaddress('', "bech32") address = wallet_prev.getnewaddress('', "bech32")
addr_info = wallet_prev.getaddressinfo(address) addr_info = wallet_prev.getaddressinfo(address)
@ -288,12 +283,8 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
# Restore the wallet to master # Restore the wallet to master
load_res = node_master.restorewallet(wallet_name, backup_path) 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 # There should be no warnings
if not self.options.descriptors: assert "warnings" not in load_res
# 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
wallet = node_master.get_wallet_rpc(wallet_name) wallet = node_master.get_wallet_rpc(wallet_name)
info = wallet.getaddressinfo(address) info = wallet.getaddressinfo(address)
@ -308,7 +299,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
# Check that taproot descriptors can be added to 0.21 wallets # 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 # This must be done after the backup is created so that 0.21 can still load
# the backup # 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") assert_raises_rpc_error(-12, "No bech32m addresses available", wallet.getnewaddress, address_type="bech32m")
xpubs = wallet.gethdkeys(active_only=True) xpubs = wallet.gethdkeys(active_only=True)
assert_equal(len(xpubs), 1) assert_equal(len(xpubs), 1)