Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove potential flaky points in microblocks_disabled #5265

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 40 additions & 22 deletions testnet/stacks-node/src/tests/epoch_25.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use stacks_common::types::chainstate::StacksPrivateKey;

use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
use crate::tests::bitcoin_regtest::BitcoinCoreController;
use crate::tests::nakamoto_integrations::wait_for;
use crate::tests::neon_integrations::{
get_account, get_chain_info, neon_integration_test_conf, next_block_and_wait, submit_tx,
test_observer, wait_for_runloop,
Expand Down Expand Up @@ -169,17 +170,25 @@ fn microblocks_disabled() {
submit_tx(&http_origin, &tx);

// wait until just before epoch 2.5
loop {
wait_for(30, || {
jferrant marked this conversation as resolved.
Show resolved Hide resolved
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height >= epoch_2_5 - 2 {
break;
if tip_info.burn_block_height >= epoch_2_1 - 2 {
jferrant marked this conversation as resolved.
Show resolved Hide resolved
return Ok(true);
}
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
}
Ok(false)
})
.expect("Failed to wait until just before epoch 2.5");

let old_tip_info = get_chain_info(&conf);
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
wait_for(30, || {
let tip_info = get_chain_info(&conf);
Ok(tip_info.burn_block_height >= old_tip_info.burn_block_height + 3)
})
jferrant marked this conversation as resolved.
Show resolved Hide resolved
.expect("Failed to process block");

info!("Test passed processing 2.5");
let account = get_account(&http_origin, &spender_1_addr);
Expand All @@ -195,12 +204,15 @@ fn microblocks_disabled() {
let mut last_block_height = get_chain_info(&conf).burn_block_height;
for _i in 0..5 {
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
} else {
panic!("FATAL: failed to mine");
}
wait_for(30, || {
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
return Ok(true);
}
Ok(false)
})
.expect("Failed to mine");
}

// second transaction should not have been processed!
Expand All @@ -226,12 +238,15 @@ fn microblocks_disabled() {
let mut last_block_height = get_chain_info(&conf).burn_block_height;
for _i in 0..2 {
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
} else {
panic!("FATAL: failed to mine");
}
wait_for(30, || {
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
return Ok(true);
}
Ok(false)
})
.expect("Failed to mine");
}

let miner_nonce_after_microblock_assembly = get_account(&http_origin, &miner_account).nonce;
Expand Down Expand Up @@ -265,12 +280,15 @@ fn microblocks_disabled() {
let mut last_block_height = get_chain_info(&conf).burn_block_height;
for _i in 0..2 {
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
} else {
panic!("FATAL: failed to mine");
}
wait_for(30, || {
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height > last_block_height {
last_block_height = tip_info.burn_block_height;
return Ok(true);
}
Ok(false)
})
.expect("Failed to mine");
}

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