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) 2022-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 block download7Ensure that even in IBD, we'll eventually sync chain from inbound peers8(whether we have only inbound peers or both inbound and outbound peers).9"""11from test_framework.test_framework import BitcoinTestFramework13class BlockSyncTest(BitcoinTestFramework):15def set_test_params(self):16self.setup_clean_chain = True17self.num_nodes = 319def setup_network(self):20self.setup_nodes()21# Construct a network:22# node0 -> node1 -> node223# So node1 has both an inbound and outbound peer.24# In our test, we will mine a block on node0, and ensure that it makes25# to both node1 and node2.26self.connect_nodes(0, 1)27self.connect_nodes(1, 2)29def run_test(self):30self.log.info("Setup network: node0->node1->node2")31self.log.info("Mining one block on node0 and verify all nodes sync")32self.generate(self.nodes[0], 1)33self.log.info("Success!")36if __name__ == '__main__':37BlockSyncTest(__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.