Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_TEST_UTIL_VALIDATION_H6#define BITCOIN_TEST_UTIL_VALIDATION_H8#include <consensus/amount.h>9#include <primitives/transaction.h>10#include <util/task_runner.h>11#include <validation.h>13#include <cstddef>14#include <functional>15#include <thread>16#include <utility>17#include <vector>19namespace node {20class BlockManager;21}22class CValidationInterface;23class FakeNodeClock;24struct TestingSetup;26/// Runs callbacks synchronously and deterministically, while avoiding DEBUG_LOCKORDER false positives.27class ImmediateBackgroundTaskRunner : public util::TaskRunnerInterface28{29public:30void insert(std::function<void()> func) override { std::thread(std::move(func)).join(); }31void flush() override {}32size_t size() override { return 0; }33};35struct TestBlockManager : public node::BlockManager {36/** Test-only method to clear internal state for fuzzing */37void CleanupForFuzzing();38};40struct TestChainstateManager : public ChainstateManager {41/** Disable the next write of all chainstates */42void DisableNextWrite();43/** Reset the ibd cache to its initial state */44void ResetIbd();45/** Toggle IsInitialBlockDownload from true to false */46void JumpOutOfIbd();47/** Wrappers that avoid making chainstatemanager internals public for tests */48void InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);49void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main);50CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);51void ResetBestInvalid() EXCLUSIVE_LOCKS_REQUIRED(cs_main);52};54class ValidationInterfaceTest55{56public:57static void BlockConnected(58const kernel::ChainstateRole& role,59CValidationInterface& obj,60const std::shared_ptr<const CBlock>& block,61const CBlockIndex* pindex);62};64std::vector<std::pair<COutPoint, CAmount>> ResetChainmanAndMempool(TestingSetup& setup, FakeNodeClock& node_clock);66#endif // BITCOIN_TEST_UTIL_VALIDATION_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.