Skip to content

Commit

Permalink
tests: add a test for the new blocksdir lock
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Jan 16, 2025
1 parent 5eeffab commit 4c2f56c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/functional/feature_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ def setup_network(self):

def run_test(self):
datadir = self.nodes[0].chain_path
blocksdir = self.nodes[0].blocks_path
self.log.info(f"Using datadir {datadir}")
self.log.info(f"Using blocksdir {blocksdir}")

self.log.info("Check that we can't start a second bitcoind instance using the same datadir")
expected_msg = f"Error: Cannot obtain a lock on directory {datadir}. {self.config['environment']['CLIENT_NAME']} is probably already running."
self.nodes[1].assert_start_raises_init_error(extra_args=[f'-datadir={self.nodes[0].datadir_path}', '-noserver'], expected_msg=expected_msg)

self.log.info("Check that cookie and PID file are not deleted when attempting to start a second bitcoind using the same datadir")
self.log.info("Check that we can't start a second bitcoind instance using the same blocksdir")
expected_msg = f"Error: Cannot obtain a lock on directory {blocksdir}. {self.config['environment']['CLIENT_NAME']} is probably already running."
self.nodes[1].assert_start_raises_init_error(extra_args=[f'-blocksdir={self.nodes[0].datadir_path}', '-noserver'], expected_msg=expected_msg)

self.log.info("Check that cookie and PID file are not deleted when attempting to start a second bitcoind using the same datadir/blocksdir")
cookie_file = datadir / ".cookie"
assert cookie_file.exists() # should not be deleted during the second bitcoind instance shutdown
pid_file = datadir / BITCOIN_PID_FILENAME_DEFAULT
Expand Down

0 comments on commit 4c2f56c

Please sign in to comment.