Skip to content

Commit c9ed4bd

Browse files
committed
Add a test for wallet directory locking
1 parent e60cb99 commit c9ed4bd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/functional/multiwallet.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
class MultiWalletTest(BitcoinTestFramework):
1616
def set_test_params(self):
1717
self.setup_clean_chain = True
18-
self.num_nodes = 1
19-
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']]
18+
self.num_nodes = 2
19+
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w'], []]
2020
self.supports_cli = True
2121

2222
def run_test(self):
@@ -28,7 +28,7 @@ def run_test(self):
2828

2929
assert_equal(set(node.listwallets()), {"w1", "w2", "w3", "w"})
3030

31-
self.stop_node(0)
31+
self.stop_nodes()
3232

3333
# should not initialize if there are duplicate wallets
3434
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):
5959
assert_equal(set(node.listwallets()), {"w4", "w5"})
6060
w5 = wallet("w5")
6161
w5.generate(1)
62-
self.stop_node(0)
6362

6463
# now if wallets/ exists again, but the rootdir is specified as the walletdir, w4 and w5 should still be loaded
6564
os.rename(wallet_dir2, wallet_dir())
66-
self.start_node(0, ['-wallet=w4', '-wallet=w5', '-walletdir=' + data_dir()])
65+
self.restart_node(0, ['-wallet=w4', '-wallet=w5', '-walletdir=' + data_dir()])
6766
assert_equal(set(node.listwallets()), {"w4", "w5"})
6867
w5 = wallet("w5")
6968
w5_info = w5.getwalletinfo()
7069
assert_equal(w5_info['immature_balance'], 50)
7170

72-
self.stop_node(0)
71+
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
72+
os.mkdir(competing_wallet_dir)
73+
self.restart_node(0, ['-walletdir='+competing_wallet_dir])
74+
self.assert_start_raises_init_error(1, ['-walletdir='+competing_wallet_dir], 'Cannot obtain a lock on wallet directory')
7375

74-
self.start_node(0, self.extra_args[0])
76+
self.restart_node(0, self.extra_args[0])
7577

7678
w1 = wallet("w1")
7779
w2 = wallet("w2")

0 commit comments

Comments
 (0)