mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
fuzz: Fix txorphan timeout by limiting block weight
Github-Pull: #35289
Rebased-From: 004a7e3cfb
This commit is contained in:
@@ -196,9 +196,13 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
|
||||
[&] {
|
||||
// Make a block out of txs and then EraseForBlock
|
||||
CBlock block;
|
||||
int64_t block_weight{0};
|
||||
int num_txs = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 1000);
|
||||
for (int i{0}; i < num_txs; ++i) {
|
||||
auto& tx_to_remove = PickValue(fuzzed_data_provider, tx_history);
|
||||
const auto tx_weight = GetTransactionWeight(*tx_to_remove);
|
||||
if (block_weight + tx_weight > MAX_BLOCK_WEIGHT) break;
|
||||
block_weight += tx_weight;
|
||||
block.vtx.push_back(tx_to_remove);
|
||||
}
|
||||
orphanage->EraseForBlock(block);
|
||||
|
||||
Reference in New Issue
Block a user