Skip to content

Commit 6c9c12b

Browse files
committed
Update feature_backwards_compatibility for descriptor wallets
1 parent 9a4c631 commit 6c9c12b

File tree

2 files changed

+102
-82
lines changed

2 files changed

+102
-82
lines changed

test/functional/feature_backwards_compatibility.py

Lines changed: 101 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from test_framework.util import (
2929
assert_equal,
30+
assert_raises_rpc_error,
3031
)
3132

3233

@@ -82,7 +83,7 @@ def run_test(self):
8283

8384
# w1: regular wallet, created on master: update this test when default
8485
# wallets can no longer be opened by older versions.
85-
node_master.rpc.createwallet(wallet_name="w1")
86+
node_master.createwallet(wallet_name="w1")
8687
wallet = node_master.get_wallet_rpc("w1")
8788
info = wallet.getwalletinfo()
8889
assert info['private_keys_enabled']
@@ -127,7 +128,7 @@ def run_test(self):
127128
# w2: wallet with private keys disabled, created on master: update this
128129
# test when default wallets private keys disabled can no longer be
129130
# opened by older versions.
130-
node_master.rpc.createwallet(wallet_name="w2", disable_private_keys=True)
131+
node_master.createwallet(wallet_name="w2", disable_private_keys=True)
131132
wallet = node_master.get_wallet_rpc("w2")
132133
info = wallet.getwalletinfo()
133134
assert info['private_keys_enabled'] == False
@@ -149,7 +150,7 @@ def run_test(self):
149150

150151
# w3: blank wallet, created on master: update this
151152
# test when default blank wallets can no longer be opened by older versions.
152-
node_master.rpc.createwallet(wallet_name="w3", blank=True)
153+
node_master.createwallet(wallet_name="w3", blank=True)
153154
wallet = node_master.get_wallet_rpc("w3")
154155
info = wallet.getwalletinfo()
155156
assert info['private_keys_enabled']
@@ -215,67 +216,89 @@ def run_test(self):
215216
os.path.join(node_v19_wallets_dir, wallet)
216217
)
217218

