43std::string_view LIMIT_TO_MESSAGE_TYPE{};
52 if (
const auto val{std::getenv(
"LIMIT_TO_MESSAGE_TYPE")}) {
53 LIMIT_TO_MESSAGE_TYPE = val;
57 static const auto testing_setup{
58 MakeNoLogFileContext<TestingSetup>(
75 const auto block_index_size{
WITH_LOCK(chainman.GetMutex(),
return chainman.BlockIndex().size())};
76 const auto initial_sequence{
WITH_LOCK(
node.mempool->cs,
return node.mempool->GetSequence())};
80 chainman.DisableNextWrite();
86 node.addrman = std::make_unique<AddrMan>(*
node.netgroupman,
true, 0);
91 .reconcile_txs = true,
92 .deterministic_rng = true,
95 connman.SetMsgProc(
node.peerman.get());
96 connman.SetAddrman(*
node.addrman);
100 if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
104 node.validation_signals->RegisterValidationInterface(
node.peerman.get());
108 connman.AddTestNode(p2p_node);
114 net_msg.
m_type = random_message_type;
117 connman.FlushSendBuffer(p2p_node);
118 (void)connman.ReceiveMsgFrom(p2p_node, std::move(net_msg));
121 chainman.JumpOutOfIbd();
124 bool more_work{
true};
128 more_work = connman.ProcessMessagesOnce(p2p_node);
129 }
catch (
const std::ios_base::failure&) {
131 node.peerman->SendMessages(p2p_node);
133 node.validation_signals->SyncWithValidationInterfaceQueue();
134 node.validation_signals->UnregisterValidationInterface(
node.peerman.get());
135 node.connman->StopNodes();
136 const auto end_sequence{
WITH_LOCK(
node.mempool->cs,
return node.mempool->GetSequence())};
137 if (block_index_size !=
WITH_LOCK(chainman.GetMutex(),
return chainman.BlockIndex().size()) || initial_sequence != end_sequence) {
const TestingSetup * g_setup
#define Assert(val)
Identity function.
Information about a peer.
std::atomic_bool fPauseSend
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Helper to initialize the global MockableSteadyClock, let a duration elapse, and reset it after use in...
std::string ConsumeBytesAsString(size_t num_bytes)
static Mutex g_msgproc_mutex
Mutex for anything that is only accessed via the msg processing thread.
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, node::Warnings &warnings, Options opts)
static const uint256 ZERO
constexpr unsigned int MAX_PROTOCOL_MESSAGE_LENGTH
Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable).
void MakeRandDeterministicDANGEROUS(const uint256 &seed) noexcept
Internal function to set g_determinstic_rng.
FUZZ_TARGET(process_message,.init=initialize_process_message)
void initialize_process_message()
const std::array ALL_NET_MESSAGE_TYPES
All known message types (see above).
std::vector< unsigned char > data
void Reset()
Reset the internal state.
Testing setup that configures a complete environment.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
SeedRandomStateForTest(SeedRand::ZEROS)
void FillNode(FuzzedDataProvider &fuzzed_data_provider, ConnmanTestMsg &connman, CNode &node) noexcept
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, FakeSteadyClock &clock, const std::optional< NodeId > &node_id_in=std::nullopt)
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
@ ZEROS
Seed with a compile time constant of zeros.
std::vector< std::pair< COutPoint, CAmount > > ResetChainmanAndMempool(TestingSetup &setup, FakeNodeClock &node_clock)
FuzzedDataProvider & fuzzed_data_provider