33 static const auto testing_setup = MakeNoLogFileContext<>();
51 bool force_read_and_write_to_err{
false};
52 if (start_with_corrupted_banlist) {
57 if (force_read_and_write_to_err) {
58 banlist_file = fs::path{
"path"} /
"to" /
"inaccessible" /
"fuzzed_banlist";
67 bool contains_invalid{
false};
74 if (!net_addr.IsCJDNS() || !net_addr.IsValid()) {
75 const std::optional<CNetAddr>& addr{
LookupHost(net_addr.ToStringAddr(),
false)};
76 if (addr.has_value() && addr->IsValid()) {
79 contains_invalid =
true;
84 ban_man.Ban(net_addr, ban_time_offset, since_unix_epoch);
89 if (!subnet.IsValid()) {
90 contains_invalid =
true;
94 ban_man.Ban(subnet, ban_time_offset, since_unix_epoch);
97 ban_man.ClearBanned();
113 ban_man.GetBanned(banmap);
116 ban_man.DumpBanlist();
125 if (!force_read_and_write_to_err) {
126 ban_man.DumpBanlist();
129 ban_man.GetBanned(banmap);
130 BanMan ban_man_read{banlist_file,
nullptr, 0};
133 if (!contains_invalid) {
134 assert(banmap == banmap_read);
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
void GetBanned(banmap_t &banmap) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex)
std::string ConsumeRandomLengthString(size_t max_length)
T ConsumeIntegralInRange(T min, T max)
static std::string PathToString(const path &path)
Convert path object to a byte string.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::map< CSubNet, CBanEntry > banmap_t
CSubNet LookupSubNet(const std::string &subnet_str)
Parse and resolve a specified subnet string into the appropriate internal representation.
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
bool WriteBinaryFile(const fs::path &filename, const std::string &data)
Write contents of std::string to a file.
FUZZ_TARGET(banman,.init=initialize_banman)
static bool operator==(const CBanEntry &lhs, const CBanEntry &rhs)
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
CSubNet ConsumeSubNet(FuzzedDataProvider &fuzzed_data_provider) noexcept
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
FuzzedDataProvider & fuzzed_data_provider