30 static const auto testing_setup = MakeNoLogFileContext<TestingSetup>(
50 node.addrman = std::make_unique<AddrMan>(
51 *
node.netgroupman,
true, 0);
56 .reconcile_txs = true,
57 .deterministic_rng = true,
59 connman.SetMsgProc(
node.peerman.get());
60 connman.SetAddrman(*
node.addrman);
64 std::vector<CNode*> peers;
66 for (
int i = 0; i < num_peers_to_add; ++i) {
68 connman.AddTestNode(*peers.back());
69 node.peerman->InitializeNode(
83 clock_ctx += std::chrono::seconds{
85 -std::chrono::seconds{10min}.count(),
93 connman.FlushSendBuffer(connection);
94 (void)connman.ReceiveMsgFrom(connection, std::move(net_msg));
101 more_work = connman.ProcessMessagesOnce(connection);
102 }
catch (
const std::ios_base::failure&) {
104 node.peerman->SendMessages(connection);
108 node.connman->StopNodes();
const TestingSetup * g_setup
Information about a peer.
std::atomic_bool fSuccessfullyConnected
fSuccessfullyConnected is set to true on receiving VERACK from the peer.
std::atomic_bool fPauseSend
std::atomic_bool fDisconnect
T ConsumeIntegralInRange(T min, T max)
static Mutex g_msgproc_mutex
Mutex for anything that is only accessed via the msg processing thread.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, node::Warnings &warnings, Options opts)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
static constexpr std::chrono::minutes TIMEOUT_INTERVAL
Time after which to disconnect, after waiting for a ping response (or inactivity).
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH
Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable).
FUZZ_TARGET(p2p_handshake,.init=::initialize)
const std::array ALL_NET_MESSAGE_TYPES
All known message types (see above).
ServiceFlags
nServices flags
std::vector< unsigned char > data
Testing setup that configures a complete environment.
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
FuzzedDataProvider & fuzzed_data_provider