36 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
42 return [result](
const CBlock& block, bool) {
54 if (!block || block->vtx.size() == 0 ||
55 block->vtx.size() >= std::numeric_limits<uint16_t>::max()) {
67 std::set<uint16_t> available;
71 std::vector<std::pair<Wtxid, CTransactionRef>> extra_txn;
72 for (
size_t i = 1; i < block->vtx.size(); ++i) {
73 auto tx{block->vtx[i]};
78 if (add_to_extra_txn) {
79 extra_txn.emplace_back(tx->GetWitnessHash(), tx);
83 if (add_to_mempool && !pool.exists(tx->GetHash())) {
90 auto init_status{pdb.InitData(cmpctblock, extra_txn)};
92 std::vector<CTransactionRef> missing;
95 bool skipped_missing{
false};
96 for (
size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
104 assert(!pdb.IsTxAvailable(i) || available.contains(i));
108 if (!pdb.IsTxAvailable(i) && !skip) {
109 missing.push_back(block->vtx[i]);
112 skipped_missing |= (!pdb.IsTxAvailable(i) && skip);
121 CBlock reconstructed_block;
122 auto fill_status{pdb.FillBlock(reconstructed_block, missing, segwit_active)};
123 switch (fill_status) {
126 assert(!fail_block_mutated);
130 assert(fail_block_mutated);
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
const TestingSetup * g_setup
#define Assert(val)
Identity function.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
std::function< bool(const CBlock &, bool)> IsBlockMutatedFn
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
FUZZ_TARGET(partially_downloaded_block,.init=initialize_pdb)
PartiallyDownloadedBlock::IsBlockMutatedFn FuzzedIsBlockMutated(bool result)
static constexpr TransactionSerParams TX_WITH_WITNESS
Testing setup that configures a complete environment.
CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider &fuzzed_data_provider, const CTransaction &tx, uint32_t max_height) noexcept
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
FuzzedDataProvider & fuzzed_data_provider