File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
mempool/src/pool/tx_pool/tests Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -279,15 +279,22 @@ pub fn generate_transaction_graph(
279
279
let mut total = 0u128 ;
280
280
let mut amts = Vec :: new ( ) ;
281
281
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
+ {
283
288
let ( outpt, amt) = utxos. swap_remove ( rng. gen_range ( 0 ..utxos. len ( ) ) ) ;
284
289
total += amt;
285
290
builder = builder. add_input ( outpt, empty_witness ( rng) ) ;
291
+ input_count += 1 ;
286
292
}
287
293
288
- total = total. checked_sub ( estimated_fee. into_atoms ( ) ) ?;
289
-
290
294
for _ in 0 ..n_outputs {
295
+ if total < min_valid_total_amount {
296
+ break ;
297
+ }
291
298
let amt = rng. gen_range ( ( total / 2 ) ..( 95 * total / 100 ) ) ;
292
299
total -= amt;
293
300
builder = builder. add_output ( TxOutput :: Transfer (
You can’t perform that action at this time.
0 commit comments