Merge #18855: tests: feature_backwards_compatibility.py test downgrade after upgrade

489ebfd7a16443d8263c048d55622da297df7c39 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 489ebfd7a16443d8263c048d55622da297df7c39

Tree-SHA512: 86231de6514b3657912fd9d6621212166fd2b29b591fc97120092c548babcf1d6f50b5bd103b28cecde395a26809134f01c1a198725596c3626420de3fd1f017
This commit is contained in:
MarcoFalke 2020-05-03 10:33:27 -04:00
commit 2e6a16b968
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -302,9 +302,9 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
node_v17.rpc.createwallet(wallet_name="u1_v17")
wallet = node_v17.get_wallet_rpc("u1_v17")
address = wallet.getnewaddress("bech32")
info = wallet.getaddressinfo(address)
hdkeypath = info["hdkeypath"]
pubkey = info["pubkey"]
v17_info = wallet.getaddressinfo(address)
hdkeypath = v17_info["hdkeypath"]
pubkey = v17_info["pubkey"]
# Copy the 0.17 wallet to the last Bitcoin Core version and open it:
node_v17.unloadwallet("u1_v17")
@ -318,6 +318,18 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
descriptor = "wpkh([" + info["hdmasterfingerprint"] + hdkeypath[1:] + "]" + pubkey + ")"
assert_equal(info["desc"], descsum_create(descriptor))
# Now copy that same wallet back to 0.17 to make sure no automatic upgrade breaks it
node_master.unloadwallet("u1_v17")
shutil.rmtree(os.path.join(node_v17_wallets_dir, "u1_v17"))
shutil.copytree(
os.path.join(node_master_wallets_dir, "u1_v17"),
os.path.join(node_v17_wallets_dir, "u1_v17")
)
node_v17.loadwallet("u1_v17")
wallet = node_v17.get_wallet_rpc("u1_v17")
info = wallet.getaddressinfo(address)
assert_equal(info, v17_info)
# Copy the 0.19 wallet to the last Bitcoin Core version and open it:
shutil.copytree(
os.path.join(node_v19_wallets_dir, "w1_v19"),
@ -327,5 +339,16 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
wallet = node_master.get_wallet_rpc("w1_v19")
assert wallet.getaddressinfo(address_18075)["solvable"]
# Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
node_master.unloadwallet("w1_v19")
shutil.rmtree(os.path.join(node_v19_wallets_dir, "w1_v19"))
shutil.copytree(
os.path.join(node_master_wallets_dir, "w1_v19"),
os.path.join(node_v19_wallets_dir, "w1_v19")
)
node_v19.loadwallet("w1_v19")
wallet = node_v19.get_wallet_rpc("w1_v19")
assert wallet.getaddressinfo(address_18075)["solvable"]
if __name__ == '__main__':
BackwardsCompatibilityTest().main()