aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_shutdown.py
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-12-14 11:27:21 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-01-16 12:01:42 +0000
commit4412a59bfe8228698e5b5bbe8bb21c8e8a70d357 (patch)
treeeaaa2823bb2300a9d6834ebe45cf6e1c45861c22 /test/functional/feature_shutdown.py
parentcf0c67b62c2037dc9e70ea84ffee3b205a9b1bef (diff)
downloadbitcoin-4412a59bfe8228698e5b5bbe8bb21c8e8a70d357.tar.xz
qa: Remove race between connecting and shutdown on separate connections
Diffstat (limited to 'test/functional/feature_shutdown.py')
-rwxr-xr-xtest/functional/feature_shutdown.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/functional/feature_shutdown.py b/test/functional/feature_shutdown.py
index b633fabb1f..5084cb1322 100755
--- a/test/functional/feature_shutdown.py
+++ b/test/functional/feature_shutdown.py
@@ -5,7 +5,7 @@
"""Test bitcoind shutdown."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_equal, get_rpc_proxy
+from test_framework.util import assert_equal, get_rpc_proxy, wait_until
from threading import Thread
def test_long_call(node):
@@ -20,8 +20,14 @@ class ShutdownTest(BitcoinTestFramework):
def run_test(self):
node = get_rpc_proxy(self.nodes[0].url, 1, timeout=600, coveragedir=self.nodes[0].coverage_dir)
+ # Force connection establishment by executing a dummy command.
+ node.getblockcount()
Thread(target=test_long_call, args=(node,)).start()
- # wait 1 second to ensure event loop waits for current connections to close
+ # Wait until the server is executing the above `waitfornewblock`.
+ wait_until(lambda: len(self.nodes[0].getrpcinfo()['active_commands']) == 2)
+ # Wait 1 second after requesting shutdown but not before the `stop` call
+ # finishes. This is to ensure event loop waits for current connections
+ # to close.
self.stop_node(0, wait=1000)
if __name__ == '__main__':