Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) 2018-present The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test bitcoind shutdown."""7from test_framework.test_framework import BitcoinTestFramework8from test_framework.util import assert_equal9from threading import Thread11def test_long_call(node):12block = node.waitfornewblock()13assert_equal(block['height'], 0)15class ShutdownTest(BitcoinTestFramework):17def set_test_params(self):18self.setup_clean_chain = True19self.num_nodes = 121def run_test(self):22node = self.nodes[0].create_new_rpc_connection()23# Force connection establishment by executing a dummy command.24node.getblockcount()25Thread(target=test_long_call, args=(node,)).start()26# Wait until the server is executing the above `waitfornewblock`.27self.wait_until(lambda: len(self.nodes[0].getrpcinfo()['active_commands']) == 2)28# Wait 1 second after requesting shutdown but not before the `stop` call29# finishes. This is to ensure event loop waits for current connections30# to close.31self.stop_node(0, wait=1000)33if __name__ == '__main__':34ShutdownTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.