Skip to content

Commit afd9a67

Browse files
committed
test: roundtrip wallet backwards compat downgrade
Test that old nodes don't mess up new wallets by loading a downgraded wallet in master again.
1 parent bbf43c6 commit afd9a67

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

test/functional/wallet_backwards_compatibility.py

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -226,30 +226,41 @@ def run_test(self):
226226
if self.major_version_less_than(node, 22) and wallet_name == "w1" and self.options.descriptors:
227227
# Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below
228228
continue
229-
node.loadwallet(wallet_name)
230-
wallet = node.get_wallet_rpc(wallet_name)
231-
info = wallet.getwalletinfo()
232-
if wallet_name == "w1":
233-
assert info['private_keys_enabled'] == True
234-
assert info['keypoolsize'] > 0
235-
txs = wallet.listtransactions()
236-
assert_equal(len(txs), 5)
237-
assert_equal(txs[1]["txid"], tx1_id)
238-
assert_equal(txs[2]["walletconflicts"], [tx1_id])
239-
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
240-
assert not txs[1]["abandoned"]
241-
assert_equal(txs[1]["confirmations"], -1)
242-
assert_equal(txs[2]["blockindex"], 1)
243-
assert txs[3]["abandoned"]
244-
assert_equal(txs[4]["walletconflicts"], [tx3_id])
245-
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
246-
assert not hasattr(txs[3], "blockindex")
247-
elif wallet_name == "w2":
248-
assert info['private_keys_enabled'] == False
249-
assert info['keypoolsize'] == 0
250-
else:
251-
assert info['private_keys_enabled'] == True
252-
assert info['keypoolsize'] == 0
229+
# Also try to reopen on master after opening on old
230+
for n in [node, node_master]:
231+
n.loadwallet(wallet_name)
232+
wallet = n.get_wallet_rpc(wallet_name)
233+
info = wallet.getwalletinfo()
234+
if wallet_name == "w1":
235+
assert info['private_keys_enabled'] == True
236+
assert info['keypoolsize'] > 0
237+
txs = wallet.listtransactions()
238+
assert_equal(len(txs), 5)
239+
assert_equal(txs[1]["txid"], tx1_id)
240+
assert_equal(txs[2]["walletconflicts"], [tx1_id])
241+
assert_equal(txs[1]["replaced_by_txid"], tx2_id)
242+
assert not txs[1]["abandoned"]
243+
assert_equal(txs[1]["confirmations"], -1)
244+
assert_equal(txs[2]["blockindex"], 1)
245+
assert txs[3]["abandoned"]
246+
assert_equal(txs[4]["walletconflicts"], [tx3_id])
247+
assert_equal(txs[3]["replaced_by_txid"], tx4_id)
248+
assert not hasattr(txs[3], "blockindex")
249+
elif wallet_name == "w2":
250+
assert info['private_keys_enabled'] == False
251+
assert info['keypoolsize'] == 0
252+
else:
253+
assert info['private_keys_enabled'] == True
254+
assert info['keypoolsize'] == 0
255+
256+
# Copy back to master
257+
wallet.unloadwallet()
258+
if n == node:
259+
shutil.rmtree(node_master.wallets_path / wallet_name)
260+
shutil.copytree(
261+
n.wallets_path / wallet_name,
262+
node_master.wallets_path / wallet_name,
263+
)
253264

254265
# Check that descriptor wallets don't work on legacy only nodes
255266
if self.options.descriptors:

0 commit comments

Comments
 (0)