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) 2021-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"""6Test ports handling for I2P hosts7"""9from test_framework.test_framework import BitcoinTestFramework10from test_framework.util import p2p_port13class I2PPorts(BitcoinTestFramework):14def set_test_params(self):15self.num_nodes = 116# Use the p2p port of the non-existing next node as the proxy port17self.proxy = f"127.0.0.1:{p2p_port(self.num_nodes)}"18# The test assumes that an I2P SAM proxy is not listening here.19self.extra_args = [[f"-i2psam={self.proxy}"]]21def run_test(self):22node = self.nodes[0]24self.log.info("Ensure we don't try to connect if port!=0")25addr = "zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:8333"26with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}, connection refused due to arbitrary port 8333"]):27node.addnode(node=addr, command="onetry")29self.log.info("Ensure we try to connect if port=0 and get an error due to missing I2P proxy")30addr = "h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"31with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {self.proxy}"]):32node.addnode(node=addr, command="onetry")35if __name__ == '__main__':36I2PPorts(__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.