Skip to content

Commit 3ae3748

Browse files
committed
Merge #14958: qa: Remove race between connecting and shutdown on separate connections
4412a59 qa: Remove race between connecting and shutdown on separate connections (João Barbosa) Pull request description: Fixes the error bitcoin/bitcoin#14670 (comment) reported by @ken2812221. There is a race between RPC stop and another concurrent call in the test framework. The connection must be established and the command `waitfornewblock` running before calling `stop`. See also bitcoin/bitcoin#14670 (comment). Tree-SHA512: 77feb8628d3b9c025ec0cf83565d4d6680cad4fb182fc93a65df8b573f3e799ba4c44e06d9001dd8a375ca0b1ee17f10e66c3902b6256d0ae2acbc64539185d7
2 parents acec9e4 + 4412a59 commit 3ae3748

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/functional/feature_shutdown.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Test bitcoind shutdown."""
66

77
from test_framework.test_framework import BitcoinTestFramework
8-
from test_framework.util import assert_equal, get_rpc_proxy
8+
from test_framework.util import assert_equal, get_rpc_proxy, wait_until
99
from threading import Thread
1010

1111
def test_long_call(node):
@@ -20,8 +20,14 @@ def set_test_params(self):
2020

2121
def run_test(self):
2222
node = get_rpc_proxy(self.nodes[0].url, 1, timeout=600, coveragedir=self.nodes[0].coverage_dir)
23+
# Force connection establishment by executing a dummy command.
24+
node.getblockcount()
2325
Thread(target=test_long_call, args=(node,)).start()
24-
# wait 1 second to ensure event loop waits for current connections to close
26+
# Wait until the server is executing the above `waitfornewblock`.
27+
wait_until(lambda: len(self.nodes[0].getrpcinfo()['active_commands']) == 2)
28+
# Wait 1 second after requesting shutdown but not before the `stop` call
29+
# finishes. This is to ensure event loop waits for current connections
30+
# to close.
2531
self.stop_node(0, wait=1000)
2632

2733
if __name__ == '__main__':

0 commit comments

Comments
 (0)