6#include <chainparams.h>
45const std::vector<std::shared_ptr<CBlock>>*
g_chain;
63 auto&
cs{
node.chainman->ActiveChainstate()};
64 cs.ForceFlushStateToDisk(
false);
73template <
bool INVALID>
87 static const auto setup{
91 .setup_validation_interface =
false,
92 .min_validation_cache =
true,
96 auto& chainman{*
setup->m_node.chainman};
97 for (
const auto& block : chain) {
99 bool processed{chainman.ProcessNewBlockHeaders({{*block}},
true, dummy)};
101 const auto* index{
WITH_LOCK(
::cs_main,
return chainman.m_blockman.LookupBlockIndex(block->GetHash()))};
108template <
bool INVALID>
120 Assert(!chainman.ActiveChainstate().m_from_snapshot_blockhash);
129 auto msg_start = chainman.GetParams().MessageStart();
142 for (
const auto& block : *
g_chain) {
166 auto msg_start = chainman.GetParams().MessageStart();
170 }
catch (
const std::ios_base::failure&) {
179 for (
const auto& block : *
g_chain) {
181 bool processed{chainman.ProcessNewBlockHeaders({{*block}},
true, dummy)};
183 const auto* index{
WITH_LOCK(
::cs_main,
return chainman.m_blockman.LookupBlockIndex(block->GetHash()))};
193 Assert(!chainman.ActiveChainstate().m_from_snapshot_blockhash->IsNull());
194 const auto&
coinscache{chainman.ActiveChainstate().CoinsTip()};
195 for (
const auto& block : *
g_chain) {
197 const auto* index{chainman.m_blockman.LookupBlockIndex(block->GetHash())};
200 if (index->nHeight == chainman.ActiveChainstate().SnapshotBase()->nHeight) {
201 auto params{chainman.GetParams().AssumeutxoForHeight(index->nHeight)};
202 Assert(params.has_value());
203 Assert(params.value().m_chain_tx_count == index->m_chain_tx_count);
205 Assert(index->m_chain_tx_count == 0);
211 Assert(!chainman.ActiveChainstate().m_from_snapshot_blockhash);
221 setup.m_node.block_template_manager.reset();
222 setup.m_node.chainman.reset();
223 setup.m_make_chainman();
224 setup.LoadVerifyActivateChainstate();
225 setup.CreateBlockTemplateManager();
const TestingSetup * g_setup
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
#define Assert(val)
Identity function.
fs::path GetDataDirNet() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get data directory path with appended network identifier.
Non-refcounted RAII wrapper for FILE*.
An outpoint - a combination of a transaction hash and an index n into its vout.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
T ConsumeIntegralInRange(T min, T max)
constexpr int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::span< const uint8_t > FuzzBufferType
FILE * fopen(const fs::path &p, const char *mode)
static std::optional< CCoinsStats > ComputeUTXOStats(T hash_obj, const CCoinsViewDB &view, node::BlockManager &blockman, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
void ObserveReachabilityGoal(bool reached, const ReachabilityGoal &goal)
Record whether a registered goal is satisfied by at least one fuzz input.
void RegisterReachabilityGoal(const ReachabilityGoal &goal)
Register a goal before executing any fuzz inputs.
void WriteCompactSize(SizeComputer &os, uint64_t nSize)
A reachability condition explicitly registered by a fuzz target.
Testing setup that configures a complete environment.
std::unique_ptr< ChainstateManager > chainman
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
SeedRandomStateForTest(SeedRand::ZEROS)
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept
COutPoint ProcessBlock(const NodeContext &node, const std::shared_ptr< CBlock > &block)
Returns the generated coin (or Null if the block was invalid).
std::vector< std::shared_ptr< CBlock > > CreateBlockChain(size_t total_height, const CChainParams ¶ms)
Create a blockchain, starting from genesis.
@ ZEROS
Seed with a compile time constant of zeros.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider