1
1
#!/usr/bin/env python3
2
- # Copyright (c) 2018-2022 The Bitcoin Core developers
2
+ # Copyright (c) 2018-present The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Backwards compatibility functional test
@@ -33,7 +33,7 @@ def add_options(self, parser):
33
33
34
34
def set_test_params (self ):
35
35
self .setup_clean_chain = True
36
- self .num_nodes = 11
36
+ self .num_nodes = 10
37
37
# Add new version after each release:
38
38
self .extra_args = [
39
39
["-addresstype=bech32" , "-whitelist=noban@127.0.0.1" ], # Pre-release: use to mine blocks. noban for immediate tx relay
@@ -46,7 +46,6 @@ def set_test_params(self):
46
46
["-nowallet" , "-walletrbf=1" , "-addresstype=bech32" , "-whitelist=noban@127.0.0.1" ], # v0.20.1
47
47
["-nowallet" , "-walletrbf=1" , "-addresstype=bech32" , "-whitelist=noban@127.0.0.1" ], # v0.19.1
48
48
["-nowallet" , "-walletrbf=1" , "-addresstype=bech32" , "-whitelist=127.0.0.1" ], # v0.18.1
49
- ["-nowallet" , "-walletrbf=1" , "-addresstype=bech32" , "-whitelist=127.0.0.1" ], # v0.17.2
50
49
]
51
50
self .wallet_names = [self .default_wallet_name ]
52
51
@@ -66,7 +65,6 @@ def setup_nodes(self):
66
65
200100 ,
67
66
190100 ,
68
67
180100 ,
69
- 170200 ,
70
68
])
71
69
72
70
self .start_nodes ()
@@ -97,7 +95,7 @@ def test_v19_addmultisigaddress(self):
97
95
# See #18075
98
96
self .log .info ("Testing 0.19 addmultisigaddress case (#18075)" )
99
97
node_master = self .nodes [1 ]
100
- node_v19 = self .nodes [self .num_nodes - 4 ]
98
+ node_v19 = self .nodes [self .num_nodes - 3 ]
101
99
node_v19 .rpc .createwallet (wallet_name = "w1_v19" )
102
100
wallet = node_v19 .get_wallet_rpc ("w1_v19" )
103
101
info = wallet .getwalletinfo ()
@@ -131,17 +129,17 @@ def test_v19_addmultisigaddress(self):
131
129
def run_test (self ):
132
130
node_miner = self .nodes [0 ]
133
131
node_master = self .nodes [1 ]
134
- node_v21 = self .nodes [self .num_nodes - 5 ]
135
- node_v17 = self .nodes [self .num_nodes - 1 ]
132
+ node_v21 = self .nodes [self .num_nodes - 4 ]
133
+ node_v18 = self .nodes [self .num_nodes - 1 ]
136
134
137
135
legacy_nodes = self .nodes [2 :] # Nodes that support legacy wallets
138
- legacy_only_nodes = self .nodes [- 4 :] # Nodes that only support legacy wallets
139
- descriptors_nodes = self .nodes [2 :- 4 ] # Nodes that support descriptor wallets
136
+ legacy_only_nodes = self .nodes [- 3 :] # Nodes that only support legacy wallets
137
+ descriptors_nodes = self .nodes [2 :- 3 ] # Nodes that support descriptor wallets
140
138
141
139
self .generatetoaddress (node_miner , COINBASE_MATURITY + 1 , node_miner .getnewaddress ())
142
140
143
141
# Sanity check the test framework:
144
- res = node_v17 .getblockchaininfo ()
142
+ res = node_v18 .getblockchaininfo ()
145
143
assert_equal (res ['blocks' ], COINBASE_MATURITY + 1 )
146
144
147
145
self .log .info ("Test wallet backwards compatibility..." )
@@ -201,11 +199,7 @@ def run_test(self):
201
199
for wallet in os .listdir (node_master_wallets_dir ):
202
200
dest = node .wallets_path / wallet
203
201
source = node_master_wallets_dir / wallet
204
- if self .major_version_equals (node , 16 ):
205
- # 0.16 node expect the wallet to be in the wallet dir but as a plain file rather than in directories
206
- shutil .copyfile (source / "wallet.dat" , dest )
207
- else :
208
- shutil .copytree (source , dest )
202
+ shutil .copytree (source , dest )
209
203
210
204
self .test_v19_addmultisigaddress ()
211
205
@@ -215,9 +209,6 @@ def run_test(self):
215
209
for node in descriptors_nodes if self .options .descriptors else legacy_nodes :
216
210
self .log .info (f"- { node .version } " )
217
211
for wallet_name in ["w1" , "w2" , "w3" ]:
218
- if self .major_version_less_than (node , 18 ) and wallet_name == "w3" :
219
- # Blank wallets were introduced in v0.18.0. We test the loading error below.
220
- continue
221
212
if self .major_version_less_than (node , 22 ) and wallet_name == "w1" and self .options .descriptors :
222
213
# Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below
223
214
continue
@@ -261,30 +252,12 @@ def run_test(self):
261
252
if self .options .descriptors :
262
253
self .log .info ("Test descriptor wallet incompatibility on:" )
263
254
for node in legacy_only_nodes :
264
- # RPC loadwallet failure causes bitcoind to exit in <= 0.17, in addition to the RPC
265
- # call failure, so the following test won't work:
266
- # assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3')
267
- if self .major_version_less_than (node , 18 ):
268
- continue
269
255
self .log .info (f"- { node .version } " )
270
256
# Descriptor wallets appear to be corrupted wallets to old software
271
- assert self .major_version_at_least ( node , 18 ) and self . major_version_less_than (node , 21 )
257
+ assert self .major_version_less_than (node , 21 )
272
258
for wallet_name in ["w1" , "w2" , "w3" ]:
273
259
assert_raises_rpc_error (- 4 , "Wallet file verification failed: wallet.dat corrupt, salvage failed" , node .loadwallet , wallet_name )
274
260
275
- # Instead, we stop node and try to launch it with the wallet:
276
- self .stop_node (node_v17 .index )
277
- if self .options .descriptors :
278
- self .log .info ("Test descriptor wallet incompatibility with 0.17" )
279
- # Descriptor wallets appear to be corrupted wallets to old software
280
- node_v17 .assert_start_raises_init_error (["-wallet=w1" ], "Error: wallet.dat corrupt, salvage failed" )
281
- node_v17 .assert_start_raises_init_error (["-wallet=w2" ], "Error: wallet.dat corrupt, salvage failed" )
282
- node_v17 .assert_start_raises_init_error (["-wallet=w3" ], "Error: wallet.dat corrupt, salvage failed" )
283
- else :
284
- self .log .info ("Test blank wallet incompatibility with v17" )
285
- node_v17 .assert_start_raises_init_error (["-wallet=w3" ], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core" )
286
- self .start_node (node_v17 .index )
287
-
288
261
# When descriptors are enabled, w1 cannot be opened by 0.21 since it contains a taproot descriptor
289
262
if self .options .descriptors :
290
263
self .log .info ("Test that 0.21 cannot open wallet containing tr() descriptors" )
@@ -294,20 +267,13 @@ def run_test(self):
294
267
for node in descriptors_nodes if self .options .descriptors else legacy_nodes :
295
268
self .log .info (f"- { node .version } " )
296
269
wallet_name = f"up_{ node .version } "
297
- if self .major_version_less_than (node , 17 ):
298
- # createwallet is only available in 0.17+
299
- self .restart_node (node .index , extra_args = [f"-wallet={ wallet_name } " ])
300
- wallet_prev = node .get_wallet_rpc (wallet_name )
301
- address = wallet_prev .getnewaddress ('' , "bech32" )
302
- addr_info = wallet_prev .validateaddress (address )
270
+ if self .major_version_at_least (node , 21 ):
271
+ node .rpc .createwallet (wallet_name = wallet_name , descriptors = self .options .descriptors )
303
272
else :
304
- if self .major_version_at_least (node , 21 ):
305
- node .rpc .createwallet (wallet_name = wallet_name , descriptors = self .options .descriptors )
306
- else :
307
- node .rpc .createwallet (wallet_name = wallet_name )
308
- wallet_prev = node .get_wallet_rpc (wallet_name )
309
- address = wallet_prev .getnewaddress ('' , "bech32" )
310
- addr_info = wallet_prev .getaddressinfo (address )
273
+ node .rpc .createwallet (wallet_name = wallet_name )
274
+ wallet_prev = node .get_wallet_rpc (wallet_name )
275
+ address = wallet_prev .getnewaddress ('' , "bech32" )
276
+ addr_info = wallet_prev .getaddressinfo (address )
311
277
312
278
hdkeypath = addr_info ["hdkeypath" ].replace ("'" , "h" )
313
279
pubkey = addr_info ["pubkey" ]
@@ -317,10 +283,7 @@ def run_test(self):
317
283
wallet_prev .backupwallet (backup_path )
318
284
319
285
# Remove the wallet from old node
320
- if self .major_version_at_least (node , 17 ):
321
- wallet_prev .unloadwallet ()
322
- else :
323
- self .stop_node (node .index )
286
+ wallet_prev .unloadwallet ()
324
287
325
288
# Restore the wallet to master
326
289
load_res = node_master .restorewallet (wallet_name , backup_path )
@@ -362,28 +325,17 @@ def run_test(self):
362
325
363
326
wallet .unloadwallet ()
364
327
365
- # Check that no automatic upgrade broke the downgrading the wallet
366
- if self .major_version_less_than (node , 17 ):
367
- # loadwallet is only available in 0.17+
368
- shutil .copyfile (
369
- down_backup_path ,
370
- node .wallets_path / down_wallet_name
371
- )
372
- self .start_node (node .index , extra_args = [f"-wallet={ down_wallet_name } " ])
373
- wallet_res = node .get_wallet_rpc (down_wallet_name )
374
- info = wallet_res .validateaddress (address )
375
- assert_equal (info , addr_info )
376
- else :
377
- target_dir = node .wallets_path / down_wallet_name
378
- os .makedirs (target_dir , exist_ok = True )
379
- shutil .copyfile (
380
- down_backup_path ,
381
- target_dir / "wallet.dat"
382
- )
383
- node .loadwallet (down_wallet_name )
384
- wallet_res = node .get_wallet_rpc (down_wallet_name )
385
- info = wallet_res .getaddressinfo (address )
386
- assert_equal (info , addr_info )
328
+ # Check that no automatic upgrade broke downgrading the wallet
329
+ target_dir = node .wallets_path / down_wallet_name
330
+ os .makedirs (target_dir , exist_ok = True )
331
+ shutil .copyfile (
332
+ down_backup_path ,
333
+ target_dir / "wallet.dat"
334
+ )
335
+ node .loadwallet (down_wallet_name )
336
+ wallet_res = node .get_wallet_rpc (down_wallet_name )
337
+ info = wallet_res .getaddressinfo (address )
338
+ assert_equal (info , addr_info )
387
339
388
340
if __name__ == '__main__' :
389
341
BackwardsCompatibilityTest (__file__ ).main ()
0 commit comments