3#include <chainparams.h>
11#include <validation.h>
18 static const auto testing_setup = MakeNoLogFileContext<>(
24 const std::vector<CBlockHeader>& all_headers,
25 std::vector<CBlockHeader>& new_headers)
27 Assume(!new_headers.empty());
30 all_headers.empty() ? &genesis_header : &all_headers.back()};
32 for (
auto& header : new_headers) {
35 prev_header = &header;
61 const uint256 genesis_hash = genesis_header.GetHash();
71 std::vector<CBlockHeader> all_headers;
72 std::vector<CBlockHeader>::const_iterator redownloaded_it;
74 bool requested_more{
true};
76 while (requested_more) {
77 std::vector<CBlockHeader> headers;
81 if (presync || fuzzed_data_provider.
ConsumeBool()) {
82 auto deser_headers = ConsumeDeserializable<std::vector<CBlockHeader>>(fuzzed_data_provider);
83 if (!deser_headers || deser_headers->empty())
return;
89 headers.swap(*deser_headers);
90 }
else if (
auto num_headers_left{std::distance(redownloaded_it, all_headers.cend())}; num_headers_left > 0) {
93 auto begin_it{redownloaded_it};
95 headers.insert(headers.cend(), begin_it, redownloaded_it);
98 if (headers.empty())
return;
102 if (result.request_more) {
104 all_headers.insert(all_headers.cend(), headers.cbegin(), headers.cend());
108 redownloaded_it = all_headers.cbegin();
arith_uint256 UintToArith256(const uint256 &a)
const CChainParams & Params()
Return the currently selected parameters.
#define Assume(val)
Assume is the identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetMedianTimePast() const
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
const CBlock & GenesisBlock() const
T ConsumeIntegralInRange(T min, T max)
256-bit unsigned big integer.
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
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.
arith_uint256 CalculateClaimedHeadersWork(std::span< const CBlockHeader > headers)
Return the sum of the claimed work on a given set of headers.