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.
251}253class SocketTestingSetup : public BasicTestingSetup254{255public:256explicit SocketTestingSetup();257~SocketTestingSetup();259/**260* Connect to the socket with a mock client and send pre-loaded data.261* Returns the I/O pipes from the mock client so we can read response data sent to it.262* Template parameter selects the socket type: DynSock by default.263*/264template <typename T = DynSock>265std::shared_ptr<typename T::Pipes> ConnectClient(std::span<const std::byte> data)266{267auto connected_socket_pipes(std::make_shared<typename T::Pipes>());268connected_socket_pipes->recv.PushBytes(data.data(), data.size());269m_accepted_sockets.Push(std::make_unique<T>(connected_socket_pipes));270return connected_socket_pipes;271}273private:274//! Save the original value of CreateSock here and restore it when the test ends.275decltype(CreateSock) m_create_sock_orig;277//! Queue of connected sockets returned by listening socket (represents network interface)278DynSock::Queue m_accepted_sockets;279};281CBlock getBlock13b8a();283#endif // BITCOIN_TEST_UTIL_SETUP_COMMON_H
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.