@@ -220,11 +220,6 @@ def wallet(name): return node.get_wallet_rpc(name)
220220 assert_raises_rpc_error (- 4 , "Wallet file verification failed: Invalid -wallet path 'w8_symlink'" ,
221221 self .nodes [0 ].loadwallet , 'w8_symlink' )
222222
223- # Fail to load if a directory is specified that doesn't contain a wallet
224- os .mkdir (wallet_dir ('empty_wallet_dir' ))
225- assert_raises_rpc_error (- 18 , "Directory empty_wallet_dir does not contain a wallet.dat file" ,
226- self .nodes [0 ].loadwallet , 'empty_wallet_dir' )
227-
228223 self .log .info ("Test dynamic wallet creation." )
229224
230225 # Fail to create a wallet if it already exists.
@@ -249,66 +244,6 @@ def wallet(name): return node.get_wallet_rpc(name)
249244
250245 assert new_wallet_name in self .nodes [0 ].listwallets ()
251246
252- self .log .info ("Test dynamic wallet unloading" )
253-
254- # Test `unloadwallet` errors
255- assert_raises_rpc_error (- 1 , "JSON value is not a string as expected" ,
256- self .nodes [0 ].unloadwallet )
257- assert_raises_rpc_error (- 18 , "Requested wallet does not exist or is not loaded" ,
258- self .nodes [0 ].unloadwallet , "dummy" )
259- assert_raises_rpc_error (- 18 , "Requested wallet does not exist or is not loaded" ,
260- node .get_wallet_rpc ("dummy" ).unloadwallet )
261- assert_raises_rpc_error (- 8 , "Cannot unload the requested wallet" ,
262- w1 .unloadwallet , "w2" ),
263-
264- # Successfully unload the specified wallet name
265- self .nodes [0 ].unloadwallet ("w1" )
266- assert 'w1' not in self .nodes [0 ].listwallets ()
267-
268- # Successfully unload the wallet referenced by the request endpoint
269- w2 .unloadwallet ()
270- assert 'w2' not in self .nodes [0 ].listwallets ()
271-
272- # Successfully unload all wallets
273- for wallet_name in self .nodes [0 ].listwallets ():
274- self .nodes [0 ].unloadwallet (wallet_name )
275- assert_equal (self .nodes [0 ].listwallets (), [])
276- assert_raises_rpc_error (- 32601 , "Method not found (wallet method is disabled because no wallet is loaded)" ,
277- self .nodes [0 ].getwalletinfo )
278-
279- # Successfully load a previously unloaded wallet
280- self .nodes [0 ].loadwallet ('w1' )
281- assert_equal (self .nodes [0 ].listwallets (), ['w1' ])
282- assert_equal (w1 .getwalletinfo ()['walletname' ], 'w1' )
283-
284- # Test backing up and restoring wallets
285- self .log .info ("Test wallet backup" )
286- self .restart_node (0 , ['-nowallet' ])
287- for wallet_name in wallet_names :
288- self .nodes [0 ].loadwallet (wallet_name )
289- for wallet_name in wallet_names :
290- rpc = self .nodes [0 ].get_wallet_rpc (wallet_name )
291- addr = rpc .getnewaddress ()
292- backup = os .path .join (self .options .tmpdir , 'backup.dat' )
293- rpc .backupwallet (backup )
294- self .nodes [0 ].unloadwallet (wallet_name )
295- shutil .copyfile (empty_wallet , wallet_file (wallet_name ))
296- self .nodes [0 ].loadwallet (wallet_name )
297- assert_equal (rpc .getaddressinfo (addr )['ismine' ], False )
298- self .nodes [0 ].unloadwallet (wallet_name )
299- shutil .copyfile (backup , wallet_file (wallet_name ))
300- self .nodes [0 ].loadwallet (wallet_name )
301- assert_equal (rpc .getaddressinfo (addr )['ismine' ], True )
302-
303- # Test .walletlock file is closed
304- self .start_node (1 )
305- wallet = os .path .join (self .options .tmpdir , 'my_wallet' )
306- self .nodes [0 ].createwallet (wallet )
307- assert_raises_rpc_error (- 4 , "Error initializing wallet database environment" ,
308- self .nodes [1 ].loadwallet , wallet )
309- self .nodes [0 ].unloadwallet (wallet )
310- self .nodes [1 ].loadwallet (wallet )
311-
312247
313248if __name__ == '__main__' :
314249 MultiWalletTest ().main ()
0 commit comments