6#include <blockfilter.h>
8#include <chainparams.h>
34#include <boost/test/unit_test.hpp>
80 m_node.
chain->context()->validation_signals->SyncWithValidationInterfaceQueue();
107 sync_index(
false, tip_height + 1, tip_height);
120 m_node.
chain->context()->validation_signals->SyncWithValidationInterfaceQueue();
133 new_block = std::make_shared<CBlock>(block);
164 std::unique_ptr<BaseIndex::DB>
m_db;
173 fs::create_directories(path);
174 m_db = std::make_unique<BaseIndex::DB>(path /
"db", 0,
true,
false);
204 auto func_wait_until = [&](
int height, std::chrono::milliseconds timeout) {
205 auto deadline = std::chrono::steady_clock::now() + timeout;
206 while (index.GetSummary().best_block_height < height) {
207 if (std::chrono::steady_clock::now() >
deadline) {
208 BOOST_FAIL(
strprintf(
"Timeout waiting for index height %d (current: %d)", height, index.GetSummary().best_block_height));
211 std::this_thread::sleep_for(100
ms);
219 std::vector<std::shared_ptr<CBlock>>
fork;
223 for (
const auto& block :
fork) {
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::function< std::unique_ptr< BaseIndex >(node::NodeContext &)> IndexFactory
static const std::vector< std::pair< std::string, IndexFactory > > INDEX_FACTORIES
BOOST_FIXTURE_TEST_CASE(baseindex_no_commit_ahead_of_flush, TestChain100Setup)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
fs::path GetDataDirNet() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get data directory path with appended network identifier.
The database stores a block locator of the chain the database is synced to so that the index can effi...
Base class for indices of blockchain data.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Serialized script, used inside transaction inputs and outputs.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
bool CustomAppend(const interfaces::BlockInfo &block) override
Write update index entries for a newly connected block.
IndexReorgCrash(std::unique_ptr< interfaces::Chain > chain, std::shared_future< void > blocker, int blocking_height, FakeNodeClock &clock)
std::unique_ptr< BaseIndex::DB > m_db
BaseIndex::DB & GetDB() const override
bool AllowPrune() const override
std::shared_future< void > m_blocker
static void BlockConnected(const kernel::ChainstateRole &role, CValidationInterface &obj, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE_END()
is a home for simple enum and struct type definitions that can be used internally by functions in the...
CKey GenerateRandomKey(bool compressed) noexcept
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Block data sent with blockConnected, blockDisconnected notifications.
Information about chainstate that notifications are sent from.
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< ChainstateManager > chainman
std::unique_ptr< interfaces::Chain > chain
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
bool BuildChain(const NodeContext &node, const CBlockIndex *pindex, const CScript &coinbase_script_pub_key, size_t length, std::vector< std::shared_ptr< CBlock > > &chain)
Build a chain of length coinbase-only blocks on top of pindex (which need not be the active tip,...
void StopIndex(BaseIndex &index, node::NodeContext &node)
Drain validation callbacks before stopping an index, matching Shutdown() in init.cpp.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
Functions for validating blocks and updating the block tree.