From c9ed4bd58cac05b355ab103476ff29ecd10ce263 Mon Sep 17 00:00:00 2001 From: MeshCollider Date: Fri, 15 Dec 2017 11:15:18 +1300 Subject: [PATCH] Add a test for wallet directory locking --- test/functional/multiwallet.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/functional/multiwallet.py b/test/functional/multiwallet.py index 12d9e9f48d4b3..38e2a8bfeca30 100755 --- a/test/functional/multiwallet.py +++ b/test/functional/multiwallet.py @@ -15,8 +15,8 @@ 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 @@ def run_test(self): 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 @@ def run_test(self): 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")