@@ -34,51 +34,65 @@ def set_test_params(self):
34
34
]]
35
35
self .supports_cli = False
36
36
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" )
38
40
txouts = gen_return_txouts ()
39
41
node = self .nodes [0 ]
40
- miniwallet = MiniWallet ( node )
42
+ miniwallet = self . wallet
41
43
relayfee = node .getnetworkinfo ()['relayfee' ]
42
44
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
-
47
45
tx_batch_size = 1
48
46
num_of_batches = 75
49
47
# Generate UTXOs to flood the mempool
50
48
# 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
52
50
# And 1 more to verify that this tx does not get added to the mempool with a fee rate less than the mempoolminfee
53
51
# 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 ))
55
53
56
54
# Mine 99 blocks so that the UTXOs are allowed to be spent
57
55
self .generate (node , COINBASE_MATURITY - 1 )
58
56
59
- self .log .info ( ' Create a mempool tx that will be evicted' )
57
+ self .log .debug ( " Create a mempool tx that will be evicted" )
60
58
tx_to_be_evicted_id = miniwallet .send_self_transfer (from_node = node , fee_rate = relayfee )["txid" ]
61
59
62
60
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
63
61
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
64
62
# by 130 should result in a fee that corresponds to 2x of that fee rate
65
63
base_fee = relayfee * 130
66
64
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 )
71
70
72
- self .log .info ( ' The tx should be evicted by now' )
71
+ self .log .debug ( " The tx should be evicted by now" )
73
72
# The number of transactions created should be greater than the ones present in the mempool
74
73
assert_greater_than (tx_batch_size * num_of_batches , len (node .getrawmempool ()))
75
74
# Initial tx created should not be present in the mempool anymore as it had a lower fee rate
76
75
assert tx_to_be_evicted_id not in node .getrawmempool ()
77
76
78
- self .log .info ( ' Check that mempoolminfee is larger than minrelaytxfee' )
77
+ self .log .debug ( " Check that mempoolminfee is larger than minrelaytxfee" )
79
78
assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ('0.00001000' ))
80
79
assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], Decimal ('0.00001000' ))
81
80
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
+
82
96
# 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
83
97
self .log .info ('Create a mempool tx that will not pass mempoolminfee' )
84
98
assert_raises_rpc_error (- 26 , "mempool min fee not met" , miniwallet .send_self_transfer , from_node = node , fee_rate = relayfee )
0 commit comments