8 #include <chainparams.h> 51 }
catch (
const std::exception&) {
62 for (
size_t i = 0; i < 8 && !addr.
IsValid(); ++i) {
73 v4_addr.s_addr = 0x05050505;
93 for (
size_t i = 0; i < num_sources; ++i) {
95 const size_t num_addresses = fast_random_context.randrange(500) + 1;
97 for (
size_t j = 0; j < num_addresses; ++j) {
99 const std::chrono::seconds time_penalty{fast_random_context.randrange(100000001)};
100 addrman.
Add({addr},
source, time_penalty);
102 if (n > 0 && addrman.
Size() % n == 0) {
103 addrman.
Good(addr, Now<NodeSeconds>());
107 if (fast_random_context.randrange(10) == 0 && prev_source.IsValid()) {
108 addrman.
Add({addr}, prev_source, time_penalty);
127 }
catch (
const std::ios_base::failure&) {
142 std::vector<CAddress> addresses;
148 addr_man.
Add(addresses, net_addr, time_penalty);
153 addr_man.
Good(addr, time);
159 addr_man.
Attempt(addr, count_failure, time);
172 const AddrMan& const_addr_man{addr_man};
173 std::optional<Network> network;
180 (void)const_addr_man.GetAddr(max_addresses, max_pct, network, filtered);
182 std::unordered_set<Network> nets;
190 std::optional<bool> in_new;
194 (void)const_addr_man.Size(network, in_new);
196 data_stream << const_addr_man;
213 data_stream << addr_man1;
214 data_stream >> addr_man2;
215 assert(addr_man1 == addr_man2);
size_t Size(std::optional< Network > net=std::nullopt, std::optional< bool > in_new=std::nullopt) const
Return size information about addrman.
WeakEnumType ConsumeWeakEnum(FuzzedDataProvider &fuzzed_data_provider, const WeakEnumType(&all_types)[size]) noexcept
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
const TestingSetup * g_setup
NetGroupManager ConsumeNetGroupManager(FuzzedDataProvider &fuzzed_data_provider) noexcept
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
void ResolveCollisions()
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions...
Stochastic address manager.
std::chrono::seconds ConsumeDuration(FuzzedDataProvider &fuzzed_data_provider, std::chrono::seconds min, std::chrono::seconds max) noexcept
CAddress ConsumeAddress(FuzzedDataProvider &fuzzed_data_provider) noexcept
constexpr ServiceFlags ALL_SERVICE_FLAGS[]
void initialize_addrman()
bool Add(const std::vector< CAddress > &vAddr, const CNetAddr &source, std::chrono::seconds time_penalty=0s)
Attempt to add one or more addresses to addrman's new table.
DataStream ConsumeDataStream(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
void FillAddrman(AddrMan &addrman, FuzzedDataProvider &fuzzed_data_provider)
Fill addrman with lots of addresses from lots of sources.
Double ended buffer combining vector and stream-like interfaces.
CService ConsumeService(FuzzedDataProvider &fuzzed_data_provider) noexcept
A combination of a network address (CNetAddr) and a (TCP) port.
void Attempt(const CService &addr, bool fCountFailure, NodeSeconds time=Now< NodeSeconds >())
Mark an entry as connection attempted to.
A CService with information about it as peer.
void Connected(const CService &addr, NodeSeconds time=Now< NodeSeconds >())
We have successfully connected to this peer.
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
void ReadFromStream(AddrMan &addr, DataStream &ssPeers)
Only used by tests.
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
std::pair< CAddress, NodeSeconds > SelectTriedCollision()
Randomly select an address in the tried table that another address is attempting to evict...
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
FuzzedDataProvider & fuzzed_data_provider
void SetServices(const CService &addr, ServiceFlags nServices)
Update an entry's service bits.
static int32_t GetCheckRatio(const NodeContext &node_ctx)
constexpr auto ALL_NETWORKS
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
FUZZ_TARGET(data_stream_addr_man,.init=initialize_addrman)
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
CNetAddr RandAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext &fast_random_context)
Generate a random address.
T ConsumeIntegralInRange(T min, T max)
bool Good(const CService &addr, NodeSeconds time=Now< NodeSeconds >())
Mark an address record as accessible and attempt to move it to addrman's tried table.
Seed with a compile time constant of zeros.
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
T PickValueInArray(const T(&array)[size])