6
6
7
7
from decimal import Decimal
8
8
9
- from test_framework .blocktools import COINBASE_MATURITY
10
9
from test_framework .p2p import P2PTxInvStore
11
10
from test_framework .test_framework import BitcoinTestFramework
12
11
from test_framework .util import (
13
12
assert_equal ,
14
13
assert_fee_amount ,
15
14
assert_greater_than ,
16
15
assert_raises_rpc_error ,
17
- create_lots_of_big_transactions ,
18
- gen_return_txouts ,
16
+ fill_mempool ,
19
17
)
20
18
from test_framework .wallet import (
21
19
COIN ,
@@ -34,48 +32,6 @@ def set_test_params(self):
34
32
]]
35
33
self .supports_cli = False
36
34
37
- def fill_mempool (self ):
38
- """Fill mempool until eviction."""
39
- self .log .info ("Fill the mempool until eviction is triggered and the mempoolminfee rises" )
40
- txouts = gen_return_txouts ()
41
- node = self .nodes [0 ]
42
- miniwallet = self .wallet
43
- relayfee = node .getnetworkinfo ()['relayfee' ]
44
-
45
- tx_batch_size = 1
46
- num_of_batches = 75
47
- # Generate UTXOs to flood the mempool
48
- # 1 to create a tx initially that will be evicted from the mempool later
49
- # 75 transactions each with a fee rate higher than the previous one
50
- self .generate (miniwallet , 1 + (num_of_batches * tx_batch_size ))
51
-
52
- # Mine 99 blocks so that the UTXOs are allowed to be spent
53
- self .generate (node , COINBASE_MATURITY - 1 )
54
-
55
- self .log .debug ("Create a mempool tx that will be evicted" )
56
- tx_to_be_evicted_id = miniwallet .send_self_transfer (from_node = node , fee_rate = relayfee )["txid" ]
57
-
58
- # Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
59
- # The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
60
- # by 130 should result in a fee that corresponds to 2x of that fee rate
61
- base_fee = relayfee * 130
62
-
63
- self .log .debug ("Fill up the mempool with txs with higher fee rate" )
64
- with node .assert_debug_log (["rolling minimum fee bumped" ]):
65
- for batch_of_txid in range (num_of_batches ):
66
- fee = (batch_of_txid + 1 ) * base_fee
67
- create_lots_of_big_transactions (miniwallet , node , fee , tx_batch_size , txouts )
68
-
69
- self .log .debug ("The tx should be evicted by now" )
70
- # The number of transactions created should be greater than the ones present in the mempool
71
- assert_greater_than (tx_batch_size * num_of_batches , len (node .getrawmempool ()))
72
- # Initial tx created should not be present in the mempool anymore as it had a lower fee rate
73
- assert tx_to_be_evicted_id not in node .getrawmempool ()
74
-
75
- self .log .debug ("Check that mempoolminfee is larger than minrelaytxfee" )
76
- assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
77
- assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
78
-
79
35
def test_rbf_carveout_disallowed (self ):
80
36
node = self .nodes [0 ]
81
37
@@ -137,7 +93,7 @@ def test_mid_package_eviction(self):
137
93
assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
138
94
assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
139
95
140
- self . fill_mempool ()
96
+ fill_mempool (self , node , self . wallet )
141
97
current_info = node .getmempoolinfo ()
142
98
mempoolmin_feerate = current_info ["mempoolminfee" ]
143
99
@@ -227,7 +183,7 @@ def test_mid_package_replacement(self):
227
183
assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
228
184
assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
229
185
230
- self . fill_mempool ()
186
+ fill_mempool (self , node , self . wallet )
231
187
current_info = node .getmempoolinfo ()
232
188
mempoolmin_feerate = current_info ["mempoolminfee" ]
233
189
@@ -301,7 +257,7 @@ def run_test(self):
301
257
assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
302
258
assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
303
259
304
- self . fill_mempool ()
260
+ fill_mempool (self , node , self . wallet )
305
261
306
262
# Deliberately try to create a tx with a fee less than the minimum mempool fee to assert that it does not get added to the mempool
307
263
self .log .info ('Create a mempool tx that will not pass mempoolminfee' )
0 commit comments