Skip to content

Commit 951bca6

Browse files
committed
tests: feature_backwards_compatibility.py test 0.16 up/downgrade
1 parent 3a03a11 commit 951bca6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/functional/feature_backwards_compatibility.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,15 @@ def run_test(self):
322322
info = wallet.getwalletinfo()
323323
assert info['keypoolsize'] == 1
324324

325+
# Create upgrade wallet in v0.16
326+
self.stop_node(-1)
327+
self.start_node(-1, extra_args=["-wallet=u1_v16"])
328+
wallet = node_v16.get_wallet_rpc("u1_v16")
329+
v16_addr = wallet.getnewaddress('', "bech32")
330+
v16_info = wallet.validateaddress(v16_addr)
331+
v16_pubkey = v16_info['pubkey']
332+
self.stop_node(-1)
333+
325334
self.log.info("Test wallet upgrade path...")
326335
# u1: regular wallet, created with v0.17
327336
node_v17.rpc.createwallet(wallet_name="u1_v17")
@@ -331,6 +340,30 @@ def run_test(self):
331340
hdkeypath = v17_info["hdkeypath"]
332341
pubkey = v17_info["pubkey"]
333342

343+
# Copy the 0.16 wallet to the last Bitcoin Core version and open it:
344+
shutil.copyfile(
345+
os.path.join(node_v16_wallets_dir, "wallets/u1_v16"),
346+
os.path.join(node_master_wallets_dir, "u1_v16")
347+
)
348+
load_res = node_master.loadwallet("u1_v16")
349+
# Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
350+
assert_equal(load_res['warning'], '')
351+
wallet = node_master.get_wallet_rpc("u1_v16")
352+
info = wallet.getaddressinfo(v16_addr)
353+
descriptor = "wpkh([" + info["hdmasterfingerprint"] + hdkeypath[1:] + "]" + v16_pubkey + ")"
354+
assert_equal(info["desc"], descsum_create(descriptor))
355+
356+
# Now copy that same wallet back to 0.16 to make sure no automatic upgrade breaks it
357+
os.remove(os.path.join(node_v16_wallets_dir, "wallets/u1_v16"))
358+
shutil.copyfile(
359+
os.path.join(node_master_wallets_dir, "u1_v16"),
360+
os.path.join(node_v16_wallets_dir, "wallets/u1_v16")
361+
)
362+
self.start_node(-1, extra_args=["-wallet=u1_v16"])
363+
wallet = node_v16.get_wallet_rpc("u1_v16")
364+
info = wallet.validateaddress(v16_addr)
365+
assert_equal(info, v16_info)
366+
334367
# Copy the 0.17 wallet to the last Bitcoin Core version and open it:
335368
node_v17.unloadwallet("u1_v17")
336369
shutil.copytree(

0 commit comments

Comments
 (0)