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

Integration test for #5400 #5411

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 1 addition & 7 deletions testnet/stacks-node/src/nakamoto_node/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,13 +1000,7 @@ impl RelayerThread {

#[cfg(test)]
fn fault_injection_skip_block_commit(&self) -> bool {
self.globals
.counters
.naka_skip_commit_op
.0
.lock()
.unwrap()
.unwrap_or(false)
self.globals.counters.naka_skip_commit_op.get()
}

#[cfg(not(test))]
Expand Down
15 changes: 14 additions & 1 deletion testnet/stacks-node/src/run_loop/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ impl Default for TestFlag {
}
}

#[cfg(test)]
impl TestFlag {
/// Set the test flag to the given value
pub fn set(&self, value: bool) {
*self.0.lock().unwrap() = Some(value);
}

/// Get the test flag value. Defaults to false if the flag is not set.
pub fn get(&self) -> bool {
self.0.lock().unwrap().unwrap_or(false)
}
}

#[derive(Clone, Default)]
pub struct Counters {
pub blocks_processed: RunLoopCounter,
Expand Down Expand Up @@ -1026,7 +1039,7 @@ impl RunLoop {
/// This function will block by looping infinitely.
/// It will start the burnchain (separate thread), set-up a channel in
/// charge of coordinating the new blocks coming from the burnchain and
/// the nodes, taking turns on tenures.
/// the nodes, taking turns on tenures.
///
/// Returns `Option<NeonGlobals>` so that data can be passed to `NakamotoNode`
pub fn start(
Expand Down
8 changes: 4 additions & 4 deletions testnet/stacks-node/src/tests/nakamoto_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4985,7 +4985,7 @@ fn forked_tenure_is_ignored() {

// Unpause the broadcast of Tenure B's block, do not submit commits, and do not allow blocks to
// be processed
test_skip_commit_op.0.lock().unwrap().replace(true);
test_skip_commit_op.set(true);
TEST_BROADCAST_STALL.lock().unwrap().replace(false);

// Wait for a stacks block to be broadcasted.
Expand Down Expand Up @@ -5038,7 +5038,7 @@ fn forked_tenure_is_ignored() {
.expect("Mutex poisoned")
.get_stacks_blocks_processed();
next_block_and(&mut btc_regtest_controller, 60, || {
test_skip_commit_op.0.lock().unwrap().replace(false);
test_skip_commit_op.set(false);
TEST_BLOCK_ANNOUNCE_STALL.lock().unwrap().replace(false);
let commits_count = commits_submitted.load(Ordering::SeqCst);
let blocks_count = mined_blocks.load(Ordering::SeqCst);
Expand Down Expand Up @@ -6970,7 +6970,7 @@ fn continue_tenure_extend() {
.get_stacks_blocks_processed();

info!("Pausing commit ops to trigger a tenure extend.");
test_skip_commit_op.0.lock().unwrap().replace(true);
test_skip_commit_op.set(true);

next_block_and(&mut btc_regtest_controller, 60, || Ok(true)).unwrap();

Expand Down Expand Up @@ -7069,7 +7069,7 @@ fn continue_tenure_extend() {
}

info!("Resuming commit ops to mine regular tenures.");
test_skip_commit_op.0.lock().unwrap().replace(false);
test_skip_commit_op.set(false);

// Mine 15 more regular nakamoto tenures
for _i in 0..15 {
Expand Down
Loading
Loading