Skip to content

Commit 7c34901

Browse files
committed
fuzz: package_eval: move last_tx inside txn ctor
1 parent 445eaed commit 7c34901

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/test/fuzz/package_eval.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,15 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
224224

225225
std::set<COutPoint> package_outpoints;
226226
while (txs.size() < num_txs) {
227-
228-
// Last transaction in a package needs to be a child of parents to get further in validation
229-
// so the last transaction to be generated(in a >1 package) must spend all package-made outputs
230-
// Note that this test currently only spends package outputs in last transaction.
231-
bool last_tx = num_txs > 1 && txs.size() == num_txs - 1;
232-
233227
// Create transaction to add to the mempool
234228
txs.emplace_back([&] {
235229
CMutableTransaction tx_mut;
236230
tx_mut.version = CTransaction::CURRENT_VERSION;
237231
tx_mut.nLockTime = 0;
238-
// Last tx will sweep half or more of all outpoints from package
232+
// Last transaction in a package needs to be a child of parents to get further in validation
233+
// so the last transaction to be generated(in a >1 package) must spend all package-made outputs
234+
// Note that this test currently only spends package outputs in last transaction.
235+
bool last_tx = num_txs > 1 && txs.size() == num_txs - 1;
239236
const auto num_in = outpoint_to_rbf ? 2 :
240237
last_tx ? fuzzed_data_provider.ConsumeIntegralInRange<int>(package_outpoints.size()/2 + 1, package_outpoints.size()) :
241238
fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 4);
@@ -377,18 +374,15 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
377374
const auto num_txs = (size_t) fuzzed_data_provider.ConsumeIntegralInRange<int>(1, 26);
378375
std::set<COutPoint> package_outpoints;
379376
while (txs.size() < num_txs) {
380-
381-
// Last transaction in a package needs to be a child of parents to get further in validation
382-
// so the last transaction to be generated(in a >1 package) must spend all package-made outputs
383-
// Note that this test currently only spends package outputs in last transaction.
384-
bool last_tx = num_txs > 1 && txs.size() == num_txs - 1;
385-
386377
// Create transaction to add to the mempool
387378
txs.emplace_back([&] {
388379
CMutableTransaction tx_mut;
389380
tx_mut.version = fuzzed_data_provider.ConsumeBool() ? TRUC_VERSION : CTransaction::CURRENT_VERSION;
390381
tx_mut.nLockTime = fuzzed_data_provider.ConsumeBool() ? 0 : fuzzed_data_provider.ConsumeIntegral<uint32_t>();
391-
// Last tx will sweep all outpoints in package
382+
// Last transaction in a package needs to be a child of parents to get further in validation
383+
// so the last transaction to be generated(in a >1 package) must spend all package-made outputs
384+
// Note that this test currently only spends package outputs in last transaction.
385+
bool last_tx = num_txs > 1 && txs.size() == num_txs - 1;
392386
const auto num_in = last_tx ? package_outpoints.size() : fuzzed_data_provider.ConsumeIntegralInRange<int>(1, mempool_outpoints.size());
393387
auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, mempool_outpoints.size() * 2);
394388

0 commit comments

Comments
 (0)