Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_multiwallet.py
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# if wallets/ doesn't exist, datadir should be the default wallet dir | # if wallets/ doesn't exist, datadir should be the default wallet dir | ||||
wallet_dir2 = data_dir('walletdir') | wallet_dir2 = data_dir('walletdir') | ||||
os.rename(wallet_dir(), wallet_dir2) | os.rename(wallet_dir(), wallet_dir2) | ||||
self.start_node(0, ['-wallet=w4', '-wallet=w5']) | self.start_node(0, ['-wallet=w4', '-wallet=w5']) | ||||
assert_equal(set(node.listwallets()), {"w4", "w5"}) | assert_equal(set(node.listwallets()), {"w4", "w5"}) | ||||
w5 = wallet("w5") | w5 = wallet("w5") | ||||
w5.generate(1) | w5.generate(1) | ||||
# now if wallets/ exists again, but the rootdir is specified as the walletdir, w4 and w5 should still be loaded | # now if wallets/ exists again, but the rootdir is specified as the | ||||
# walletdir, w4 and w5 should still be loaded | |||||
os.rename(wallet_dir2, wallet_dir()) | os.rename(wallet_dir2, wallet_dir()) | ||||
self.restart_node(0, ['-wallet=w4', '-wallet=w5', | self.restart_node(0, ['-wallet=w4', '-wallet=w5', | ||||
'-walletdir=' + data_dir()]) | '-walletdir=' + data_dir()]) | ||||
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'], 50) | assert_equal(w5_info['immature_balance'], 50) | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Fail to load if wallet doesn't exist | # Fail to load if wallet doesn't exist | ||||
assert_raises_rpc_error(-18, 'Wallet wallets not found.', | assert_raises_rpc_error(-18, 'Wallet wallets not found.', | ||||
self.nodes[0].loadwallet, 'wallets') | self.nodes[0].loadwallet, 'wallets') | ||||
# Fail to load duplicate wallets | # Fail to load duplicate wallets | ||||
assert_raises_rpc_error(-4, 'Wallet file verification failed: Error loading wallet w1. Duplicate -wallet filename specified.', | assert_raises_rpc_error(-4, 'Wallet file verification failed: Error loading wallet w1. Duplicate -wallet filename specified.', | ||||
self.nodes[0].loadwallet, wallet_names[0]) | self.nodes[0].loadwallet, wallet_names[0]) | ||||
# Fail to load duplicate wallets by different ways (directory and filepath) | # Fail to load duplicate wallets by different ways (directory and | ||||
# filepath) | |||||
assert_raises_rpc_error(-4, "Wallet file verification failed: Error loading wallet wallet.dat. Duplicate -wallet filename specified.", | assert_raises_rpc_error(-4, "Wallet file verification failed: Error loading wallet wallet.dat. Duplicate -wallet filename specified.", | ||||
self.nodes[0].loadwallet, 'wallet.dat') | self.nodes[0].loadwallet, 'wallet.dat') | ||||
# Fail to load if one wallet is a copy of another | # Fail to load if one wallet is a copy of another | ||||
assert_raises_rpc_error(-1, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", | assert_raises_rpc_error(-1, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", | ||||
self.nodes[0].loadwallet, 'w8_copy') | self.nodes[0].loadwallet, 'w8_copy') | ||||
# Fail to load if one wallet is a copy of another. | # Fail to load if one wallet is a copy of another. | ||||
# Test this twice to make sure that we don't re-introduce https://github.com/bitcoin/bitcoin/issues/14304 | # Test this twice to make sure that we don't re-introduce | ||||
# https://github.com/bitcoin/bitcoin/issues/14304 | |||||
assert_raises_rpc_error(-1, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", | assert_raises_rpc_error(-1, "BerkeleyBatch: Can't open database w8_copy (duplicates fileid", | ||||
self.nodes[0].loadwallet, 'w8_copy') | self.nodes[0].loadwallet, 'w8_copy') | ||||
# Fail to load if wallet file is a symlink | # Fail to load if wallet file is a symlink | ||||
assert_raises_rpc_error(-4, "Wallet file verification failed: Invalid -wallet path 'w8_symlink'", | assert_raises_rpc_error(-4, "Wallet file verification failed: Invalid -wallet path 'w8_symlink'", | ||||
self.nodes[0].loadwallet, 'w8_symlink') | self.nodes[0].loadwallet, 'w8_symlink') | ||||
# Fail to load if a directory is specified that doesn't contain a wallet | # Fail to load if a directory is specified that doesn't contain a | ||||
# wallet | |||||
os.mkdir(wallet_dir('empty_wallet_dir')) | os.mkdir(wallet_dir('empty_wallet_dir')) | ||||
assert_raises_rpc_error(-18, "Directory empty_wallet_dir does not contain a wallet.dat file", | assert_raises_rpc_error(-18, "Directory empty_wallet_dir does not contain a wallet.dat file", | ||||
self.nodes[0].loadwallet, 'empty_wallet_dir') | self.nodes[0].loadwallet, 'empty_wallet_dir') | ||||
self.log.info("Test dynamic wallet creation.") | self.log.info("Test dynamic wallet creation.") | ||||
# Fail to create a wallet if it already exists. | # Fail to create a wallet if it already exists. | ||||
assert_raises_rpc_error(-4, "Wallet w2 already exists.", | assert_raises_rpc_error(-4, "Wallet w2 already exists.", | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |