Skip to content

Commit 71c03ae

Browse files
committed
test: Refactor v19 addmultisigaddress test to be distinct
This specific test is distinct from the rest of the backwards compatibility tests as it is checking a specific failure.
1 parent 53f35d0 commit 71c03ae

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

test/functional/wallet_backwards_compatibility.py

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,47 @@ def major_version_at_least(self, node, major):
9090
node_major, _, _ = self.split_version(node)
9191
return node_major >= major
9292

93+
def test_v19_addmultisigaddress(self):
94+
if not self.is_bdb_compiled():
95+
return
96+
# Specific test for addmultisigaddress using v19
97+
# See #18075
98+
self.log.info("Testing 0.19 addmultisigaddress case (#18075)")
99+
node_master = self.nodes[1]
100+
node_v19 = self.nodes[self.num_nodes - 4]
101+
node_v19.rpc.createwallet(wallet_name="w1_v19")
102+
wallet = node_v19.get_wallet_rpc("w1_v19")
103+
info = wallet.getwalletinfo()
104+
assert info['private_keys_enabled']
105+
assert info['keypoolsize'] > 0
106+
# Use addmultisigaddress (see #18075)
107+
address_18075 = wallet.rpc.addmultisigaddress(1, ["0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52", "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073"], "", "legacy")["address"]
108+
assert wallet.getaddressinfo(address_18075)["solvable"]
109+
node_v19.unloadwallet("w1_v19")
110+
111+
# Copy the 0.19 wallet to the last Bitcoin Core version and open it:
112+
shutil.copytree(
113+
os.path.join(node_v19.wallets_path, "w1_v19"),
114+
os.path.join(node_master.wallets_path, "w1_v19")
115+
)
116+
node_master.loadwallet("w1_v19")
117+
wallet = node_master.get_wallet_rpc("w1_v19")
118+
assert wallet.getaddressinfo(address_18075)["solvable"]
119+
120+
# Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
121+
node_master.unloadwallet("w1_v19")
122+
shutil.rmtree(os.path.join(node_v19.wallets_path, "w1_v19"))
123+
shutil.copytree(
124+
os.path.join(node_master.wallets_path, "w1_v19"),
125+
os.path.join(node_v19.wallets_path, "w1_v19")
126+
)
127+
node_v19.loadwallet("w1_v19")
128+
wallet = node_v19.get_wallet_rpc("w1_v19")
129+
assert wallet.getaddressinfo(address_18075)["solvable"]
130+
93131
def run_test(self):
94132
node_miner = self.nodes[0]
95133
node_master = self.nodes[1]
96-
node_v19 = self.nodes[self.num_nodes - 4]
97134
node_v17 = self.nodes[self.num_nodes - 2]
98135
node_v16 = self.nodes[self.num_nodes - 1]
99136

@@ -133,17 +170,6 @@ def run_test(self):
133170
# Abandon transaction, but don't confirm
134171
node_master.abandontransaction(tx3_id)
135172

136-
# w1_v19: regular wallet, created with v0.19
137-
node_v19.rpc.createwallet(wallet_name="w1_v19")
138-
wallet = node_v19.get_wallet_rpc("w1_v19")
139-
info = wallet.getwalletinfo()
140-
assert info['private_keys_enabled']
141-
assert info['keypoolsize'] > 0
142-
# Use addmultisigaddress (see #18075)
143-
address_18075 = wallet.rpc.addmultisigaddress(1, ["0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52", "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073"], "", "legacy")["address"]
144-
assert wallet.getaddressinfo(address_18075)["solvable"]
145-
node_v19.unloadwallet("w1_v19")
146-
147173
# w2: wallet with private keys disabled, created on master: update this
148174
# test when default wallets private keys disabled can no longer be
149175
# opened by older versions.
@@ -163,7 +189,6 @@ def run_test(self):
163189

164190
# Unload wallets and copy to older nodes:
165191
node_master_wallets_dir = node_master.wallets_path
166-
node_v19_wallets_dir = node_v19.wallets_path
167192
node_v17_wallets_dir = node_v17.wallets_path
168193
node_v16_wallets_dir = node_v16.wallets_path
169194
node_master.unloadwallet("w1")
@@ -181,6 +206,8 @@ def run_test(self):
181206
else:
182207
shutil.copytree(source, dest)
183208

209+
self.test_v19_addmultisigaddress()
210+
184211
if not self.options.descriptors:
185212
# Descriptor wallets break compatibility, only run this test for legacy wallet
186213
# Load modern wallet with older nodes
@@ -322,25 +349,5 @@ def run_test(self):
322349
info = wallet.getaddressinfo(address)
323350
assert_equal(info, v17_info)
324351

325-
# Copy the 0.19 wallet to the last Bitcoin Core version and open it:
326-
shutil.copytree(
327-
os.path.join(node_v19_wallets_dir, "w1_v19"),
328-
os.path.join(node_master_wallets_dir, "w1_v19")
329-
)
330-
node_master.loadwallet("w1_v19")
331-
wallet = node_master.get_wallet_rpc("w1_v19")
332-
assert wallet.getaddressinfo(address_18075)["solvable"]
333-
334-
# Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
335-
node_master.unloadwallet("w1_v19")
336-
shutil.rmtree(os.path.join(node_v19_wallets_dir, "w1_v19"))
337-
shutil.copytree(
338-
os.path.join(node_master_wallets_dir, "w1_v19"),
339-
os.path.join(node_v19_wallets_dir, "w1_v19")
340-
)
341-
node_v19.loadwallet("w1_v19")
342-
wallet = node_v19.get_wallet_rpc("w1_v19")
343-
assert wallet.getaddressinfo(address_18075)["solvable"]
344-
345352
if __name__ == '__main__':
346353
BackwardsCompatibilityTest().main()

0 commit comments

Comments
 (0)