Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_multiwallet.py
Show All 39 Lines | for _ in range(10): | ||||
got_loading_error = True | got_loading_error = True | ||||
return | return | ||||
class MultiWalletTest(BitcoinTestFramework): | class MultiWalletTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-wallet="], ["-wallet="]] | |||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_wallet() | self.skip_if_no_wallet() | ||||
def add_options(self, parser): | def add_options(self, parser): | ||||
parser.add_argument( | parser.add_argument( | ||||
'--data_wallets_dir', | '--data_wallets_dir', | ||||
default=os.path.join( | default=os.path.join( | ||||
Show All 30 Lines | def run_test(self): | ||||
os.mkdir(wallet_dir('w7')) | os.mkdir(wallet_dir('w7')) | ||||
os.symlink('w7', wallet_dir('w7_symlink')) | os.symlink('w7', wallet_dir('w7_symlink')) | ||||
# rename wallet.dat to make sure plain wallet file paths (as opposed to | # rename wallet.dat to make sure plain wallet file paths (as opposed to | ||||
# directory paths) can be loaded | # directory paths) can be loaded | ||||
os.rename(wallet_dir("wallet.dat"), wallet_dir("w8")) | os.rename(wallet_dir("wallet.dat"), wallet_dir("w8")) | ||||
# create another dummy wallet for use in testing backups later | # create another dummy wallet for use in testing backups later | ||||
self.start_node(0, []) | self.start_node(0, ["-wallet="]) | ||||
self.stop_nodes() | self.stop_nodes() | ||||
empty_wallet = os.path.join(self.options.tmpdir, 'empty.dat') | empty_wallet = os.path.join(self.options.tmpdir, 'empty.dat') | ||||
os.rename(wallet_dir("wallet.dat"), empty_wallet) | os.rename(wallet_dir("wallet.dat"), empty_wallet) | ||||
# restart node with a mix of wallet names: | # restart node with a mix of wallet names: | ||||
# w1, w2, w3 - to verify new wallets created when non-existing paths specified | # w1, w2, w3 - to verify new wallets created when non-existing paths specified | ||||
# w - to verify wallet name matching works when one wallet path is prefix of another | # w - to verify wallet name matching works when one wallet path is prefix of another | ||||
# sub/w5 - to verify relative wallet path is created correctly | # sub/w5 - to verify relative wallet path is created correctly | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(set(node.listwallets()), {"w4", "w5"}) | assert_equal(set(node.listwallets()), {"w4", "w5"}) | ||||
w5 = wallet("w5") | w5 = wallet("w5") | ||||
w5_info = w5.getwalletinfo() | w5_info = w5.getwalletinfo() | ||||
assert_equal(w5_info['immature_balance'], 50000000) | assert_equal(w5_info['immature_balance'], 50000000) | ||||
competing_wallet_dir = os.path.join( | competing_wallet_dir = os.path.join( | ||||
self.options.tmpdir, 'competing_walletdir') | self.options.tmpdir, 'competing_walletdir') | ||||
os.mkdir(competing_wallet_dir) | os.mkdir(competing_wallet_dir) | ||||
self.restart_node(0, ['-walletdir=' + competing_wallet_dir]) | self.restart_node( | ||||
0, ['-walletdir=' + competing_wallet_dir, '-wallet=']) | |||||
exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\"!" | exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\"!" | ||||
self.nodes[1].assert_start_raises_init_error( | self.nodes[1].assert_start_raises_init_error( | ||||
['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX) | ['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX) | ||||
self.restart_node(0, extra_args) | self.restart_node(0, extra_args) | ||||
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ | 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']) | '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy']) | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |