38 void ResetNextWrite() { m_next_write = NodeClock::time_point::max() - 1s; }
41 for (
const auto&
cs : m_chainstates) {
42 static_cast<TestChainstate&
>(*cs).ResetNextWrite();
62 const std::shared_ptr<const CBlock>& block,
76 static_cast<TestChainstate*
>(&
ActiveChainstate())->CallInvalidBlockFound(pindex, state);
88 static_cast<TestChainstate*
>(&
ActiveChainstate())->CallInvalidChainFound(pindexNew);
100 return static_cast<TestChainstate*
>(&
ActiveChainstate())->CallFindMostWorkChain();
105 m_best_invalid =
nullptr;
124 std::vector<std::pair<COutPoint, CAmount>> mature_coinbase;
130 mature_coinbase.emplace_back(prevout, subsidy);
133 return mature_coinbase;
int64_t CAmount
Amount in satoshis (Can be negative).
#define Assert(val)
Identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
An outpoint - a combination of a transaction hash and an index n into its vout.
Implement this to subscribe to events generated in validation and mempool.
virtual void BlockConnected(const kernel::ChainstateRole &role, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
Notifies listeners of a block being connected.
bool IsInitialBlockDownload() const noexcept
Check whether we are doing an initial block download (synchronizing from disk or network).
Chainstate & ActiveChainstate() const
std::atomic_bool m_cached_is_ibd
Whether initial block download (IBD) is ongoing.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
void set(NodeSeconds t)
Set mocktime.
static void BlockConnected(const kernel::ChainstateRole &role, CValidationInterface &obj, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
std::set< int > m_dirty_fileinfo
Dirty block file entries.
std::set< CBlockIndex * > m_dirty_blockindex
Dirty block index entries.
std::vector< CBlockFileInfo > m_blockfile_info
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::function< void()> m_make_chainman
void LoadVerifyActivateChainstate()
void CleanupForFuzzing()
Test-only method to clear internal state for fuzzing.
void ResetBestInvalid() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void InvalidChainFound(CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
CBlockIndex * FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void DisableNextWrite()
Disable the next write of all chainstates.
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Wrappers that avoid making chainstatemanager internals public for tests.
void JumpOutOfIbd()
Toggle IsInitialBlockDownload from true to false.
void ResetIbd()
Reset the ibd cache to its initial state.
Testing setup that configures a complete environment.
Information about chainstate that notifications are sent from.
Block template creation options.
CScript coinbase_output_script
Script to put in the coinbase transaction.
std::unique_ptr< CTxMemPool > mempool
std::unique_ptr< ChainstateManager > chainman
COutPoint MineBlock(const NodeContext &node, const node::BlockCreateOptions &assembler_options)
Returns the generated coin.
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
std::vector< std::pair< COutPoint, CAmount > > ResetChainmanAndMempool(TestingSetup &setup, FakeNodeClock &node_clock)
#define EXCLUSIVE_LOCKS_REQUIRED(...)