5#include <chainparams.h>
66 unsigned char hsh[32];
81 const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
87 assert(msg.m_time == m_time);
89 std::vector<unsigned char> header;
107template<RandomNumberGenerator R>
119 std::array<std::vector<uint8_t>, 2>
in_flight;
122 std::array<std::deque<CSerializedNetMsg>, 2> expected;
125 std::array<std::vector<uint8_t>, 2>
to_send;
146 if (
c <
' ' ||
c > 0x7E)
break;
161 msg.m_type =
"version";
168 msg.data = rng.randbytes(size);
174 std::array<CSerializedNetMsg, 2>
next_msg = {
196 std::copy(bytes.begin(), bytes.end(),
to_send[
side].begin());
207 if (expected[
side].size() >= 16)
return;
228 if (bytes.empty())
return false;
272 auto received =
transports[!
side]->GetReceivedMessage({}, reject);
278 assert(received.m_message_size == received.m_recv.size());
280 assert(received.m_type == expected[
side].front().m_type);
283 expected[
side].pop_front();
327 assert(expected[0].empty());
328 assert(expected[1].empty());
336 return std::make_unique<V1Transport>(nodeid);
339template<RandomNumberGenerator RNG>
344 if (!key.IsValid())
return {};
347 std::vector<uint8_t>
garb;
370 return std::make_unique<V2Transport>(nodeid,
initiator, key,
ent, std::move(
garb));
382 if (!
t1 || !
t2)
return;
383 SimulationTest(*
t1, *
t2, rng, provider);
393 if (!
t1 || !
t2)
return;
394 SimulationTest(*
t1, *
t2, rng, provider);
404 if (!
t1 || !
t2)
return;
405 SimulationTest(*
t1, *
t2, rng, provider);
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
const CChainParams & Params()
Return the currently selected parameters.
const MessageStartChars & MessageStart() const
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
void Finalize(std::span< unsigned char > output)
CHash256 & Write(std::span< const unsigned char > input)
Transport protocol agnostic message container.
A hasher class for SHA-256.
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA256 & Write(const unsigned char *data, size_t len)
RAII class initializing and deinitializing global state for elliptic curve support.
std::vector< T > ConsumeBytes(size_t num_bytes)
T ConsumeIntegralInRange(T min, T max)
std::vector< T > ConsumeRemainingBytes()
The Transport converts one connection's sent messages to wire bytes, and received bytes back.
std::tuple< std::span< const uint8_t >, bool, const std::string & > BytesToSend
Return type for GetBytesToSend, consisting of:
static constexpr uint32_t MAX_GARBAGE_LEN
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
CSerializedNetMsg Make(std::string msg_type, Args &&... args)
const std::array ALL_NET_MESSAGE_TYPES
All known message types (see above).
auto MakeByteSpan(const V &v) noexcept
unsigned char * UCharCast(char *c)
CKey ConsumePrivateKey(FuzzedDataProvider &fuzzed_data_provider, std::optional< bool > compressed) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider