8#include <chainparams.h>
42#include <boost/multi_index/detail/hash_index_iterator.hpp>
68 std::shared_ptr<CBlock> block;
85 prefilledtxn.erase(prefilledtxn.begin());
90 shorttxids.insert(shorttxids.begin(),
shorttxid);
95 shorttxids.erase(shorttxids.begin() + index);
99 return prefilledtxn.size();
103 return shorttxids.size();
121 testing_setup->m_node.validation_signals = std::make_unique<ValidationSignals>(std::make_unique<ImmediateBackgroundTaskRunner>());
136 auto& mempool = *
setup->m_node.mempool;
139 chainman.DisableNextWrite();
145 mempool, *
setup->m_node.warnings,
147 .deterministic_rng = true,
149 connman.SetMsgProc(peerman.get());
151 setup->m_node.validation_signals->RegisterValidationInterface(peerman.get());
152 setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
156 std::vector<CNode*> peers;
157 for (
int i = 0; i < 4; ++i) {
165 std::vector<BlockInfo> info;
180 unsigned long mempool_size = mempool.size();
225 prev = chainman.ActiveChain().Tip()->GetBlockHash();
226 height = chainman.ActiveChain().Height() + 1;
229 prev = info[index].hash;
230 height = info[index].height + 1;
242 std::shared_ptr<CBlock> block = std::make_shared<CBlock>();
254 const auto mempool_size = mempool.size();
270 for (
size_t i = 0; i <
new_txns; ++i) {
277 chainman.GenerateCoinbaseCommitment(*block,
pindexPrev);
302 std::shared_ptr<CBlock>
cblock;
306 size_t index = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, info.size() - 1);
307 cblock = info[index].block;
309 BlockInfo block_info = create_block();
310 cblock = block_info.block;
311 info.push_back(block_info);
327 for (
size_t i = 0; i <
num_txs; ++i) {
373 for (
size_t i = 0; i <
cblock->vtx.size(); i++) {
391 CBlock block = *info[index].block;
446 std::vector<CNodeStats> stats;
447 connman.GetNodeStats(stats);
452 if (
stat.m_bip152_highbandwidth_to) {
468 setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
469 setup->m_node.validation_signals->UnregisterAllValidationInterfaces();
int64_t CAmount
Amount in satoshis (Can be negative)
constexpr CAmount COIN
The amount of satoshis in one BTC.
const TestingSetup * g_setup
const CChainParams & Params()
Return the currently selected parameters.
Stochastic address manager.
CBlockHeaderAndShortTxIDs()=default
Dummy for deserialization.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
const CBlock & GenesisBlock() const
Information about a peer.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
static constexpr uint32_t CURRENT_VERSION
An input of a transaction.
CScriptWitness scriptWitness
Only serialized through CTransaction.
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Helper to initialize the global MockableSteadyClock, let a duration elapse, and reset it after use in...
T ConsumeIntegralInRange(T min, T max)
static Mutex g_msgproc_mutex
Mutex for anything that is only accessed via the msg processing thread.
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, node::Warnings &warnings, Options opts)
void resize(size_type new_size)
void push_back(const T &value)
static const uint256 ZERO
void MakeRandDeterministicDANGEROUS(const uint256 &seed) noexcept
Internal function to set g_determinstic_rng.
void initialize_cmpctblock()
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
CSerializedNetMsg Make(std::string msg_type, Args &&... args)
constexpr const char * HEADERS
The headers message sends one or more block headers to a node which previously requested certain head...
constexpr const char * CMPCTBLOCK
Contains a CBlockHeaderAndShortTxIDs object - providing a header and list of "short txids".
constexpr const char * BLOCKTXN
Contains a BlockTransactions.
constexpr const char * SENDCMPCT
Contains a 1-byte bool and 8-byte LE version number.
constexpr const char * TX
The tx message transmits a single transaction.
constexpr uint64_t CMPCTBLOCKS_VERSION
The compactblocks version we support.
constexpr TransactionSerParams TX_WITH_WITNESS
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
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.
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
void Reset()
Reset the internal state.
A reachability condition explicitly registered by a fuzz target.
void ResetIbd()
Reset the ibd cache to its initial state.
Testing setup that configures a complete environment.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
SeedRandomStateForTest(SeedRand::ZEROS)
void FillNode(FuzzedDataProvider &fuzzed_data_provider, ConnmanTestMsg &connman, CNode &node) noexcept
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, FakeSteadyClock &clock, const std::optional< NodeId > &node_id_in=std::nullopt)
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
uint32_t ConsumeSequence(FuzzedDataProvider &fuzzed_data_provider) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
void FinalizeHeader(CBlockHeader &header, const ChainstateManager &chainman)
@ ZEROS
Seed with a compile time constant of zeros.
static const std::vector< uint8_t > WITNESS_STACK_ELEM_OP_TRUE
static const CScript P2WSH_OP_TRUE
std::vector< std::pair< COutPoint, CAmount > > ResetChainmanAndMempool(TestingSetup &setup, FakeNodeClock &node_clock, const ResetOptions &opts)
constexpr decltype(CTransaction::version) TRUC_VERSION
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider