I was building Bitcoin Core on my Windows machine, on WSL/Ubuntu. I tried to run the tests and ran into a problem. The test in test/functional/wallet_multiwallet.py
failed. Follows the output of the test:
0mtrycz@LAPTOP-00AACAV2:~/git/bitcoin/test/functional$ ./test_runner.py wallet_multiwallet.py
1Temporary test directory at /tmp/test_runner_₿_🏃_20200413_152720
2Remaining jobs: [wallet_multiwallet.py]
31/1 - wallet_multiwallet.py failed, Duration: 9 s
4
5stdout:
62020-04-13T13:27:20.407000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
72020-04-13T13:27:24.947000Z TestFramework (INFO): Do not allow -zapwallettxes with multiwallet
82020-04-13T13:27:25.745000Z TestFramework (INFO): Do not allow -salvagewallet with multiwallet
92020-04-13T13:27:26.278000Z TestFramework (INFO): Do not allow -upgradewallet with multiwallet
102020-04-13T13:27:29.060000Z TestFramework (ERROR): Assertion failed
11Traceback (most recent call last):
12 File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_framework.py", line 112, in main
13 self.run_test()
14 File "/home/mtrycz/git/bitcoin/test/functional/wallet_multiwallet.py", line 152, in run_test
15 self.nodes[1].assert_start_raises_init_error(['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
16 File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 460, in assert_start_raises_init_error
17 self._raise_assertion_error(assert_msg)
18 File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 157, in _raise_assertion_error
19 raise AssertionError(self._node_msg(msg))
20AssertionError: [node 1] bitcoind should have exited with expected error Error: Error initializing wallet database environment \"\S+competing_walletdir\"!
212020-04-13T13:27:29.113000Z TestFramework (INFO): Stopping nodes
222020-04-13T13:27:29.215000Z TestFramework (WARNING): Not cleaning up dir /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
232020-04-13T13:27:29.215000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0/test_framework.log
242020-04-13T13:27:29.215000Z TestFramework (ERROR): Hint: Call /home/mtrycz/git/bitcoin/test/functional/combine_logs.py '/tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0' to consolidate all logs
25
26
27stderr:
28
29
30
31TEST | STATUS | DURATION
32
33wallet_multiwallet.py | ✖ Failed | 9 s
34
35ALL | ✖ Failed | 9 s (accumulated)
36Runtime: 9 s
I traced the cause to a node being able to open a wallet that is already open by another node.
To the best of my understanding mutliple bitcoind instances shouldn’t be able to point to the same datadirs or walletdirs. On Windows it is possible to have multiple bitcoind instances to point to the same walletdir, leading to possible data corruption. To the best of my understanding this is not possible on Linux (can’t confirm atm).
Manual test plan:
- Download the latest Windows release binaries (version v.0.19.1)
- Create two directories, for example
C:\node0
andC:\node1
; create abitcoin.conf
file inC:\node1
with a single linerpcport=8333
(otherwise the second node will fail for an unrelated reason) - Open a command prompt and run
bitcoind.exe -datadir=C:\node0 -walletdir=D:\bchwallettest
- Open a second prompt and run
bitcoind.exe -datadir=C:\node1 -walletdir=D:\bchwallettest
- Expect the second node to fail at startup
I’ve run this test myself and can confirm that the second node erroneously starts. The bug was reproduced on Windows 10 Pro, both in cmd and in WSL shell, with the latest release v.0.19.1.