@@ -34,51 +34,65 @@ def set_test_params(self):
3434 ]]
3535 self .supports_cli = False
3636
37- def run_test (self ):
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" )
3840 txouts = gen_return_txouts ()
3941 node = self .nodes [0 ]
40- miniwallet = MiniWallet ( node )
42+ miniwallet = self . wallet
4143 relayfee = node .getnetworkinfo ()['relayfee' ]
4244
43- self .log .info ('Check that mempoolminfee is minrelaytxfee' )
44- assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
45- assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
46-
4745 tx_batch_size = 1
4846 num_of_batches = 75
4947 # Generate UTXOs to flood the mempool
5048 # 1 to create a tx initially that will be evicted from the mempool later
51- # 3 batches of multiple transactions with a fee rate much higher than the previous UTXO
49+ # 75 transactions each with a fee rate higher than the previous one
5250 # And 1 more to verify that this tx does not get added to the mempool with a fee rate less than the mempoolminfee
5351 # And 2 more for the package cpfp test
54- self .generate (miniwallet , 1 + (num_of_batches * tx_batch_size ) + 1 + 2 )
52+ self .generate (miniwallet , 1 + (num_of_batches * tx_batch_size ))
5553
5654 # Mine 99 blocks so that the UTXOs are allowed to be spent
5755 self .generate (node , COINBASE_MATURITY - 1 )
5856
59- self .log .info ( ' Create a mempool tx that will be evicted' )
57+ self .log .debug ( " Create a mempool tx that will be evicted" )
6058 tx_to_be_evicted_id = miniwallet .send_self_transfer (from_node = node , fee_rate = relayfee )["txid" ]
6159
6260 # Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
6361 # The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
6462 # by 130 should result in a fee that corresponds to 2x of that fee rate
6563 base_fee = relayfee * 130
6664
67- self .log .info ("Fill up the mempool with txs with higher fee rate" )
68- for batch_of_txid in range (num_of_batches ):
69- fee = (batch_of_txid + 1 ) * base_fee
70- create_lots_of_big_transactions (miniwallet , node , fee , tx_batch_size , txouts )
65+ self .log .debug ("Fill up the mempool with txs with higher fee rate" )
66+ with node .assert_debug_log (["rolling minimum fee bumped" ]):
67+ for batch_of_txid in range (num_of_batches ):
68+ fee = (batch_of_txid + 1 ) * base_fee
69+ create_lots_of_big_transactions (miniwallet , node , fee , tx_batch_size , txouts )
7170
72- self .log .info ( ' The tx should be evicted by now' )
71+ self .log .debug ( " The tx should be evicted by now" )
7372 # The number of transactions created should be greater than the ones present in the mempool
7473 assert_greater_than (tx_batch_size * num_of_batches , len (node .getrawmempool ()))
7574 # Initial tx created should not be present in the mempool anymore as it had a lower fee rate
7675 assert tx_to_be_evicted_id not in node .getrawmempool ()
7776
78- self .log .info ( ' Check that mempoolminfee is larger than minrelaytxfee' )
77+ self .log .debug ( " Check that mempoolminfee is larger than minrelaytxfee" )
7978 assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
8079 assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
8180
81+ def run_test (self ):
82+ node = self .nodes [0 ]
83+ self .wallet = MiniWallet (node )
84+ miniwallet = self .wallet
85+
86+ # Generate coins needed to create transactions in the subtests (excluding coins used in fill_mempool).
87+ self .generate (miniwallet , 10 )
88+
89+ relayfee = node .getnetworkinfo ()['relayfee' ]
90+ self .log .info ('Check that mempoolminfee is minrelaytxfee' )
91+ assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
92+ assert_equal (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
93+
94+ self .fill_mempool ()
95+
8296 # 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
8397 self .log .info ('Create a mempool tx that will not pass mempoolminfee' )
8498 assert_raises_rpc_error (- 26 , "mempool min fee not met" , miniwallet .send_self_transfer , from_node = node , fee_rate = relayfee )
0 commit comments