41 return [result](
const CBlock& block, bool) {
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};
108 missing.push_back(block->vtx[i]);
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);
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
const TestingSetup * g_setup
#define Assert(val)
Identity function.
size_t BlockTxCount() const
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
bool exists(const Txid &txid) const
IsBlockMutatedFn m_check_block_mutated_mock
ReadStatus FillBlock(CBlock &block, const std::vector< CTransactionRef > &vtx_missing, bool segwit_active)
std::function< bool(const CBlock &, bool)> IsBlockMutatedFn
bool IsTxAvailable(size_t index) const
ReadStatus InitData(const CBlockHeaderAndShortTxIDs &cmpctblock, const std::vector< std::pair< Wtxid, CTransactionRef > > &extra_txn)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
PartiallyDownloadedBlock::IsBlockMutatedFn FuzzedIsBlockMutated(bool result)
static constexpr TransactionSerParams TX_WITH_WITNESS
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
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
std::optional< T > ConsumeDeserializable(FuzzedDataProvider &fuzzed_data_provider, const P ¶ms, const std::optional< size_t > &max_length=std::nullopt) 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.