31 auto checksum_assist = fuzzed_data_provider.
ConsumeBool();
32 auto magic_bytes_assist = fuzzed_data_provider.ConsumeBool();
33 std::vector<uint8_t> mutable_msg_bytes;
36 if (magic_bytes_assist) {
39 mutable_msg_bytes.push_back(msg_start[i]);
44 if (checksum_assist) {
48 auto header_random_bytes = fuzzed_data_provider.ConsumeBytes<uint8_t>(header_bytes_remaining);
49 mutable_msg_bytes.insert(mutable_msg_bytes.end(), header_random_bytes.begin(), header_random_bytes.end());
50 auto payload_bytes = fuzzed_data_provider.ConsumeRemainingBytes<uint8_t>();
54 unsigned char hsh[32];
55 hasher.
Write(payload_bytes);
58 mutable_msg_bytes.push_back(hsh[i]);
62 mutable_msg_bytes.insert(mutable_msg_bytes.end(), payload_bytes.begin(), payload_bytes.end());
64 while (msg_bytes.size() > 0) {
65 const int handled = deserializer.Read(msg_bytes);
69 if (deserializer.Complete()) {
70 const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
71 bool reject_message{
false};
72 CNetMessage msg = deserializer.GetMessage(m_time, reject_message);
78 std::vector<unsigned char> header;
80 serializer.prepareForTransport(msg2, header);
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
const CChainParams & Params()
Return the currently selected parameters.
static const std::string REGTEST
const CMessageHeader::MessageStartChars & MessageStart() const
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
CHash256 & Write(Span< const unsigned char > input)
void Finalize(Span< unsigned char > output)
Transport protocol agnostic message container.
uint32_t m_message_size
size of the payload
std::chrono::microseconds m_time
time of message receipt
CDataStream m_recv
received message data
uint32_t m_raw_message_size
used wire size of the message (including header/checksum)
A Span is an object that can refer to a contiguous sequence of objects.
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
void initialize_p2p_transport_serialization()
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span{std::forward< V >(v)}))
Like the Span constructor, but for (const) unsigned char member types only.
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation