@@ -120,15 +120,26 @@ def check_estimates(node, fees_seen, max_invalid, print_estimates = True):
120120 last_e = e
121121 valid_estimate = False
122122 invalid_estimates = 0
123- for e in all_estimates :
123+ for i , e in enumerate ( all_estimates ): # estimate is for i+1
124124 if e >= 0 :
125125 valid_estimate = True
126+ # estimatesmartfee should return the same result
127+ assert_equal (node .estimatesmartfee (i + 1 )["feerate" ], e )
128+
126129 else :
127130 invalid_estimates += 1
128- # Once we're at a high enough confirmation count that we can give an estimate
129- # We should have estimates for all higher confirmation counts
130- if valid_estimate and e < 0 :
131- raise AssertionError ("Invalid estimate appears at higher confirm count than valid estimate" )
131+
132+ # estimatesmartfee should still be valid
133+ approx_estimate = node .estimatesmartfee (i + 1 )["feerate" ]
134+ answer_found = node .estimatesmartfee (i + 1 )["blocks" ]
135+ assert (approx_estimate > 0 )
136+ assert (answer_found > i + 1 )
137+
138+ # Once we're at a high enough confirmation count that we can give an estimate
139+ # We should have estimates for all higher confirmation counts
140+ if valid_estimate :
141+ raise AssertionError ("Invalid estimate appears at higher confirm count than valid estimate" )
142+
132143 # Check on the expected number of different confirmation counts
133144 # that we might not have valid estimates for
134145 if invalid_estimates > max_invalid :
@@ -184,13 +195,13 @@ def setup_network(self):
184195 # NOTE: the CreateNewBlock code starts counting block size at 1,000 bytes,
185196 # (17k is room enough for 110 or so transactions)
186197 self .nodes .append (start_node (1 , self .options .tmpdir ,
187- ["-blockprioritysize=1500" , "-blockmaxsize=18000 " ,
198+ ["-blockprioritysize=1500" , "-blockmaxsize=17000 " ,
188199 "-maxorphantx=1000" , "-relaypriority=0" , "-debug=estimatefee" ]))
189200 connect_nodes (self .nodes [1 ], 0 )
190201
191202 # Node2 is a stingy miner, that
192- # produces too small blocks (room for only 70 or so transactions)
193- node2args = ["-blockprioritysize=0" , "-blockmaxsize=12000 " , "-maxorphantx=1000" , "-relaypriority=0" ]
203+ # produces too small blocks (room for only 55 or so transactions)
204+ node2args = ["-blockprioritysize=0" , "-blockmaxsize=8000 " , "-maxorphantx=1000" , "-relaypriority=0" ]
194205
195206 self .nodes .append (start_node (2 , self .options .tmpdir , node2args ))
196207 connect_nodes (self .nodes [0 ], 2 )
@@ -229,22 +240,19 @@ def run_test(self):
229240 self .fees_per_kb = []
230241 self .memutxo = []
231242 self .confutxo = self .txouts # Start with the set of confirmed txouts after splitting
232- print ("Checking estimates for 1/2/3/6/15/25 blocks" )
233- print ("Creating transactions and mining them with a huge block size" )
234- # Create transactions and mine 20 big blocks with node 0 such that the mempool is always emptied
235- self .transact_and_mine (30 , self .nodes [0 ])
236- check_estimates (self .nodes [1 ], self .fees_per_kb , 1 )
243+ print ("Will output estimates for 1/2/3/6/15/25 blocks" )
237244
238- print ("Creating transactions and mining them with a block size that can't keep up" )
239- # Create transactions and mine 30 small blocks with node 2, but create txs faster than we can mine
240- self .transact_and_mine (20 , self .nodes [2 ])
241- check_estimates (self .nodes [1 ], self .fees_per_kb , 3 )
245+ for i in xrange (2 ):
246+ print ("Creating transactions and mining them with a block size that can't keep up" )
247+ # Create transactions and mine 10 small blocks with node 2, but create txs faster than we can mine
248+ self .transact_and_mine (10 , self .nodes [2 ])
249+ check_estimates (self .nodes [1 ], self .fees_per_kb , 14 )
242250
243- print ("Creating transactions and mining them at a block size that is just big enough" )
244- # Generate transactions while mining 40 more blocks, this time with node1
245- # which mines blocks with capacity just above the rate that transactions are being created
246- self .transact_and_mine (40 , self .nodes [1 ])
247- check_estimates (self .nodes [1 ], self .fees_per_kb , 2 )
251+ print ("Creating transactions and mining them at a block size that is just big enough" )
252+ # Generate transactions while mining 10 more blocks, this time with node1
253+ # which mines blocks with capacity just above the rate that transactions are being created
254+ self .transact_and_mine (10 , self .nodes [1 ])
255+ check_estimates (self .nodes [1 ], self .fees_per_kb , 2 )
248256
249257 # Finish by mining a normal-sized block:
250258 while len (self .nodes [1 ].getrawmempool ()) > 0 :
0 commit comments