 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
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) {
83 g_setup->m_node.peerman->InitializeNode(&p2p_node);
84 FillNode(fuzzed_data_provider, connman, *g_setup->m_node.peerman, p2p_node);
86 const auto mock_time =
ConsumeTime(fuzzed_data_provider);
92 g_setup->m_node.peerman->ProcessMessage(p2p_node, random_message_type, random_bytes_data_stream,
93 GetTime<std::chrono::microseconds>(), std::atomic<bool>{
false});
94 }
catch (
const std::ios_base::failure&) {
98 g_setup->m_node.peerman->SendMessages(&p2p_node);
101 g_setup->m_node.connman->StopNodes();
void FillNode(FuzzedDataProvider &fuzzed_data_provider, ConnmanTestMsg &connman, PeerManager &peerman, CNode &node) noexcept
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
void fuzz_target(FuzzBufferType buffer, const std::string &LIMIT_TO_MESSAGE_TYPE)
Information about a peer.
void ResetIbd()
Reset the ibd cache to its initial state.
CTxIn MineBlock(const NodeContext &node, const CScript &coinbase_scriptPubKey)
Returns the generated coin.
#define Assert(val)
Identity function.
#define FUZZ_TARGET_MSG(msg_type)
constexpr std::size_t size() const noexcept
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
A Span is an object that can refer to a contiguous sequence of objects.
void AddTestNode(CNode &node)
void initialize_process_message()
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
std::vector< T > ConsumeRemainingBytes()
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
size_t & GetNumMsgTypes()
Serialized script, used inside transaction inputs and outputs.
constexpr C * data() const noexcept
FUZZ_TARGET_INIT(process_message, initialize_process_message)
RecursiveMutex cs_sendProcessing
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
std::string ConsumeBytesAsString(size_t num_bytes)
Testing setup that configures a complete environment.
const std::vector< std::string > & getAllNetMessageTypes()
Double ended buffer combining vector and stream-like interfaces.
static const int PROTOCOL_VERSION
network protocol versioning