Skip to content

Commit

Permalink
Add a test for wallet directory locking
Browse files Browse the repository at this point in the history
  • Loading branch information
meshcollider committed Jan 16, 2018
1 parent e60cb99 commit c9ed4bd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/functional/multiwallet.py
Expand Up @@ -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):
Expand All @@ -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.')
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit c9ed4bd

Please sign in to comment.