@@ -30,6 +30,12 @@ def set_test_params(self):
30
30
]] * self .num_nodes
31
31
self .supports_cli = False
32
32
33
+ def clear_prioritisation (self , node ):
34
+ for txid , info in node .getprioritisedtransactions ().items ():
35
+ delta = info ["fee_delta" ]
36
+ node .prioritisetransaction (txid , 0 , - delta )
37
+ assert_equal (node .getprioritisedtransactions (), {})
38
+
33
39
def test_replacement (self ):
34
40
self .log .info ("Test tx prioritisation stays after a tx is replaced" )
35
41
conflicting_input = self .wallet .get_utxo ()
@@ -108,6 +114,10 @@ def test_diamond(self):
108
114
prioritisation_map_in_mempool = self .nodes [0 ].getprioritisedtransactions ()
109
115
assert_equal (prioritisation_map_in_mempool [txid_b ], {"fee_delta" : fee_delta_b * COIN , "in_mempool" : True })
110
116
assert_equal (prioritisation_map_in_mempool [txid_c ], {"fee_delta" : (fee_delta_c_1 + fee_delta_c_2 )* COIN , "in_mempool" : True })
117
+ # Clear prioritisation, otherwise the transactions' fee deltas are persisted to mempool.dat and loaded again when the node
118
+ # is restarted at the end of this subtest. Deltas are removed when a transaction is mined, but only at that time. We do
119
+ # not check whether mapDeltas transactions were mined when loading from mempool.dat.
120
+ self .clear_prioritisation (node = self .nodes [0 ])
111
121
112
122
self .log .info ("Test priority while txs are not in mempool" )
113
123
self .restart_node (0 , extra_args = ["-nopersistmempool" ])
@@ -135,6 +145,7 @@ def test_diamond(self):
135
145
136
146
# Use default extra_args
137
147
self .restart_node (0 )
148
+ assert_equal (self .nodes [0 ].getprioritisedtransactions (), {})
138
149
139
150
def run_test (self ):
140
151
self .wallet = MiniWallet (self .nodes [0 ])
@@ -202,10 +213,18 @@ def run_test(self):
202
213
sizes [i ] += mempool [j ]['vsize' ]
203
214
assert sizes [i ] > MAX_BLOCK_WEIGHT // 4 # Fail => raise utxo_count
204
215
216
+ assert_equal (self .nodes [0 ].getprioritisedtransactions (), {})
205
217
# add a fee delta to something in the cheapest bucket and make sure it gets mined
206
218
# also check that a different entry in the cheapest bucket is NOT mined
207
219
self .nodes [0 ].prioritisetransaction (txid = txids [0 ][0 ], fee_delta = int (3 * base_fee * COIN ))
208
- assert_equal (self .nodes [0 ].getprioritisedtransactions ()[txids [0 ][0 ]], { "fee_delta" : 3 * base_fee * COIN , "in_mempool" : True })
220
+ assert_equal (self .nodes [0 ].getprioritisedtransactions (), {txids [0 ][0 ] : { "fee_delta" : 3 * base_fee * COIN , "in_mempool" : True }})
221
+
222
+ # Priority disappears when prioritisetransaction is called with an inverse value...
223
+ self .nodes [0 ].prioritisetransaction (txid = txids [0 ][0 ], fee_delta = int (- 3 * base_fee * COIN ))
224
+ assert txids [0 ][0 ] not in self .nodes [0 ].getprioritisedtransactions ()
225
+ # ... and reappears when prioritisetransaction is called again.
226
+ self .nodes [0 ].prioritisetransaction (txid = txids [0 ][0 ], fee_delta = int (3 * base_fee * COIN ))
227
+ assert txids [0 ][0 ] in self .nodes [0 ].getprioritisedtransactions ()
209
228
210
229
self .generate (self .nodes [0 ], 1 )
211
230
@@ -277,8 +296,8 @@ def run_test(self):
277
296
template = self .nodes [0 ].getblocktemplate ({'rules' : ['segwit' ]})
278
297
self .nodes [0 ].prioritisetransaction (txid = tx_id , fee_delta = - int (self .relayfee * COIN ))
279
298
280
- assert tx_id in self . nodes [ 0 ]. getprioritisedtransactions ()
281
- assert_equal ( self .nodes [0 ].getprioritisedtransactions ()[ tx_id ][ "fee_delta" ], 0 )
299
+ # Calling prioritisetransaction with the inverse amount should delete its prioritisation entry
300
+ assert tx_id not in self .nodes [0 ].getprioritisedtransactions ()
282
301
283
302
self .nodes [0 ].setmocktime (mock_time + 10 )
284
303
new_template = self .nodes [0 ].getblocktemplate ({'rules' : ['segwit' ]})
0 commit comments