Bitcoin Core  27.99.0
P2P Digital Currency
timeoffsets.cpp
Go to the documentation of this file.
1 // Copyright (c) 2024-present The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <node/timeoffsets.h>
7 #include <test/fuzz/fuzz.h>
9 
10 #include <chrono>
11 #include <cstdint>
12 #include <functional>
13 
15 {
16  static const auto testing_setup = MakeNoLogFileContext<>(ChainType::MAIN);
17 }
18 
20 {
21  FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
23  LIMITED_WHILE(fuzzed_data_provider.remaining_bytes() > 0, 4'000) {
24  (void)offsets.Median();
25  offsets.Add(std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<std::chrono::seconds::rep>()});
26  offsets.WarnIfOutOfSync();
27  }
28 }
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition: fuzz.h:23
static const int64_t offsets[]
FUZZ_TARGET(timeoffsets,.init=initialize_timeoffsets)
Definition: timeoffsets.cpp:19
void initialize_timeoffsets()
Definition: timeoffsets.cpp:14