35 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
36 g_setup = testing_setup.get();
41 return [result](
const CBlock& block, bool) {
52 auto block{ConsumeDeserializable<CBlock>(fuzzed_data_provider,
TX_WITH_WITNESS)};
53 if (!block || block->vtx.size() == 0 ||
54 block->vtx.size() >= std::numeric_limits<uint16_t>::max()) {
66 std::set<uint16_t> available;
70 std::vector<std::pair<Wtxid, CTransactionRef>> extra_txn;
71 for (
size_t i = 1; i < block->vtx.size(); ++i) {
72 auto tx{block->vtx[i]};
74 bool add_to_extra_txn{fuzzed_data_provider.ConsumeBool()};
75 bool add_to_mempool{fuzzed_data_provider.ConsumeBool()};
77 if (add_to_extra_txn) {
78 extra_txn.emplace_back(tx->GetWitnessHash(), tx);
82 if (add_to_mempool && !pool.exists(tx->GetHash())) {
89 auto init_status{pdb.InitData(cmpctblock, extra_txn)};
91 std::vector<CTransactionRef> missing;
94 bool skipped_missing{
false};
95 for (
size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
103 assert(!pdb.IsTxAvailable(i) || available.count(i) > 0);
106 bool skip{fuzzed_data_provider.ConsumeBool()};
107 if (!pdb.IsTxAvailable(i) && !skip) {
108 missing.push_back(block->vtx[i]);
111 skipped_missing |= (!pdb.IsTxAvailable(i) && skip);
114 bool segwit_active{fuzzed_data_provider.ConsumeBool()};
117 bool fail_block_mutated{fuzzed_data_provider.ConsumeBool()};
120 CBlock reconstructed_block;
121 auto fill_status{pdb.FillBlock(reconstructed_block, missing, segwit_active)};
122 switch (fill_status) {
125 assert(!fail_block_mutated);
129 assert(fail_block_mutated);
AddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
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
int64_t 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)
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.