14
14
create_lots_of_big_transactions ,
15
15
gen_return_txouts ,
16
16
)
17
+ from .wallet import (
18
+ MiniWallet ,
19
+ )
17
20
18
21
19
- def fill_mempool (test_framework , node , miniwallet ):
22
+ def fill_mempool (test_framework , node ):
20
23
"""Fill mempool until eviction.
21
24
22
25
Allows for simpler testing of scenarios with floating mempoolminfee > minrelay
@@ -25,8 +28,8 @@ def fill_mempool(test_framework, node, miniwallet):
25
28
It will not ensure mempools become synced as it
26
29
is based on a single node and assumes -minrelaytxfee
27
30
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 .
30
33
"""
31
34
test_framework .log .info ("Fill the mempool until eviction is triggered and the mempoolminfee rises" )
32
35
txouts = gen_return_txouts ()
@@ -39,19 +42,20 @@ def fill_mempool(test_framework, node, miniwallet):
39
42
# Generate UTXOs to flood the mempool
40
43
# 1 to create a tx initially that will be evicted from the mempool later
41
44
# 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 )
43
47
44
48
# Mine enough blocks so that the UTXOs are allowed to be spent
45
49
test_framework .generate (node , COINBASE_MATURITY - 1 )
46
50
47
51
# Get all UTXOs up front to ensure none of the transactions spend from each other, as that may
48
52
# 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 )]
50
54
assert_equal (len (confirmed_utxos ), num_of_batches * tx_batch_size + 1 )
51
55
52
56
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" ]
55
59
56
60
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
57
61
# 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):
63
67
for batch_of_txid in range (num_of_batches ):
64
68
fee = (batch_of_txid + 1 ) * base_fee
65
69
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 )
67
71
del confirmed_utxos [:tx_batch_size ]
68
72
69
73
test_framework .log .debug ("The tx should be evicted by now" )
0 commit comments