Skip to content

Commit f947086

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin#18855: tests: feature_backwards_compatibility.py test downgrade after upgrade
489ebfd tests: feature_backwards_compatibility.py test downgrade after upgrade (Andrew Chow) Pull request description: After upgrading the node, try to go back to the original version to make sure that using a newer node version does not prevent the wallet file from being downgraded again. ACKs for top commit: MarcoFalke: ACK 489ebfd Tree-SHA512: 86231de6514b3657912fd9d6621212166fd2b29b591fc97120092c548babcf1d6f50b5bd103b28cecde395a26809134f01c1a198725596c3626420de3fd1f017
1 parent 81f64f7 commit f947086

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

test/functional/feature_backwards_compatibility.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ def run_test(self):
334334
node_v17.createwallet(wallet_name="u1_v17")
335335
wallet = node_v17.get_wallet_rpc("u1_v17")
336336
address = wallet.getnewaddress()
337-
info = wallet.getaddressinfo(address)
337+
v17_info = wallet.getaddressinfo(address)
338338
# TODO enable back when HD wallets are created by default
339-
#hdkeypath = info["hdkeypath"]
340-
pubkey = info["pubkey"]
339+
#v17_hdkeypath = v17_info["hdkeypath"]
340+
v17_pubkey = v17_info["pubkey"]
341341

342342
# Copy the 0.17 wallet to the last Bitcoin Core version and open it:
343343
node_v17.unloadwallet("u1_v17")
@@ -349,9 +349,21 @@ def run_test(self):
349349
wallet = node_master.get_wallet_rpc("u1_v17")
350350
info = wallet.getaddressinfo(address)
351351
# TODO enable back when HD wallets are created by default
352-
#descriptor = "pkh([" + info["hdmasterfingerprint"] + hdkeypath[1:] + "]" + pubkey + ")"
352+
#descriptor = "pkh([" + info["hdmasterfingerprint"] + hdkeypath[1:] + "]" + v17_pubkey + ")"
353353
#assert_equal(info["desc"], descsum_create(descriptor))
354-
assert_equal(info["pubkey"], pubkey)
354+
assert_equal(info["pubkey"], v17_pubkey)
355+
356+
# Now copy that same wallet back to 0.17 to make sure no automatic upgrade breaks it
357+
node_master.unloadwallet("u1_v17")
358+
shutil.rmtree(os.path.join(node_v17_wallets_dir, "u1_v17"))
359+
shutil.copytree(
360+
os.path.join(node_master_wallets_dir, "u1_v17"),
361+
os.path.join(node_v17_wallets_dir, "u1_v17")
362+
)
363+
node_v17.loadwallet("u1_v17")
364+
wallet = node_v17.get_wallet_rpc("u1_v17")
365+
info = wallet.getaddressinfo(address)
366+
assert_equal(info, v17_info)
355367

356368
# Copy the 0.19 wallet to the last Bitcoin Core version and open it:
357369
shutil.copytree(
@@ -362,5 +374,16 @@ def run_test(self):
362374
wallet = node_master.get_wallet_rpc("w1_v19")
363375
assert wallet.getaddressinfo(address_18075)["solvable"]
364376

377+
# Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
378+
node_master.unloadwallet("w1_v19")
379+
shutil.rmtree(os.path.join(node_v19_wallets_dir, "w1_v19"))
380+
shutil.copytree(
381+
os.path.join(node_master_wallets_dir, "w1_v19"),
382+
os.path.join(node_v19_wallets_dir, "w1_v19")
383+
)
384+
node_v19.loadwallet("w1_v19")
385+
wallet = node_v19.get_wallet_rpc("w1_v19")
386+
assert wallet.getaddressinfo(address_18075)["solvable"]
387+
365388
if __name__ == '__main__':
366389
BackwardsCompatibilityTest().main()

0 commit comments

Comments
 (0)