aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeshCollider <dobsonsa68@gmail.com>2017-12-15 11:15:18 +1300
committerMeshCollider <dobsonsa68@gmail.com>2018-01-16 19:05:45 +1300
commitc9ed4bd58cac05b355ab103476ff29ecd10ce263 (patch)
tree1c339adb96a5a6d802b17c29d72c8e6b9fb777d9
parente60cb99c580a602a83856769ad2ac882d3cdfcb5 (diff)
Add a test for wallet directory locking
-rwxr-xr-xtest/functional/multiwallet.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/functional/multiwallet.py b/test/functional/multiwallet.py
index 12d9e9f48d..38e2a8bfec 100755
--- a/test/functional/multiwallet.py
+++ b/test/functional/multiwallet.py
@@ -15,8 +15,8 @@ from test_framework.util import assert_equal, assert_raises_rpc_error
class MultiWalletTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
- self.num_nodes = 1
- self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']]
+ self.num_nodes = 2
+ self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w'], []]
self.supports_cli = True
def run_test(self):
@@ -28,7 +28,7 @@ class MultiWalletTest(BitcoinTestFramework):
assert_equal(set(node.listwallets()), {"w1", "w2", "w3", "w"})
- self.stop_node(0)
+ self.stop_nodes()
# should not initialize if there are duplicate wallets
self.assert_start_raises_init_error(0, ['-wallet=w1', '-wallet=w1'], 'Error loading wallet w1. Duplicate -wallet filename specified.')
@@ -59,19 +59,21 @@ class MultiWalletTest(BitcoinTestFramework):
assert_equal(set(node.listwallets()), {"w4", "w5"})
w5 = wallet("w5")
w5.generate(1)
- self.stop_node(0)
# 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())
- self.start_node(0, ['-wallet=w4', '-wallet=w5', '-walletdir=' + data_dir()])
+ self.restart_node(0, ['-wallet=w4', '-wallet=w5', '-walletdir=' + data_dir()])
assert_equal(set(node.listwallets()), {"w4", "w5"})
w5 = wallet("w5")
w5_info = w5.getwalletinfo()
assert_equal(w5_info['immature_balance'], 50)
- self.stop_node(0)
+ competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
+ os.mkdir(competing_wallet_dir)
+ self.restart_node(0, ['-walletdir='+competing_wallet_dir])
+ self.assert_start_raises_init_error(1, ['-walletdir='+competing_wallet_dir], 'Cannot obtain a lock on wallet directory')
- self.start_node(0, self.extra_args[0])
+ self.restart_node(0, self.extra_args[0])
w1 = wallet("w1")
w2 = wallet("w2")