34std::string_view LIMIT_TO_MESSAGE_TYPE{};
51 if (
const auto val{std::getenv(
"LIMIT_TO_MESSAGE_TYPE")}) {
52 LIMIT_TO_MESSAGE_TYPE = val;
56 static const auto testing_setup{
57 MakeNoLogFileContext<TestingSetup>(
61 g_setup = testing_setup.get();
62 ResetChainman(*g_setup);
72 connman.ResetMaxOutboundCycle();
74 const auto block_index_size{
WITH_LOCK(chainman.GetMutex(),
return chainman.BlockIndex().size())};
77 chainman.DisableNextWrite();
81 AddrMan addrman{netgroupman,
true, 0};
86 .reconcile_txs = true,
87 .deterministic_rng = true,
90 connman.SetMsgProc(peerman.get());
94 if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
99 connman.AddTestNode(p2p_node);
100 FillNode(fuzzed_data_provider, connman, p2p_node);
102 const auto mock_time =
ConsumeTime(fuzzed_data_provider);
106 net_msg.
m_type = random_message_type;
109 connman.FlushSendBuffer(p2p_node);
110 (void)connman.ReceiveMsgFrom(p2p_node, std::move(net_msg));
112 bool more_work{
true};
116 more_work = connman.ProcessMessagesOnce(p2p_node);
117 }
catch (
const std::ios_base::failure&) {
123 if (block_index_size !=
WITH_LOCK(chainman.GetMutex(),
return chainman.BlockIndex().size())) {
125 ResetChainman(*g_setup);
#define Assert(val)
Identity function.
Stochastic address manager.
Information about a peer.
std::atomic_bool fPauseSend
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)
Manages warning messages within a node.
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH
Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable).
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
std::function< void()> m_make_chainman
void LoadVerifyActivateChainstate()
Testing setup that configures a complete environment.
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
std::unique_ptr< CConnman > connman
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
std::unique_ptr< PeerManager > peerman
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void FillNode(FuzzedDataProvider &fuzzed_data_provider, ConnmanTestMsg &connman, CNode &node) noexcept
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
int64_t 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
COutPoint MineBlock(const NodeContext &node, const node::BlockAssembler::Options &assembler_options)
Returns the generated coin.
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.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.