Skip to content

Commit 47fd98b

Browse files
committed
Fix comments
1 parent 949ea81 commit 47fd98b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

mempool/src/pool/tx_pool/tests/utils.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,22 @@ pub fn generate_transaction_graph(
279279
let mut total = 0u128;
280280
let mut amts = Vec::new();
281281

282-
for _ in 0..n_inputs {
282+
// the number is chosen to avoid generating empty range below
283+
let min_valid_total_amount = 2;
284+
285+
let mut input_count = 0;
286+
while input_count < n_inputs || total < estimated_fee.into_atoms() + min_valid_total_amount
287+
{
283288
let (outpt, amt) = utxos.swap_remove(rng.gen_range(0..utxos.len()));
284289
total += amt;
285290
builder = builder.add_input(outpt, empty_witness(rng));
291+
input_count += 1;
286292
}
287293

288-
total = total.checked_sub(estimated_fee.into_atoms())?;
289-
290294
for _ in 0..n_outputs {
295+
if total < min_valid_total_amount {
296+
break;
297+
}
291298
let amt = rng.gen_range((total / 2)..(95 * total / 100));
292299
total -= amt;
293300
builder = builder.add_output(TxOutput::Transfer(

0 commit comments

Comments
 (0)