218-
# Open the wallets in v0.19
219-
node_v19.loadwallet("w1")
220-
wallet = node_v19.get_wallet_rpc("w1")
221-
info = wallet.getwalletinfo()
222-
assert info['private_keys_enabled']
223-
assert info['keypoolsize'] > 0
224-
txs = wallet.listtransactions()
225-
assert_equal(len(txs), 5)
226-
assert_equal(txs[1]["txid"], tx1_id)
227-
assert_equal(txs[2]["walletconflicts"], [tx1_id])
228-
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
229-
assert not(txs[1]["abandoned"])
230-
assert_equal(txs[1]["confirmations"], -1)
231-
assert_equal(txs[2]["blockindex"], 1)
232-
assert txs[3]["abandoned"]
233-
assert_equal(txs[4]["walletconflicts"], [tx3_id])
234-
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
235-
assert not(hasattr(txs[3], "blockindex"))
236-
237-
node_v19.loadwallet("w2")
238-
wallet = node_v19.get_wallet_rpc("w2")
239-
info = wallet.getwalletinfo()
240-
assert info['private_keys_enabled'] == False
241-
assert info['keypoolsize'] == 0
242-
243-
node_v19.loadwallet("w3")
244-
wallet = node_v19.get_wallet_rpc("w3")
245-
info = wallet.getwalletinfo()
246-
assert info['private_keys_enabled']
247-
assert info['keypoolsize'] == 0
248-
249-
# Open the wallets in v0.18
250-
node_v18.loadwallet("w1")
251-
wallet = node_v18.get_wallet_rpc("w1")
252-
info = wallet.getwalletinfo()
253-
assert info['private_keys_enabled']
254-
assert info['keypoolsize'] > 0
255-
txs = wallet.listtransactions()
256-
assert_equal(len(txs), 5)
257-
assert_equal(txs[1]["txid"], tx1_id)
258-
assert_equal(txs[2]["walletconflicts"], [tx1_id])
259-
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
260-
assert not(txs[1]["abandoned"])
261-
assert_equal(txs[1]["confirmations"], -1)
262-
assert_equal(txs[2]["blockindex"], 1)
263-
assert txs[3]["abandoned"]
264-
assert_equal(txs[4]["walletconflicts"], [tx3_id])
265-
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
266-
assert not(hasattr(txs[3], "blockindex"))
267-
268-
node_v18.loadwallet("w2")
269-
wallet = node_v18.get_wallet_rpc("w2")
270-
info = wallet.getwalletinfo()
271-
assert info['private_keys_enabled'] == False
272-
assert info['keypoolsize'] == 0
273-
274-
node_v18.loadwallet("w3")
275-
wallet = node_v18.get_wallet_rpc("w3")
276-
info = wallet.getwalletinfo()
277-
assert info['private_keys_enabled']
278-
assert info['keypoolsize'] == 0
219+
if not self.options.descriptors:
220+
# Descriptor wallets break compatibility, only run this test for legacy wallet
221+
# Open the wallets in v0.19
222+
node_v19.loadwallet("w1")
223+
wallet = node_v19.get_wallet_rpc("w1")
224+
info = wallet.getwalletinfo()
225+
assert info['private_keys_enabled']
226+
assert info['keypoolsize'] > 0
227+
txs = wallet.listtransactions()
228+
assert_equal(len(txs), 5)
229+
assert_equal(txs[1]["txid"], tx1_id)
230+
assert_equal(txs[2]["walletconflicts"], [tx1_id])
231+
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
232+
assert not(txs[1]["abandoned"])
233+
assert_equal(txs[1]["confirmations"], -1)
234+
assert_equal(txs[2]["blockindex"], 1)
235+
assert txs[3]["abandoned"]
236+
assert_equal(txs[4]["walletconflicts"], [tx3_id])
237+
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
238+
assert not(hasattr(txs[3], "blockindex"))
239+
240+
node_v19.loadwallet("w2")
241+
wallet = node_v19.get_wallet_rpc("w2")
242+
info = wallet.getwalletinfo()
243+
assert info['private_keys_enabled'] == False
244+
assert info['keypoolsize'] == 0
245+
246+
node_v19.loadwallet("w3")
247+
wallet = node_v19.get_wallet_rpc("w3")
248+
info = wallet.getwalletinfo()
249+
assert info['private_keys_enabled']
250+
assert info['keypoolsize'] == 0
251+
252+
# Open the wallets in v0.18
253+
node_v18.loadwallet("w1")
254+
wallet = node_v18.get_wallet_rpc("w1")
255+
info = wallet.getwalletinfo()
256+
assert info['private_keys_enabled']
257+
assert info['keypoolsize'] > 0
258+
txs = wallet.listtransactions()
259+
assert_equal(len(txs), 5)
260+
assert_equal(txs[1]["txid"], tx1_id)
261+
assert_equal(txs[2]["walletconflicts"], [tx1_id])
262+
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
263+
assert not(txs[1]["abandoned"])
264+
assert_equal(txs[1]["confirmations"], -1)
265+
assert_equal(txs[2]["blockindex"], 1)
266+
assert txs[3]["abandoned"]
267+
assert_equal(txs[4]["walletconflicts"], [tx3_id])
268+
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
269+
assert not(hasattr(txs[3], "blockindex"))
270+
271+
node_v18.loadwallet("w2")
272+
wallet = node_v18.get_wallet_rpc("w2")
273+
info = wallet.getwalletinfo()
274+
assert info['private_keys_enabled'] == False
275+
assert info['keypoolsize'] == 0
276+
277+
node_v18.loadwallet("w3")
278+
wallet = node_v18.get_wallet_rpc("w3")
279+
info = wallet.getwalletinfo()
280+
assert info['private_keys_enabled']
281+
assert info['keypoolsize'] == 0
282+
283+
node_v17.loadwallet("w1")
284+
wallet = node_v17.get_wallet_rpc("w1")
285+
info = wallet.getwalletinfo()
286+
assert info['private_keys_enabled']
287+
assert info['keypoolsize'] > 0
288+
289+
node_v17.loadwallet("w2")
290+
wallet = node_v17.get_wallet_rpc("w2")
291+
info = wallet.getwalletinfo()
292+
assert info['private_keys_enabled'] == False
293+
assert info['keypoolsize'] == 0
294+
else:
295+
# Descriptor wallets appear to be corrupted wallets to old software
296+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w1")
297+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w2")
298+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v19.loadwallet, "w3")
299+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w1")
300+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w2")
301+
assert_raises_rpc_error(-4, "Wallet file verification failed: wallet.dat corrupt, salvage failed", node_v18.loadwallet, "w3")
279302

