40 static size_t g_num_msg_types{0};
41 return g_num_msg_types;
43#define FUZZ_TARGET_MSG(msg_type) \
44 struct msg_type##_Count_Before_Main { \
45 msg_type##_Count_Before_Main() \
49 } const static g_##msg_type##_count_before_main; \
50 FUZZ_TARGET_INIT(process_message_##msg_type, initialize_process_message) \
52 fuzz_target(buffer, #msg_type); \
59 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
60 g_setup = testing_setup.get();
77 if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
82 const bool successfully_connected{fuzzed_data_provider.
ConsumeBool()};
85 g_setup->m_node.peerman->InitializeNode(&p2p_node);
86 FillNode(fuzzed_data_provider, p2p_node, successfully_connected);
88 const auto mock_time =
ConsumeTime(fuzzed_data_provider);
94 g_setup->m_node.peerman->ProcessMessage(p2p_node, random_message_type, random_bytes_data_stream,
95 GetTime<std::chrono::microseconds>(), std::atomic<bool>{
false});
96 }
catch (
const std::ios_base::failure&) {
100 g_setup->m_node.peerman->SendMessages(&p2p_node);
103 g_setup->m_node.connman->StopNodes();
#define Assert(val)
Identity function.
Double ended buffer combining vector and stream-like interfaces.
Information about a peer.
RecursiveMutex cs_sendProcessing
std::atomic_bool fSuccessfullyConnected
fSuccessfullyConnected is set to true on receiving VERACK from the peer.
Serialized script, used inside transaction inputs and outputs.
std::string ConsumeBytesAsString(size_t num_bytes)
std::vector< T > ConsumeRemainingBytes()
A Span is an object that can refer to a contiguous sequence of objects.
constexpr std::size_t size() const noexcept
constexpr C * data() const noexcept
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
FUZZ_TARGET_INIT(process_message, initialize_process_message)
#define FUZZ_TARGET_MSG(msg_type)
void fuzz_target(FuzzBufferType buffer, const std::string &LIMIT_TO_MESSAGE_TYPE)
size_t & GetNumMsgTypes()
void initialize_process_message()
const std::vector< std::string > & getAllNetMessageTypes()
void AddTestNode(CNode &node)
void ResetIbd()
Reset the ibd cache to its initial state.
Testing setup that configures a complete environment.
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
void FillNode(FuzzedDataProvider &fuzzed_data_provider, CNode &node, bool init_version) noexcept
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
CTxIn MineBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Returns the generated coin.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
static const int PROTOCOL_VERSION
network protocol versioning