mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
8de8cf33d1
4412a59bfe8228698e5b5bbe8bb21c8e8a70d357 qa: Remove race between connecting and shutdown on separate connections (João Barbosa) Pull request description: Fixes the error https://github.com/bitcoin/bitcoin/pull/14670#issuecomment-447255352 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 https://github.com/bitcoin/bitcoin/pull/14670#issuecomment-447304513. Tree-SHA512: 77feb8628d3b9c025ec0cf83565d4d6680cad4fb182fc93a65df8b573f3e799ba4c44e06d9001dd8a375ca0b1ee17f10e66c3902b6256d0ae2acbc64539185d7
35 lines
1.3 KiB
Python
Executable File
35 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test dashd shutdown."""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import assert_equal, get_rpc_proxy, wait_until
|
|
from threading import Thread
|
|
|
|
def test_long_call(node):
|
|
block = node.waitfornewblock()
|
|
assert_equal(block['height'], 0)
|
|
|
|
class ShutdownTest(BitcoinTestFramework):
|
|
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 1
|
|
|
|
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 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__':
|
|
ShutdownTest().main()
|