4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Check that it's not possible to start a second bitcoind instance using the same datadir or wallet."""
6
6
import os
7
+ import random
8
+ import string
7
9
8
10
from test_framework .test_framework import BitcoinTestFramework
9
11
from test_framework .test_node import ErrorMatch
@@ -27,11 +29,21 @@ def run_test(self):
27
29
self .nodes [1 ].assert_start_raises_init_error (extra_args = ['-datadir={}' .format (self .nodes [0 ].datadir ), '-noserver' ], expected_msg = expected_msg )
28
30
29
31
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 )
35
47
36
48
if __name__ == '__main__' :
37
49
FilelockTest ().main ()
0 commit comments