File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,22 @@ void initialize()
22
22
SelectParams (CBaseChainParams::REGTEST);
23
23
}
24
24
25
+ class CAddrManDeterministic : public CAddrMan
26
+ {
27
+ public:
28
+ void MakeDeterministic (const uint256& random_seed)
29
+ {
30
+ insecure_rand = FastRandomContext{random_seed};
31
+ Clear ();
32
+ }
33
+ };
34
+
25
35
void test_one_input (const std::vector<uint8_t >& buffer)
26
36
{
27
37
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
28
-
29
38
SetMockTime (ConsumeTime (fuzzed_data_provider));
30
- CAddrMan addr_man;
39
+ CAddrManDeterministic addr_man;
40
+ addr_man.MakeDeterministic (ConsumeUInt256 (fuzzed_data_provider));
31
41
if (fuzzed_data_provider.ConsumeBool ()) {
32
42
addr_man.m_asmap = ConsumeRandomLengthBitVector (fuzzed_data_provider);
33
43
if (!SanityCheckASMap (addr_man.m_asmap )) {
Original file line number Diff line number Diff line change @@ -98,7 +98,8 @@ NODISCARD inline CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider)
98
98
99
99
NODISCARD inline int64_t ConsumeTime (FuzzedDataProvider& fuzzed_data_provider) noexcept
100
100
{
101
- static const int64_t time_min = ParseISO8601DateTime (" 1970-01-01T00:00:00Z" );
101
+ // Avoid t=0 (1970-01-01T00:00:00Z) since SetMockTime(0) is a no-op.
102
+ static const int64_t time_min = ParseISO8601DateTime (" 1970-01-01T00:00:01Z" );
102
103
static const int64_t time_max = ParseISO8601DateTime (" 9999-12-31T23:59:59Z" );
103
104
return fuzzed_data_provider.ConsumeIntegralInRange <int64_t >(time_min, time_max);
104
105
}
You can’t perform that action at this time.
0 commit comments