Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_multiwallet.py
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# extern/w6 - to verify absolute wallet path is created correctly | # extern/w6 - to verify absolute wallet path is created correctly | ||||
# w7_symlink - to verify symlinked wallet path is initialized correctly | # w7_symlink - to verify symlinked wallet path is initialized correctly | ||||
# w8 - to verify existing wallet file is loaded correctly | # w8 - to verify existing wallet file is loaded correctly | ||||
# '' - to verify default wallet file is created correctly | # '' - to verify default wallet file is created correctly | ||||
wallet_names = ['w1', 'w2', 'w3', 'w', 'sub/w5', | 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', ''] | ||||
extra_args = ['-wallet={}'.format(n) for n in wallet_names] | extra_args = ['-wallet={}'.format(n) for n in wallet_names] | ||||
self.start_node(0, extra_args) | self.start_node(0, extra_args) | ||||
assert_equal(set(map(lambda w: w['name'], self.nodes[0].listwalletdir()[ | assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ | ||||
'wallets'])), set(['', 'w3', 'w2', os.path.join('sub', 'w5'), 'w7', 'w7', 'w1', 'w8', 'w'])) | '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8']) | ||||
assert_equal(set(node.listwallets()), set(wallet_names)) | assert_equal(set(node.listwallets()), set(wallet_names)) | ||||
# check that all requested wallets were created | # check that all requested wallets were created | ||||
self.stop_node(0) | self.stop_node(0) | ||||
for wallet_name in wallet_names: | for wallet_name in wallet_names: | ||||
assert_equal(os.path.isfile(wallet_file(wallet_name)), True) | assert_equal(os.path.isfile(wallet_file(wallet_name)), True) | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
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]) | ||||
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(set(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), set( | assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ | ||||
['', 'w3', 'w2', os.path.join('sub', 'w5'), 'w7', 'w7', 'w8_copy', 'w1', 'w8', 'w'])) | '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy']) | ||||
wallets = [wallet(w) for w in wallet_names] | wallets = [wallet(w) for w in wallet_names] | ||||
wallet_bad = wallet("bad") | wallet_bad = wallet("bad") | ||||
# check wallet names and balances | # check wallet names and balances | ||||
wallets[0].generate(1) | wallets[0].generate(1) | ||||
for wallet_name, wallet in zip(wallet_names, wallets): | for wallet_name, wallet in zip(wallet_names, wallets): | ||||
info = wallet.getwalletinfo() | info = wallet.getwalletinfo() | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_raises_rpc_error(-32601, "Method not found (wallet method is disabled because no wallet is loaded)", | assert_raises_rpc_error(-32601, "Method not found (wallet method is disabled because no wallet is loaded)", | ||||
self.nodes[0].getwalletinfo) | self.nodes[0].getwalletinfo) | ||||
# Successfully load a previously unloaded wallet | # Successfully load a previously unloaded wallet | ||||
self.nodes[0].loadwallet('w1') | self.nodes[0].loadwallet('w1') | ||||
assert_equal(self.nodes[0].listwallets(), ['w1']) | assert_equal(self.nodes[0].listwallets(), ['w1']) | ||||
assert_equal(w1.getwalletinfo()['walletname'], 'w1') | assert_equal(w1.getwalletinfo()['walletname'], 'w1') | ||||
assert_equal(set(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), set( | assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [ | ||||
['', 'w3', 'w2', os.path.join('sub', 'w5'), 'w7', 'w9', 'w7', 'w8_copy', 'w1', 'w8', 'w'])) | '', os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy', 'w9']) | ||||
# Test backing up and restoring wallets | # Test backing up and restoring wallets | ||||
self.log.info("Test wallet backup") | self.log.info("Test wallet backup") | ||||
self.restart_node(0, ['-nowallet']) | self.restart_node(0, ['-nowallet']) | ||||
for wallet_name in wallet_names: | for wallet_name in wallet_names: | ||||
self.nodes[0].loadwallet(wallet_name) | self.nodes[0].loadwallet(wallet_name) | ||||
for wallet_name in wallet_names: | for wallet_name in wallet_names: | ||||
rpc = self.nodes[0].get_wallet_rpc(wallet_name) | rpc = self.nodes[0].get_wallet_rpc(wallet_name) | ||||
Show All 24 Lines |