@@ -212,48 +212,36 @@ def transact_and_mine(self, numblocks, mining_node):
212212 newmem .append (utx )
213213 self .memutxo = newmem
214214
215- def run_test (self ):
216- self .log .info ("This test is time consuming, please be patient" )
217- self .log .info ("Splitting inputs so we can generate tx's" )
218-
219- # Start node0
220- self .start_node (0 )
215+ def initial_split (self , node ):
216+ """Split two coinbase UTxOs into many small coins"""
221217 self .txouts = []
222218 self .txouts2 = []
223219 # Split a coinbase into two transaction puzzle outputs
224- split_inputs (self . nodes [ 0 ], self . nodes [ 0 ] .listunspent (0 ), self .txouts , True )
220+ split_inputs (node , node .listunspent (0 ), self .txouts , True )
225221
226222 # Mine
227- while len (self . nodes [ 0 ] .getrawmempool ()) > 0 :
228- self .generate (self . nodes [ 0 ] , 1 )
223+ while len (node .getrawmempool ()) > 0 :
224+ self .generate (node , 1 )
229225
230226 # Repeatedly split those 2 outputs, doubling twice for each rep
231227 # Use txouts to monitor the available utxo, since these won't be tracked in wallet
232228 reps = 0
233229 while reps < 5 :
234230 # Double txouts to txouts2
235231 while len (self .txouts ) > 0 :
236- split_inputs (self . nodes [ 0 ] , self .txouts , self .txouts2 )
237- while len (self . nodes [ 0 ] .getrawmempool ()) > 0 :
238- self .generate (self . nodes [ 0 ] , 1 )
232+ split_inputs (node , self .txouts , self .txouts2 )
233+ while len (node .getrawmempool ()) > 0 :
234+ self .generate (node , 1 )
239235 # Double txouts2 to txouts
240236 while len (self .txouts2 ) > 0 :
241- split_inputs (self . nodes [ 0 ] , self .txouts2 , self .txouts )
242- while len (self . nodes [ 0 ] .getrawmempool ()) > 0 :
243- self .generate (self . nodes [ 0 ] , 1 )
237+ split_inputs (node , self .txouts2 , self .txouts )
238+ while len (node .getrawmempool ()) > 0 :
239+ self .generate (node , 1 )
244240 reps += 1
245- self .log .info ("Finished splitting" )
246-
247- # Now we can connect the other nodes, didn't want to connect them earlier
248- # so the estimates would not be affected by the splitting transactions
249- self .start_node (1 )
250- self .start_node (2 )
251- self .connect_nodes (1 , 0 )
252- self .connect_nodes (0 , 2 )
253- self .connect_nodes (2 , 1 )
254-
255- self .sync_all ()
256241
242+ def sanity_check_estimates_range (self ):
243+ """Populate estimation buckets, assert estimates are in a sane range and
244+ are strictly increasing as the target decreases."""
257245 self .fees_per_kb = []
258246 self .memutxo = []
259247 self .confutxo = self .txouts # Start with the set of confirmed txouts after splitting
@@ -279,12 +267,36 @@ def run_test(self):
279267 self .log .info ("Final estimates after emptying mempools" )
280268 check_estimates (self .nodes [1 ], self .fees_per_kb )
281269
282- # check that the effective feerate is greater than or equal to the mempoolminfee even for high mempoolminfee
283- self .log .info ("Test fee rate estimation after restarting node with high MempoolMinFee" )
270+ def test_feerate_mempoolminfee (self ):
284271 high_val = 3 * self .nodes [1 ].estimatesmartfee (1 )['feerate' ]
285272 self .restart_node (1 , extra_args = [f'-minrelaytxfee={ high_val } ' ])
286273 check_estimates (self .nodes [1 ], self .fees_per_kb )
287274
275+ def run_test (self ):
276+ self .log .info ("This test is time consuming, please be patient" )
277+ self .log .info ("Splitting inputs so we can generate tx's" )
278+
279+ # Split two coinbases into many small utxos
280+ self .start_node (0 )
281+ self .initial_split (self .nodes [0 ])
282+ self .log .info ("Finished splitting" )
283+
284+ # Now we can connect the other nodes, didn't want to connect them earlier
285+ # so the estimates would not be affected by the splitting transactions
286+ self .start_node (1 )
287+ self .start_node (2 )
288+ self .connect_nodes (1 , 0 )
289+ self .connect_nodes (0 , 2 )
290+ self .connect_nodes (2 , 1 )
291+ self .sync_all ()
292+
293+ self .log .info ("Testing estimates with single transactions." )
294+ self .sanity_check_estimates_range ()
295+
296+ # check that the effective feerate is greater than or equal to the mempoolminfee even for high mempoolminfee
297+ self .log .info ("Test fee rate estimation after restarting node with high MempoolMinFee" )
298+ self .test_feerate_mempoolminfee ()
299+
288300 self .log .info ("Testing that fee estimation is disabled in blocksonly." )
289301 self .restart_node (0 , ["-blocksonly" ])
290302 assert_raises_rpc_error (- 32603 , "Fee estimation disabled" ,
0 commit comments