Skip to content

Commit 18c3741

Browse files
authored
Merge pull request #5265 from stacks-network/chore/fix-microblocks-disabled
Remove potential flaky points in microblocks_disabled
2 parents 5e6c689 + 66904cc commit 18c3741

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

testnet/stacks-node/src/tests/epoch_25.rs

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use stacks_common::types::chainstate::StacksPrivateKey;
2323

2424
use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
2525
use crate::tests::bitcoin_regtest::BitcoinCoreController;
26+
use crate::tests::nakamoto_integrations::wait_for;
2627
use crate::tests::neon_integrations::{
2728
get_account, get_chain_info, neon_integration_test_conf, next_block_and_wait, submit_tx,
2829
test_observer, wait_for_runloop,
@@ -169,17 +170,25 @@ fn microblocks_disabled() {
169170
submit_tx(&http_origin, &tx);
170171

171172
// wait until just before epoch 2.5
172-
loop {
173+
wait_for(120, || {
173174
let tip_info = get_chain_info(&conf);
174175
if tip_info.burn_block_height >= epoch_2_5 - 2 {
175-
break;
176+
return Ok(true);
176177
}
177178
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");
179182

183+
let old_tip_info = get_chain_info(&conf);
180184
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
181185
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
182186
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");
183192

184193
info!("Test passed processing 2.5");
185194
let account = get_account(&http_origin, &spender_1_addr);
@@ -195,12 +204,15 @@ fn microblocks_disabled() {
195204
let mut last_block_height = get_chain_info(&conf).burn_block_height;
196205
for _i in 0..5 {
197206
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");
204216
}
205217

206218
// second transaction should not have been processed!
@@ -226,12 +238,15 @@ fn microblocks_disabled() {
226238
let mut last_block_height = get_chain_info(&conf).burn_block_height;
227239
for _i in 0..2 {
228240
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");
235250
}
236251

237252
let miner_nonce_after_microblock_assembly = get_account(&http_origin, &miner_account).nonce;
@@ -265,12 +280,15 @@ fn microblocks_disabled() {
265280
let mut last_block_height = get_chain_info(&conf).burn_block_height;
266281
for _i in 0..2 {
267282
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");
274292
}
275293

276294
let miner_nonce_after_microblock_confirmation = get_account(&http_origin, &miner_account).nonce;

0 commit comments

Comments
 (0)