Changeset View
Changeset View
Standalone View
Standalone View
test/functional/multiwallet.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017 The Bitcoin Core developers | # Copyright (c) 2017 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test multiwallet. | """Test multiwallet. | ||||
Verify that a bitcoind node can load multiple wallet files | Verify that a bitcoind node can load multiple wallet files | ||||
""" | """ | ||||
import os | import os | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, assert_raises_jsonrpc | from test_framework.util import assert_equal, assert_raises_jsonrpc | ||||
class MultiWalletTest(BitcoinTestFramework): | class MultiWalletTest(BitcoinTestFramework): | ||||
def set_test_params(self): | |||||
def __init__(self): | |||||
super().__init__() | |||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [ | self.extra_args = [ | ||||
['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']] | ['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']] | ||||
def run_test(self): | def run_test(self): | ||||
assert_equal(set(self.nodes[0].listwallets()), {"w1", "w2", "w3", "w"}) | assert_equal(set(self.nodes[0].listwallets()), {"w1", "w2", "w3", "w"}) | ||||
self.stop_node(0) | self.stop_node(0) | ||||
# should not initialize if there are duplicate wallets | # should not initialize if there are duplicate wallets | ||||
self.assert_start_raises_init_error(0, self.options.tmpdir, [ | self.assert_start_raises_init_error( | ||||
'-wallet=w1', '-wallet=w1'], 'Error loading wallet w1. Duplicate -wallet filename specified.') | 0, ['-wallet=w1', '-wallet=w1'], 'Error loading wallet w1. Duplicate -wallet filename specified.') | ||||
# should not initialize if wallet file is a directory | # should not initialize if wallet file is a directory | ||||
os.mkdir(os.path.join(self.options.tmpdir, 'node0', 'regtest', 'w11')) | os.mkdir(os.path.join(self.options.tmpdir, 'node0', 'regtest', 'w11')) | ||||
self.assert_start_raises_init_error(0, self.options.tmpdir, [ | self.assert_start_raises_init_error( | ||||
'-wallet=w11'], 'Error loading wallet w11. -wallet filename must be a regular file.') | 0, ['-wallet=w11'], 'Error loading wallet w11. -wallet filename must be a regular file.') | ||||
# should not initialize if wallet file is a symlink | # should not initialize if wallet file is a symlink | ||||
wallet_dir = os.path.abspath(os.path.join( | wallet_dir = os.path.abspath(os.path.join( | ||||
self.options.tmpdir, 'node0', 'regtest')) | self.options.tmpdir, 'node0', 'regtest')) | ||||
os.symlink(os.path.join(wallet_dir, 'w1'), | os.symlink(os.path.join(wallet_dir, 'w1'), | ||||
os.path.join(wallet_dir, 'w12')) | os.path.join(wallet_dir, 'w12')) | ||||
self.assert_start_raises_init_error(0, self.options.tmpdir, [ | self.assert_start_raises_init_error( | ||||
'-wallet=w12'], 'Error loading wallet w12. -wallet filename must be a regular file.') | 0, ['-wallet=w12'], 'Error loading wallet w12. -wallet filename must be a regular file.') | ||||
self.nodes[0] = self.start_node( | self.start_node(0, self.extra_args[0]) | ||||
0, self.options.tmpdir, self.extra_args[0]) | |||||
w1 = self.nodes[0].get_wallet_rpc("w1") | w1 = self.nodes[0].get_wallet_rpc("w1") | ||||
w2 = self.nodes[0].get_wallet_rpc("w2") | w2 = self.nodes[0].get_wallet_rpc("w2") | ||||
w3 = self.nodes[0].get_wallet_rpc("w3") | w3 = self.nodes[0].get_wallet_rpc("w3") | ||||
w4 = self.nodes[0].get_wallet_rpc("w") | w4 = self.nodes[0].get_wallet_rpc("w") | ||||
wallet_bad = self.nodes[0].get_wallet_rpc("bad") | wallet_bad = self.nodes[0].get_wallet_rpc("bad") | ||||
w1.generate(1) | w1.generate(1) | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |