21 const std::vector<std::shared_ptr<CBlock>>* g_chain;
23 void initialize_chain()
33 std::unique_ptr<const TestingSetup> setup{MakeNoLogFileContext<const TestingSetup>()};
34 const auto&
node = setup->m_node;
35 auto& chainman{*
node.chainman};
39 Assert(!chainman.SnapshotBlockhash());
44 outfile <<
Span{file_data};
47 const auto ActivateFuzzedSnapshot{[&] {
52 }
catch (
const std::ios_base::failure&) {
55 return chainman.ActivateSnapshot(infile, metadata,
true);
58 if (fuzzed_data_provider.ConsumeBool()) {
59 for (
const auto& block : *g_chain) {
61 bool processed{chainman.ProcessNewBlockHeaders({*block}, dummy,
::Params())};
63 const auto* index{
WITH_LOCK(::
cs_main,
return chainman.m_blockman.LookupBlockIndex(block->GetHash()))};
68 if (ActivateFuzzedSnapshot()) {
70 Assert(!chainman.ActiveChainstate().m_from_snapshot_blockhash->IsNull());
71 Assert(*chainman.ActiveChainstate().m_from_snapshot_blockhash ==
72 *chainman.SnapshotBlockhash());
73 const auto& coinscache{chainman.ActiveChainstate().CoinsTip()};
75 for (
const auto& block : *g_chain) {
77 const auto* index{chainman.m_blockman.LookupBlockIndex(block->GetHash())};
78 const auto num_tx{
Assert(index)->nTx};
82 Assert(g_chain->size() == coinscache.GetCacheSize());
83 Assert(chain_tx == chainman.ActiveTip()->nChainTx);
85 Assert(!chainman.SnapshotBlockhash());
86 Assert(!chainman.ActiveChainstate().m_from_snapshot_blockhash);
89 Assert(!ActivateFuzzedSnapshot());