mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Update feature_backwards_compatibility for descriptor wallets
This commit is contained in:
parent
9a4c631e1c
commit
6c9c12bf87
2 changed files with 97 additions and 77 deletions
|
@ -27,6 +27,7 @@ from test_framework.descriptors import descsum_create
|
||||||
|
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
|
assert_raises_rpc_error,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# w1: regular wallet, created on master: update this test when default
|
# w1: regular wallet, created on master: update this test when default
|
||||||
# wallets can no longer be opened by older versions.
|
# wallets can no longer be opened by older versions.
|
||||||
node_master.rpc.createwallet(wallet_name="w1")
|
node_master.createwallet(wallet_name="w1")
|
||||||
wallet = node_master.get_wallet_rpc("w1")
|
wallet = node_master.get_wallet_rpc("w1")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
|
@ -127,7 +128,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
# w2: wallet with private keys disabled, created on master: update this
|
# w2: wallet with private keys disabled, created on master: update this
|
||||||
# test when default wallets private keys disabled can no longer be
|
# test when default wallets private keys disabled can no longer be
|
||||||
# opened by older versions.
|
# opened by older versions.
|
||||||
node_master.rpc.createwallet(wallet_name="w2", disable_private_keys=True)
|
node_master.createwallet(wallet_name="w2", disable_private_keys=True)
|
||||||
wallet = node_master.get_wallet_rpc("w2")
|
wallet = node_master.get_wallet_rpc("w2")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled'] == False
|
assert info['private_keys_enabled'] == False
|
||||||
|
@ -149,7 +150,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# w3: blank wallet, created on master: update this
|
# w3: blank wallet, created on master: update this
|
||||||
# test when default blank wallets can no longer be opened by older versions.
|
# test when default blank wallets can no longer be opened by older versions.
|
||||||
node_master.rpc.createwallet(wallet_name="w3", blank=True)
|
node_master.createwallet(wallet_name="w3", blank=True)
|
||||||
wallet = node_master.get_wallet_rpc("w3")
|
wallet = node_master.get_wallet_rpc("w3")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
|
@ -215,67 +216,89 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
os.path.join(node_v19_wallets_dir, wallet)
|
os.path.join(node_v19_wallets_dir, wallet)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Open the wallets in v0.19
|
if not self.options.descriptors:
|
||||||
node_v19.loadwallet("w1")
|
# Descriptor wallets break compatibility, only run this test for legacy wallet
|
||||||
wallet = node_v19.get_wallet_rpc("w1")
|
# Open the wallets in v0.19
|
||||||
info = wallet.getwalletinfo()
|
node_v19.loadwallet("w1")
|
||||||
assert info['private_keys_enabled']
|
wallet = node_v19.get_wallet_rpc("w1")
|
||||||
assert info['keypoolsize'] > 0
|
info = wallet.getwalletinfo()
|
||||||
txs = wallet.listtransactions()
|
assert info['private_keys_enabled']
|
||||||
assert_equal(len(txs), 5)
|
assert info['keypoolsize'] > 0
|
||||||
assert_equal(txs[1]["txid"], tx1_id)
|
txs = wallet.listtransactions()
|
||||||
assert_equal(txs[2]["walletconflicts"], [tx1_id])
|
assert_equal(len(txs), 5)
|
||||||
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
|
assert_equal(txs[1]["txid"], tx1_id)
|
||||||
assert not(txs[1]["abandoned"])
|
assert_equal(txs[2]["walletconflicts"], [tx1_id])
|
||||||
assert_equal(txs[1]["confirmations"], -1)
|
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
|
||||||
assert_equal(txs[2]["blockindex"], 1)
|
assert not(txs[1]["abandoned"])
|
||||||
assert txs[3]["abandoned"]
|
assert_equal(txs[1]["confirmations"], -1)
|
||||||
assert_equal(txs[4]["walletconflicts"], [tx3_id])
|
assert_equal(txs[2]["blockindex"], 1)
|
||||||
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
|
assert txs[3]["abandoned"]
|
||||||
assert not(hasattr(txs[3], "blockindex"))
|
assert_equal(txs[4]["walletconflicts"], [tx3_id])
|
||||||
|
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
|
||||||
|
assert not(hasattr(txs[3], "blockindex"))
|
||||||
|
|
||||||
node_v19.loadwallet("w2")
|
node_v19.loadwallet("w2")
|
||||||
wallet = node_v19.get_wallet_rpc("w2")
|
wallet = node_v19.get_wallet_rpc("w2")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled'] == False
|
assert info['private_keys_enabled'] == False
|
||||||
assert info['keypoolsize'] == 0
|
assert info['keypoolsize'] == 0
|
||||||
|
|
||||||
node_v19.loadwallet("w3")
|
node_v19.loadwallet("w3")
|
||||||
wallet = node_v19.get_wallet_rpc("w3")
|
wallet = node_v19.get_wallet_rpc("w3")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
assert info['keypoolsize'] == 0
|
assert info['keypoolsize'] == 0
|
||||||
|
|
||||||
# Open the wallets in v0.18
|
# Open the wallets in v0.18
|
||||||
node_v18.loadwallet("w1")
|
node_v18.loadwallet("w1")
|
||||||
wallet = node_v18.get_wallet_rpc("w1")
|
wallet = node_v18.get_wallet_rpc("w1")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
assert info['keypoolsize'] > 0
|
assert info['keypoolsize'] > 0
|
||||||
txs = wallet.listtransactions()
|
txs = wallet.listtransactions()
|
||||||
assert_equal(len(txs), 5)
|
assert_equal(len(txs), 5)
|
||||||
assert_equal(txs[1]["txid"], tx1_id)
|
assert_equal(txs[1]["txid"], tx1_id)
|
||||||
assert_equal(txs[2]["walletconflicts"], [tx1_id])
|
assert_equal(txs[2]["walletconflicts"], [tx1_id])
|
||||||
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
|
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
|
||||||
assert not(txs[1]["abandoned"])
|
assert not(txs[1]["abandoned"])
|
||||||
assert_equal(txs[1]["confirmations"], -1)
|
assert_equal(txs[1]["confirmations"], -1)
|
||||||
assert_equal(txs[2]["blockindex"], 1)
|
assert_equal(txs[2]["blockindex"], 1)
|
||||||
assert txs[3]["abandoned"]
|
assert txs[3]["abandoned"]
|
||||||
assert_equal(txs[4]["walletconflicts"], [tx3_id])
|
assert_equal(txs[4]["walletconflicts"], [tx3_id])
|
||||||
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
|
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
|
||||||
assert not(hasattr(txs[3], "blockindex"))
|
assert not(hasattr(txs[3], "blockindex"))
|
||||||
|
|
||||||
node_v18.loadwallet("w2")
|
node_v18.loadwallet("w2")
|
||||||
wallet = node_v18.get_wallet_rpc("w2")
|
wallet = node_v18.get_wallet_rpc("w2")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled'] == False
|
assert info['private_keys_enabled'] == False
|
||||||
assert info['keypoolsize'] == 0
|
assert info['keypoolsize'] == 0
|
||||||
|
|
||||||
node_v18.loadwallet("w3")
|
node_v18.loadwallet("w3")
|
||||||
wallet = node_v18.get_wallet_rpc("w3")
|
wallet = node_v18.get_wallet_rpc("w3")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
assert info['keypoolsize'] == 0
|
assert info['keypoolsize'] == 0
|
||||||
|
|
||||||
|
node_v17.loadwallet("w1")
|
||||||
|
wallet = node_v17.get_wallet_rpc("w1")
|
||||||
|
info = wallet.getwalletinfo()
|
||||||
|
assert info['private_keys_enabled']
|
||||||
|
assert info['keypoolsize'] > 0
|
||||||
|
|
||||||
|
node_v17.loadwallet("w2")
|
||||||
|
wallet = node_v17.get_wallet_rpc("w2")
|
||||||
|
info = wallet.getwalletinfo()
|
||||||
|
assert info['private_keys_enabled'] == False
|
||||||
|
assert info['keypoolsize'] == 0
|
||||||
|
else:
|
||||||
|
# Descriptor wallets appear to be corrupted wallets to old software
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w1")
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w2")
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w3")
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w1")
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w2")
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w3")
|
||||||
|
|
||||||
# Open the wallets in v0.17
|
# Open the wallets in v0.17
|
||||||
node_v17.loadwallet("w1_v18")
|
node_v17.loadwallet("w1_v18")
|
||||||
|
@ -284,24 +307,12 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
assert info['private_keys_enabled']
|
assert info['private_keys_enabled']
|
||||||
assert info['keypoolsize'] > 0
|
assert info['keypoolsize'] > 0
|
||||||
|
|
||||||
node_v17.loadwallet("w1")
|
|
||||||
wallet = node_v17.get_wallet_rpc("w1")
|
|
||||||
info = wallet.getwalletinfo()
|
|
||||||
assert info['private_keys_enabled']
|
|
||||||
assert info['keypoolsize'] > 0
|
|
||||||
|
|
||||||
node_v17.loadwallet("w2_v18")
|
node_v17.loadwallet("w2_v18")
|
||||||
wallet = node_v17.get_wallet_rpc("w2_v18")
|
wallet = node_v17.get_wallet_rpc("w2_v18")
|
||||||
info = wallet.getwalletinfo()
|
info = wallet.getwalletinfo()
|
||||||
assert info['private_keys_enabled'] == False
|
assert info['private_keys_enabled'] == False
|
||||||
assert info['keypoolsize'] == 0
|
assert info['keypoolsize'] == 0
|
||||||
|
|
||||||
node_v17.loadwallet("w2")
|
|
||||||
wallet = node_v17.get_wallet_rpc("w2")
|
|
||||||
info = wallet.getwalletinfo()
|
|
||||||
assert info['private_keys_enabled'] == False
|
|
||||||
assert info['keypoolsize'] == 0
|
|
||||||
|
|
||||||
# RPC loadwallet failure causes bitcoind to exit, in addition to the RPC
|
# RPC loadwallet failure causes bitcoind to exit, in addition to the RPC
|
||||||
# call failure, so the following test won't work:
|
# call failure, so the following test won't work:
|
||||||
# assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3_v18')
|
# assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3_v18')
|
||||||
|
@ -309,14 +320,22 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||||
# Instead, we stop node and try to launch it with the wallet:
|
# Instead, we stop node and try to launch it with the wallet:
|
||||||
self.stop_node(4)
|
self.stop_node(4)
|
||||||
node_v17.assert_start_raises_init_error(["-wallet=w3_v18"], "Error: Error loading w3_v18: Wallet requires newer version of Bitcoin Core")
|
node_v17.assert_start_raises_init_error(["-wallet=w3_v18"], "Error: Error loading w3_v18: Wallet requires newer version of Bitcoin Core")
|
||||||
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core")
|
if self.options.descriptors:
|
||||||
|
# Descriptor wallets appear to be corrupted wallets to old software
|
||||||
|
node_v17.assert_start_raises_init_error(["-wallet=w1"], "Error: wallet.dat corrupt, salvage failed")
|
||||||
|
node_v17.assert_start_raises_init_error(["-wallet=w2"], "Error: wallet.dat corrupt, salvage failed")
|
||||||
|
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: wallet.dat corrupt, salvage failed")
|
||||||
|
else:
|
||||||
|
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core")
|
||||||
self.start_node(4)
|
self.start_node(4)
|
||||||
|
|
||||||
# Open most recent wallet in v0.16 (no loadwallet RPC)
|
if not self.options.descriptors:
|
||||||
self.restart_node(5, extra_args=["-wallet=w2"])
|
# Descriptor wallets break compatibility, only run this test for legacy wallets
|
||||||
wallet = node_v16.get_wallet_rpc("w2")
|
# Open most recent wallet in v0.16 (no loadwallet RPC)
|
||||||
info = wallet.getwalletinfo()
|
self.restart_node(5, extra_args=["-wallet=w2"])
|
||||||
assert info['keypoolsize'] == 1
|
wallet = node_v16.get_wallet_rpc("w2")
|
||||||
|
info = wallet.getwalletinfo()
|
||||||
|
assert info['keypoolsize'] == 1
|
||||||
|
|
||||||
# Create upgrade wallet in v0.16
|
# Create upgrade wallet in v0.16
|
||||||
self.restart_node(-1, extra_args=["-wallet=u1_v16"])
|
self.restart_node(-1, extra_args=["-wallet=u1_v16"])
|
||||||
|
|
|
@ -197,6 +197,7 @@ BASE_SCRIPTS = [
|
||||||
'wallet_txn_doublespend.py',
|
'wallet_txn_doublespend.py',
|
||||||
'wallet_txn_doublespend.py --descriptors',
|
'wallet_txn_doublespend.py --descriptors',
|
||||||
'feature_backwards_compatibility.py',
|
'feature_backwards_compatibility.py',
|
||||||
|
'feature_backwards_compatibility.py --descriptors',
|
||||||
'wallet_txn_clone.py --mineblock',
|
'wallet_txn_clone.py --mineblock',
|
||||||
'feature_notifications.py',
|
'feature_notifications.py',
|
||||||
'rpc_getblockfilter.py',
|
'rpc_getblockfilter.py',
|
||||||
|
|
Loading…
Add table
Reference in a new issue