diff --git a/test/functional/feature_filelock.py b/test/functional/feature_filelock.py --- a/test/functional/feature_filelock.py +++ b/test/functional/feature_filelock.py @@ -38,7 +38,7 @@ self.nodes[1].assert_start_raises_init_error( extra_args=[ '-walletdir={}'.format(wallet_dir), - '-wallet=', + '-wallet=' + self.default_wallet_name, '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX) diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -113,7 +113,7 @@ # Setup to test -getinfo, -generate, and -rpcwallet= with multiple # wallets. - wallets = ['', 'Encrypted', 'secret'] + wallets = [self.default_wallet_name, 'Encrypted', 'secret'] amounts = [ BALANCE + Decimal('9999995.50'), Decimal(9000000), diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -109,6 +109,8 @@ self.rpc_timeout = 60 self.supports_cli = True self.bind_to_localhost_only = True + self.default_wallet_name = "" + self.wallet_data_filename = "wallet.dat" # We run parse_args before set_test_params for tests who need to # know the parser options during setup. self.parse_args() diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -246,7 +246,12 @@ def run_test(self): self.wallet_path = os.path.join( - self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat') + self.nodes[0].datadir, + self.chain, + 'wallets', + self.default_wallet_name, + self.wallet_data_filename + ) self.test_invalid_tool_commands_and_args() # Warning: The following tests are order-dependent. self.test_tool_wallet_info() diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -107,12 +107,15 @@ self.stop_node(2) def erase_three(self): - os.remove(os.path.join( - self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat')) - os.remove(os.path.join( - self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat')) - os.remove(os.path.join( - self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat')) + os.remove( + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) + os.remove( + os.path.join(self.nodes[1].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) + os.remove( + os.path.join(self.nodes[2].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) def run_test(self): self.log.info("Generating initial blockchain") @@ -184,12 +187,18 @@ self.nodes[2].datadir, self.chain, 'chainstate')) # Restore wallets from backup - shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join( - self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat')) - shutil.copyfile(os.path.join(self.nodes[1].datadir, 'wallet.bak'), os.path.join( - self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat')) - shutil.copyfile(os.path.join(self.nodes[2].datadir, 'wallet.bak'), os.path.join( - self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat')) + shutil.copyfile( + os.path.join(self.nodes[0].datadir, 'wallet.bak'), + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) + shutil.copyfile( + os.path.join(self.nodes[1].datadir, 'wallet.bak'), + os.path.join(self.nodes[1].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) + shutil.copyfile( + os.path.join(self.nodes[2].datadir, 'wallet.bak'), + os.path.join(self.nodes[2].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename)) self.log.info("Re-starting nodes") self.start_three() @@ -233,11 +242,12 @@ # Backup to source wallet file must fail sourcePaths = [ - os.path.join(self.nodes[0].datadir, - self.chain, 'wallets', 'wallet.dat'), - os.path.join(self.nodes[0].datadir, self.chain, - '.', 'wallets', 'wallet.dat'), - os.path.join(self.nodes[0].datadir, self.chain, 'wallets', ''), + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', + self.default_wallet_name, self.wallet_data_filename), + os.path.join(self.nodes[0].datadir, self.chain, '.', 'wallets', + self.default_wallet_name, self.wallet_data_filename), + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', + self.default_wallet_name), os.path.join(self.nodes[0].datadir, self.chain, 'wallets')] for sourcePath in sourcePaths: diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py --- a/test/functional/wallet_balance.py +++ b/test/functional/wallet_balance.py @@ -258,10 +258,10 @@ # dynamically loading the wallet. before = self.nodes[1].getbalances()['mine']['untrusted_pending'] dst = self.nodes[1].getnewaddress() - self.nodes[1].unloadwallet('') + self.nodes[1].unloadwallet(self.default_wallet_name) self.nodes[0].sendtoaddress(dst, 100000) self.sync_all() - self.nodes[1].loadwallet('') + self.nodes[1].loadwallet(self.default_wallet_name) after = self.nodes[1].getbalances()['mine']['untrusted_pending'] assert_equal(before + Decimal('100000'), after) diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -21,7 +21,7 @@ # Make a descriptor wallet self.log.info("Making a descriptor wallet") self.nodes[0].createwallet(wallet_name="desc1", descriptors=True) - self.nodes[0].unloadwallet("") + self.nodes[0].unloadwallet(self.default_wallet_name) # A descriptor wallet should have 100 addresses = 100 keys self.log.info("Checking wallet info") diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -97,7 +97,7 @@ shutil.copyfile( os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, 'wallets', - "wallet.dat")) + self.default_wallet_name, self.wallet_data_filename)) self.start_node(1) # Assert that derivation is deterministic @@ -129,8 +129,10 @@ "blocks")) shutil.rmtree(os.path.join( self.nodes[1].datadir, self.chain, "chainstate")) - shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join( - self.nodes[1].datadir, self.chain, "wallets", "wallet.dat")) + shutil.copyfile( + os.path.join(self.nodes[1].datadir, "hd.bak"), + os.path.join(self.nodes[1].datadir, self.chain, "wallets", + self.default_wallet_name, self.wallet_data_filename)) self.start_node(1, extra_args=self.extra_args[1]) connect_nodes(self.nodes[0], self.nodes[1]) self.sync_all() diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -742,7 +742,7 @@ # Cannot import those pubkeys to keypool of wallet with privkeys self.log.info( "Pubkeys cannot be added to the keypool of a wallet with private keys") - wrpc = self.nodes[1].get_wallet_rpc("") + wrpc = self.nodes[1].get_wallet_rpc(self.default_wallet_name) assert wrpc.getwalletinfo()['private_keys_enabled'] result = wrpc.importmulti( [{ diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py --- a/test/functional/wallet_keypool.py +++ b/test/functional/wallet_keypool.py @@ -95,7 +95,7 @@ w2 = nodes[0].get_wallet_rpc('w2') # refer to initial wallet as w1 - w1 = nodes[0].get_wallet_rpc('') + w1 = nodes[0].get_wallet_rpc(self.default_wallet_name) # import private key and fund it address = addr.pop() diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -28,7 +28,8 @@ def run_test(self): wallet_path = os.path.join( - self.nodes[1].datadir, self.chain, "wallets", "wallet.dat") + self.nodes[1].datadir, self.chain, "wallets", + self.default_wallet_name, self.wallet_data_filename) wallet_backup_path = os.path.join(self.nodes[1].datadir, "wallet.bak") self.nodes[0].generate(101) diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -69,15 +69,17 @@ def wallet_file(name): if os.path.isdir(wallet_dir(name)): - return wallet_dir(name, "wallet.dat") + return wallet_dir(name, self.wallet_data_filename) return wallet_dir(name) assert_equal(self.nodes[0].listwalletdir(), - {'wallets': [{'name': ''}]}) + {'wallets': [{'name': self.default_wallet_name}]}) # check wallet.dat is created self.stop_nodes() - assert_equal(os.path.isfile(wallet_dir('wallet.dat')), True) + assert_equal(os.path.isfile(wallet_dir(self.default_wallet_name, + self.wallet_data_filename)), + True) # create symlink to verify wallet directory path can be referenced # through symlink @@ -87,13 +89,15 @@ # rename wallet.dat to make sure plain wallet file paths (as opposed to # directory paths) can be loaded - os.rename(wallet_dir("wallet.dat"), wallet_dir("w8")) + os.rename(wallet_dir(self.default_wallet_name, self.wallet_data_filename), + wallet_dir("w8")) # create another dummy wallet for use in testing backups later - self.start_node(0, ["-wallet="]) + self.start_node(0, ["-wallet=" + self.default_wallet_name]) self.stop_nodes() empty_wallet = os.path.join(self.options.tmpdir, 'empty.dat') - os.rename(wallet_dir("wallet.dat"), empty_wallet) + os.rename(wallet_dir(self.default_wallet_name, self.wallet_data_filename), + empty_wallet) # restart node with a mix of wallet names: # w1, w2, w3 - to verify new wallets created when non-existing paths specified @@ -104,13 +108,17 @@ # w8 - to verify existing wallet file is loaded correctly # '' - to verify default wallet file is created correctly wallet_names = ['w1', 'w2', 'w3', 'w', 'sub/w5', - os.path.join(self.options.tmpdir, 'extern/w6'), 'w7_symlink', 'w8', ''] + os.path.join(self.options.tmpdir, 'extern/w6'), + 'w7_symlink', 'w8', self.default_wallet_name] if os.name == 'nt': wallet_names.remove('w7_symlink') extra_args = ['-wallet={}'.format(n) for n in wallet_names] self.start_node(0, extra_args) - assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ - '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8']) + assert_equal( + sorted(map(lambda w: w['name'], + self.nodes[0].listwalletdir()['wallets'])), + [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', + 'w2', 'w3', 'w7', 'w7_symlink', 'w8']) assert_equal(set(node.listwallets()), set(wallet_names)) @@ -185,8 +193,10 @@ self.restart_node(0, extra_args) - assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ - '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy']) + assert_equal(sorted(map(lambda w: w['name'], + self.nodes[0].listwalletdir()['wallets'])), + [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', + 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy']) wallets = [wallet(w) for w in wallet_names] wallet_bad = wallet("bad") @@ -293,7 +303,7 @@ "regtest", "wallets", "w1", - "wallet.dat") + self.wallet_data_filename) assert_raises_rpc_error( -4, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format( @@ -308,13 +318,13 @@ "node0", "regtest", "wallets", - "wallet.dat") + self.wallet_data_filename) 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') + self.wallet_data_filename) # Fail to load if one wallet is a copy of another assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", @@ -409,8 +419,11 @@ assert_equal(self.nodes[0].listwallets(), ['w1']) assert_equal(w1.getwalletinfo()['walletname'], 'w1') - assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ - '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy', 'w9']) + assert_equal(sorted(map(lambda w: w['name'], + self.nodes[0].listwalletdir()['wallets'])), + [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', + 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy', + 'w9']) # Test backing up and restoring wallets self.log.info("Test wallet backup") diff --git a/test/functional/wallet_reorgsrestore.py b/test/functional/wallet_reorgsrestore.py --- a/test/functional/wallet_reorgsrestore.py +++ b/test/functional/wallet_reorgsrestore.py @@ -105,7 +105,8 @@ os.path.join( self.nodes[1].datadir, self.chain, - 'wallet.dat')) + self.default_wallet_name, + self.wallet_data_filename)) self.start_node(1) tx_after_reorg = self.nodes[1].gettransaction(txid) # Check that normal confirmed tx is confirmed again but with different diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py --- a/test/functional/wallet_send.py +++ b/test/functional/wallet_send.py @@ -170,7 +170,7 @@ def run_test(self): self.log.info("Setup wallets...") # w0 is a wallet with coinbase rewards - w0 = self.nodes[0].get_wallet_rpc("") + w0 = self.nodes[0].get_wallet_rpc(self.default_wallet_name) # w1 is a regular wallet self.nodes[1].createwallet(wallet_name="w1") w1 = self.nodes[1].get_wallet_rpc("w1")