280303
# Open the wallets in v0.17
281304
node_v17.loadwallet("w1_v18")
@@ -284,39 +307,35 @@ def run_test(self):
284307
assert info['private_keys_enabled']
285308
assert info['keypoolsize'] > 0
286309

287-
node_v17.loadwallet("w1")
288-
wallet = node_v17.get_wallet_rpc("w1")
289-
info = wallet.getwalletinfo()
290-
assert info['private_keys_enabled']
291-
assert info['keypoolsize'] > 0
292-
293310
node_v17.loadwallet("w2_v18")
294311
wallet = node_v17.get_wallet_rpc("w2_v18")
295312
info = wallet.getwalletinfo()
296313
assert info['private_keys_enabled'] == False
297314
assert info['keypoolsize'] == 0
298315

299-
node_v17.loadwallet("w2")
300-
wallet = node_v17.get_wallet_rpc("w2")
301-
info = wallet.getwalletinfo()
302-
assert info['private_keys_enabled'] == False
303-
assert info['keypoolsize'] == 0
304-
305316
# RPC loadwallet failure causes bitcoind to exit, in addition to the RPC
306317
# call failure, so the following test won't work:
307318
# assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3_v18')
308319

309320
# Instead, we stop node and try to launch it with the wallet:
310321
self.stop_node(4)
311322
node_v17.assert_start_raises_init_error(["-wallet=w3_v18"], "Error: Error loading w3_v18: Wallet requires newer version of Bitcoin Core")
312-
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core")
323+
if self.options.descriptors:
324+
# Descriptor wallets appear to be corrupted wallets to old software
325+
node_v17.assert_start_raises_init_error(["-wallet=w1"], "Error: wallet.dat corrupt, salvage failed")
326+
node_v17.assert_start_raises_init_error(["-wallet=w2"], "Error: wallet.dat corrupt, salvage failed")
327+
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: wallet.dat corrupt, salvage failed")
328+
else:
329+
node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core")
313330
self.start_node(4)
314331

315-
# Open most recent wallet in v0.16 (no loadwallet RPC)
316-
self.restart_node(5, extra_args=["-wallet=w2"])
317-
wallet = node_v16.get_wallet_rpc("w2")
318-
info = wallet.getwalletinfo()
319-
assert info['keypoolsize'] == 1
332+
if not self.options.descriptors:
333+
# Descriptor wallets break compatibility, only run this test for legacy wallets
334+
# Open most recent wallet in v0.16 (no loadwallet RPC)
335+
self.restart_node(5, extra_args=["-wallet=w2"])
336+
wallet = node_v16.get_wallet_rpc("w2")
337+
info = wallet.getwalletinfo()
338+
assert info['keypoolsize'] == 1
320339

321340
# Create upgrade wallet in v0.16
322341
self.restart_node(-1, extra_args=["-wallet=u1_v16"])

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
'wallet_txn_doublespend.py',
198198
'wallet_txn_doublespend.py --descriptors',
199199
'feature_backwards_compatibility.py',
200+
'feature_backwards_compatibility.py --descriptors',
200201
'wallet_txn_clone.py --mineblock',
201202
'feature_notifications.py',
202203
'rpc_getblockfilter.py',

0 commit comments

Comments
 (0)