66
77from decimal import Decimal
88
9- from test_framework .blocktools import COINBASE_MATURITY
109from test_framework .p2p import P2PTxInvStore
1110from test_framework .test_framework import BitcoinTestFramework
1211from test_framework .util import (
1312 assert_equal ,
1413 assert_fee_amount ,
1514 assert_greater_than ,
1615 assert_raises_rpc_error ,
17- create_lots_of_big_transactions ,
18- gen_return_txouts ,
16+ fill_mempool ,
1917)
2018from test_framework .wallet import (
2119 COIN ,
@@ -34,48 +32,6 @@ def set_test_params(self):
3432 ]]
3533 self .supports_cli = False
3634
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-
7935 def test_rbf_carveout_disallowed (self ):
8036 node = self .nodes [0 ]
8137
@@ -137,7 +93,7 @@ def test_mid_package_eviction(self):
13793 assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
13894 assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
13995
140- self . fill_mempool ()
96+ fill_mempool (self , node , self . wallet )
14197 current_info = node .getmempoolinfo ()
14298 mempoolmin_feerate = current_info ["mempoolminfee" ]
14399
@@ -227,7 +183,7 @@ def test_mid_package_replacement(self):
227183 assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
228184 assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
229185
230- self . fill_mempool ()
186+ fill_mempool (self , node , self . wallet )
231187 current_info = node .getmempoolinfo ()
232188 mempoolmin_feerate = current_info ["mempoolminfee" ]
233189
@@ -301,7 +257,7 @@ def run_test(self):
301257 assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
302258 assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
303259
304- self . fill_mempool ()
260+ fill_mempool (self , node , self . wallet )
305261
306262 # 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
307263 self .log .info ('Create a mempool tx that will not pass mempoolminfee' )
0 commit comments