Skip to content

Commit 1f1bef8

Browse files
committed
Have feature_filelock.py test both bdb and sqlite, depending on compiled
1 parent c77975a commit 1f1bef8

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

test/functional/feature_filelock.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Check that it's not possible to start a second bitcoind instance using the same datadir or wallet."""
66
import os
7+
import random
8+
import string
79

810
from test_framework.test_framework import BitcoinTestFramework
911
from test_framework.test_node import ErrorMatch
@@ -27,11 +29,21 @@ def run_test(self):
2729
self.nodes[1].assert_start_raises_init_error(extra_args=['-datadir={}'.format(self.nodes[0].datadir), '-noserver'], expected_msg=expected_msg)
2830

2931
if self.is_wallet_compiled():
30-
self.nodes[0].createwallet(self.default_wallet_name)
31-
wallet_dir = os.path.join(datadir, 'wallets')
32-
self.log.info("Check that we can't start a second bitcoind instance using the same wallet")
33-
expected_msg = "Error: Error initializing wallet database environment"
34-
self.nodes[1].assert_start_raises_init_error(extra_args=['-walletdir={}'.format(wallet_dir), '-wallet=' + self.default_wallet_name, '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX)
32+
def check_wallet_filelock(descriptors):
33+
wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])
34+
self.nodes[0].createwallet(wallet_name=wallet_name, descriptors=descriptors)
35+
wallet_dir = os.path.join(datadir, 'wallets')
36+
self.log.info("Check that we can't start a second bitcoind instance using the same wallet")
37+
if descriptors:
38+
expected_msg = "Error: SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another bitcoind?"
39+
else:
40+
expected_msg = "Error: Error initializing wallet database environment"
41+
self.nodes[1].assert_start_raises_init_error(extra_args=['-walletdir={}'.format(wallet_dir), '-wallet=' + wallet_name, '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX)
42+
43+
if self.is_bdb_compiled():
44+
check_wallet_filelock(False)
45+
if self.is_sqlite_compiled():
46+
check_wallet_filelock(True)
3547

3648
if __name__ == '__main__':
3749
FilelockTest().main()

0 commit comments

Comments
 (0)