@@ -60,8 +60,10 @@ def run_test(self):
6060 wallet = lambda name : node .get_wallet_rpc (name )
6161
6262 def wallet_file (name ):
63+ if name == self .default_wallet_name :
64+ return wallet_dir (self .default_wallet_name , self .wallet_data_filename )
6365 if os .path .isdir (wallet_dir (name )):
64- return wallet_dir (name , self . wallet_data_filename )
66+ return wallet_dir (name , "wallet.dat" )
6567 return wallet_dir (name )
6668
6769 assert_equal (self .nodes [0 ].listwalletdir (), { 'wallets' : [{ 'name' : self .default_wallet_name }] })
@@ -77,13 +79,18 @@ def wallet_file(name):
7779
7880 # rename wallet.dat to make sure plain wallet file paths (as opposed to
7981 # directory paths) can be loaded
80- os .rename (wallet_dir (self .default_wallet_name , self .wallet_data_filename ), wallet_dir ("w8" ))
81-
8282 # create another dummy wallet for use in testing backups later
83- self .start_node (0 , ["-nowallet" , "-wallet=" + self .default_wallet_name ])
83+ self .start_node (0 , ["-nowallet" , "-wallet=empty" , "-wallet=plain" ])
84+ node .createwallet ("created" )
8485 self .stop_nodes ()
8586 empty_wallet = os .path .join (self .options .tmpdir , 'empty.dat' )
86- os .rename (wallet_dir (self .default_wallet_name , self .wallet_data_filename ), empty_wallet )
87+ os .rename (wallet_file ("empty" ), empty_wallet )
88+ shutil .rmtree (wallet_dir ("empty" ))
89+ empty_created_wallet = os .path .join (self .options .tmpdir , 'empty.created.dat' )
90+ os .rename (wallet_dir ("created" , self .wallet_data_filename ), empty_created_wallet )
91+ shutil .rmtree (wallet_dir ("created" ))
92+ os .rename (wallet_file ("plain" ), wallet_dir ("w8" ))
93+ shutil .rmtree (wallet_dir ("plain" ))
8794
8895 # restart node with a mix of wallet names:
8996 # w1, w2, w3 - to verify new wallets created when non-existing paths specified
@@ -151,7 +158,7 @@ def wallet_file(name):
151158 competing_wallet_dir = os .path .join (self .options .tmpdir , 'competing_walletdir' )
152159 os .mkdir (competing_wallet_dir )
153160 self .restart_node (0 , ['-walletdir=' + competing_wallet_dir ])
154- exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\"!"
161+ exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\S*\ "!"
155162 self .nodes [1 ].assert_start_raises_init_error (['-walletdir=' + competing_wallet_dir ], exp_stderr , match = ErrorMatch .PARTIAL_REGEX )
156163
157164 self .restart_node (0 , extra_args )
@@ -246,12 +253,13 @@ def wallet_file(name):
246253 assert_raises_rpc_error (- 18 , "Wallet file verification failed. Failed to load database path '{}'. Path does not exist." .format (path ), self .nodes [0 ].loadwallet , 'wallets' )
247254
248255 # Fail to load duplicate wallets
249- path = os .path .join (self .options .tmpdir , "node0" , "regtest" , "wallets" , "w1" , self . wallet_data_filename )
256+ path = os .path .join (self .options .tmpdir , "node0" , "regtest" , "wallets" , "w1" , "wallet.dat" )
250257 assert_raises_rpc_error (- 4 , "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded." .format (path ), self .nodes [0 ].loadwallet , wallet_names [0 ])
251258
252259 # Fail to load duplicate wallets by different ways (directory and filepath)
253- path = os .path .join (self .options .tmpdir , "node0" , "regtest" , "wallets" , self .wallet_data_filename )
254- assert_raises_rpc_error (- 4 , "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded." .format (path ), self .nodes [0 ].loadwallet , self .wallet_data_filename )
260+ if not self .options .descriptors :
261+ path = os .path .join (self .options .tmpdir , "node0" , "regtest" , "wallets" , "wallet.dat" )
262+ assert_raises_rpc_error (- 4 , "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded." .format (path ), self .nodes [0 ].loadwallet , 'wallet.dat' )
255263
256264 # Fail to load if one wallet is a copy of another
257265 assert_raises_rpc_error (- 4 , "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid" , self .nodes [0 ].loadwallet , 'w8_copy' )
@@ -334,9 +342,11 @@ def wallet_file(name):
334342 rpc = self .nodes [0 ].get_wallet_rpc (wallet_name )
335343 addr = rpc .getnewaddress ()
336344 backup = os .path .join (self .options .tmpdir , 'backup.dat' )
345+ if os .path .exists (backup ):
346+ os .unlink (backup )
337347 rpc .backupwallet (backup )
338348 self .nodes [0 ].unloadwallet (wallet_name )
339- shutil .copyfile (empty_wallet , wallet_file (wallet_name ))
349+ shutil .copyfile (empty_created_wallet if wallet_name == self . default_wallet_name else empty_wallet , wallet_file (wallet_name ))
340350 self .nodes [0 ].loadwallet (wallet_name )
341351 assert_equal (rpc .getaddressinfo (addr )['ismine' ], False )
342352 self .nodes [0 ].unloadwallet (wallet_name )
@@ -348,7 +358,10 @@ def wallet_file(name):
348358 self .start_node (1 )
349359 wallet = os .path .join (self .options .tmpdir , 'my_wallet' )
350360 self .nodes [0 ].createwallet (wallet )
351- assert_raises_rpc_error (- 4 , "Error initializing wallet database environment" , self .nodes [1 ].loadwallet , wallet )
361+ if self .options .descriptors :
362+ assert_raises_rpc_error (- 4 , "Unable to obtain an exclusive lock" , self .nodes [1 ].loadwallet , wallet )
363+ else :
364+ assert_raises_rpc_error (- 4 , "Error initializing wallet database environment" , self .nodes [1 ].loadwallet , wallet )
352365 self .nodes [0 ].unloadwallet (wallet )
353366 self .nodes [1 ].loadwallet (wallet )
354367
0 commit comments