1414 create_lots_of_big_transactions ,
1515 gen_return_txouts ,
1616)
17+ from .wallet import (
18+ MiniWallet ,
19+ )
1720
1821
19- def fill_mempool (test_framework , node , miniwallet ):
22+ def fill_mempool (test_framework , node ):
2023 """Fill mempool until eviction.
2124
2225 Allows for simpler testing of scenarios with floating mempoolminfee > minrelay
@@ -25,8 +28,8 @@ def fill_mempool(test_framework, node, miniwallet):
2528 It will not ensure mempools become synced as it
2629 is based on a single node and assumes -minrelaytxfee
2730 is 1 sat/vbyte.
28- To avoid unintentional tx dependencies, it is recommended to use separate miniwallets for
29- mempool filling vs transactions in tests .
31+ To avoid unintentional tx dependencies, the mempool filling txs are created with a
32+ tagged ephemeral miniwallet instance .
3033 """
3134 test_framework .log .info ("Fill the mempool until eviction is triggered and the mempoolminfee rises" )
3235 txouts = gen_return_txouts ()
@@ -39,19 +42,20 @@ def fill_mempool(test_framework, node, miniwallet):
3942 # Generate UTXOs to flood the mempool
4043 # 1 to create a tx initially that will be evicted from the mempool later
4144 # 75 transactions each with a fee rate higher than the previous one
42- test_framework .generate (miniwallet , 1 + (num_of_batches * tx_batch_size ))
45+ ephemeral_miniwallet = MiniWallet (node , tag_name = "fill_mempool_ephemeral_wallet" )
46+ test_framework .generate (ephemeral_miniwallet , 1 + num_of_batches * tx_batch_size )
4347
4448 # Mine enough blocks so that the UTXOs are allowed to be spent
4549 test_framework .generate (node , COINBASE_MATURITY - 1 )
4650
4751 # Get all UTXOs up front to ensure none of the transactions spend from each other, as that may
4852 # change their effective feerate and thus the order in which they are selected for eviction.
49- confirmed_utxos = [miniwallet .get_utxo (confirmed_only = True ) for _ in range (num_of_batches * tx_batch_size + 1 )]
53+ confirmed_utxos = [ephemeral_miniwallet .get_utxo (confirmed_only = True ) for _ in range (num_of_batches * tx_batch_size + 1 )]
5054 assert_equal (len (confirmed_utxos ), num_of_batches * tx_batch_size + 1 )
5155
5256 test_framework .log .debug ("Create a mempool tx that will be evicted" )
53- tx_to_be_evicted_id = miniwallet .send_self_transfer (from_node = node , utxo_to_spend = confirmed_utxos [ 0 ], fee_rate = relayfee )[ "txid" ]
54- del confirmed_utxos [ 0 ]
57+ tx_to_be_evicted_id = ephemeral_miniwallet .send_self_transfer (
58+ from_node = node , utxo_to_spend = confirmed_utxos . pop ( 0 ), fee_rate = relayfee )[ "txid" ]
5559
5660 # Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
5761 # The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
@@ -63,7 +67,7 @@ def fill_mempool(test_framework, node, miniwallet):
6367 for batch_of_txid in range (num_of_batches ):
6468 fee = (batch_of_txid + 1 ) * base_fee
6569 utxos = confirmed_utxos [:tx_batch_size ]
66- create_lots_of_big_transactions (miniwallet , node , fee , tx_batch_size , txouts , utxos )
70+ create_lots_of_big_transactions (ephemeral_miniwallet , node , fee , tx_batch_size , txouts , utxos )
6771 del confirmed_utxos [:tx_batch_size ]
6872
6973 test_framework .log .debug ("The tx should be evicted by now" )
0 commit comments