@@ -23,6 +23,7 @@ use stacks_common::types::chainstate::StacksPrivateKey;
23
23
24
24
use crate :: config:: { EventKeyType , EventObserverConfig , InitialBalance } ;
25
25
use crate :: tests:: bitcoin_regtest:: BitcoinCoreController ;
26
+ use crate :: tests:: nakamoto_integrations:: wait_for;
26
27
use crate :: tests:: neon_integrations:: {
27
28
get_account, get_chain_info, neon_integration_test_conf, next_block_and_wait, submit_tx,
28
29
test_observer, wait_for_runloop,
@@ -169,17 +170,25 @@ fn microblocks_disabled() {
169
170
submit_tx ( & http_origin, & tx) ;
170
171
171
172
// wait until just before epoch 2.5
172
- loop {
173
+ wait_for ( 120 , || {
173
174
let tip_info = get_chain_info ( & conf) ;
174
175
if tip_info. burn_block_height >= epoch_2_5 - 2 {
175
- break ;
176
+ return Ok ( true ) ;
176
177
}
177
178
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
178
- }
179
+ Ok ( false )
180
+ } )
181
+ . expect ( "Failed to wait until just before epoch 2.5" ) ;
179
182
183
+ let old_tip_info = get_chain_info ( & conf) ;
180
184
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
181
185
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
182
186
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
187
+ wait_for ( 30 , || {
188
+ let tip_info = get_chain_info ( & conf) ;
189
+ Ok ( tip_info. burn_block_height >= old_tip_info. burn_block_height + 3 )
190
+ } )
191
+ . expect ( "Failed to process block" ) ;
183
192
184
193
info ! ( "Test passed processing 2.5" ) ;
185
194
let account = get_account ( & http_origin, & spender_1_addr) ;
@@ -195,12 +204,15 @@ fn microblocks_disabled() {
195
204
let mut last_block_height = get_chain_info ( & conf) . burn_block_height ;
196
205
for _i in 0 ..5 {
197
206
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
198
- let tip_info = get_chain_info ( & conf) ;
199
- if tip_info. burn_block_height > last_block_height {
200
- last_block_height = tip_info. burn_block_height ;
201
- } else {
202
- panic ! ( "FATAL: failed to mine" ) ;
203
- }
207
+ wait_for ( 30 , || {
208
+ let tip_info = get_chain_info ( & conf) ;
209
+ if tip_info. burn_block_height > last_block_height {
210
+ last_block_height = tip_info. burn_block_height ;
211
+ return Ok ( true ) ;
212
+ }
213
+ Ok ( false )
214
+ } )
215
+ . expect ( "Failed to mine" ) ;
204
216
}
205
217
206
218
// second transaction should not have been processed!
@@ -226,12 +238,15 @@ fn microblocks_disabled() {
226
238
let mut last_block_height = get_chain_info ( & conf) . burn_block_height ;
227
239
for _i in 0 ..2 {
228
240
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
229
- let tip_info = get_chain_info ( & conf) ;
230
- if tip_info. burn_block_height > last_block_height {
231
- last_block_height = tip_info. burn_block_height ;
232
- } else {
233
- panic ! ( "FATAL: failed to mine" ) ;
234
- }
241
+ wait_for ( 30 , || {
242
+ let tip_info = get_chain_info ( & conf) ;
243
+ if tip_info. burn_block_height > last_block_height {
244
+ last_block_height = tip_info. burn_block_height ;
245
+ return Ok ( true ) ;
246
+ }
247
+ Ok ( false )
248
+ } )
249
+ . expect ( "Failed to mine" ) ;
235
250
}
236
251
237
252
let miner_nonce_after_microblock_assembly = get_account ( & http_origin, & miner_account) . nonce ;
@@ -265,12 +280,15 @@ fn microblocks_disabled() {
265
280
let mut last_block_height = get_chain_info ( & conf) . burn_block_height ;
266
281
for _i in 0 ..2 {
267
282
next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
268
- let tip_info = get_chain_info ( & conf) ;
269
- if tip_info. burn_block_height > last_block_height {
270
- last_block_height = tip_info. burn_block_height ;
271
- } else {
272
- panic ! ( "FATAL: failed to mine" ) ;
273
- }
283
+ wait_for ( 30 , || {
284
+ let tip_info = get_chain_info ( & conf) ;
285
+ if tip_info. burn_block_height > last_block_height {
286
+ last_block_height = tip_info. burn_block_height ;
287
+ return Ok ( true ) ;
288
+ }
289
+ Ok ( false )
290
+ } )
291
+ . expect ( "Failed to mine" ) ;
274
292
}
275
293
276
294
let miner_nonce_after_microblock_confirmation = get_account ( & http_origin, & miner_account) . nonce ;
0 commit comments