Skip to content

Commit 571dfee

Browse files
committed
chore: resolve feature flag issue
1 parent bef8c90 commit 571dfee

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

stackslib/src/chainstate/nakamoto/coordinator/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ use crate::chainstate::nakamoto::coordinator::load_nakamoto_reward_set;
4444
use crate::chainstate::nakamoto::miner::NakamotoBlockBuilder;
4545
use crate::chainstate::nakamoto::signer_set::NakamotoSigners;
4646
use crate::chainstate::nakamoto::test_signers::TestSigners;
47+
use crate::chainstate::nakamoto::test_stall::*;
4748
use crate::chainstate::nakamoto::tests::get_account;
4849
use crate::chainstate::nakamoto::tests::node::TestStacker;
4950
use crate::chainstate::nakamoto::{
50-
disable_process_block_stall, enable_process_block_stall, NakamotoBlock,
51-
NakamotoBlockObtainMethod, NakamotoChainState, NakamotoStagingBlocksConnRef,
52-
TEST_PROCESS_BLOCK_STALL,
51+
NakamotoBlock, NakamotoBlockObtainMethod, NakamotoChainState, NakamotoStagingBlocksConnRef,
5352
};
5453
use crate::chainstate::stacks::address::PoxAddress;
5554
use crate::chainstate::stacks::boot::pox_4_tests::{get_stacking_minimum, get_tip};

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,27 +270,29 @@ lazy_static! {
270270
];
271271
}
272272

273-
// Cause an artifical stall in block-processing, for testing.
274-
#[cfg(any(test, feature = "testing"))]
275-
pub static TEST_PROCESS_BLOCK_STALL: std::sync::Mutex<Option<bool>> = std::sync::Mutex::new(None);
276-
277-
fn stall_block_processing() {
278-
if *TEST_PROCESS_BLOCK_STALL.lock().unwrap() == Some(true) {
279-
// Do an extra check just so we don't log EVERY time.
280-
warn!("Block processing is stalled due to testing directive.");
281-
while *TEST_PROCESS_BLOCK_STALL.lock().unwrap() == Some(true) {
282-
std::thread::sleep(std::time::Duration::from_millis(10));
273+
#[cfg(test)]
274+
mod test_stall {
275+
pub static TEST_PROCESS_BLOCK_STALL: std::sync::Mutex<Option<bool>> =
276+
std::sync::Mutex::new(None);
277+
278+
pub fn stall_block_processing() {
279+
if *TEST_PROCESS_BLOCK_STALL.lock().unwrap() == Some(true) {
280+
// Do an extra check just so we don't log EVERY time.
281+
warn!("Block processing is stalled due to testing directive.");
282+
while *TEST_PROCESS_BLOCK_STALL.lock().unwrap() == Some(true) {
283+
std::thread::sleep(std::time::Duration::from_millis(10));
284+
}
285+
info!("Block processing is no longer stalled due to testing directive.");
283286
}
284-
info!("Block processing is no longer stalled due to testing directive.");
285287
}
286-
}
287288

288-
pub fn enable_process_block_stall() {
289-
TEST_PROCESS_BLOCK_STALL.lock().unwrap().replace(true);
290-
}
289+
pub fn enable_process_block_stall() {
290+
TEST_PROCESS_BLOCK_STALL.lock().unwrap().replace(true);
291+
}
291292

292-
pub fn disable_process_block_stall() {
293-
TEST_PROCESS_BLOCK_STALL.lock().unwrap().replace(false);
293+
pub fn disable_process_block_stall() {
294+
TEST_PROCESS_BLOCK_STALL.lock().unwrap().replace(false);
295+
}
294296
}
295297

296298
/// Trait for common MARF getters between StacksDBConn and StacksDBTx
@@ -1745,8 +1747,8 @@ impl NakamotoChainState {
17451747
canonical_sortition_tip: &SortitionId,
17461748
dispatcher_opt: Option<&'a T>,
17471749
) -> Result<Option<StacksEpochReceipt>, ChainstateError> {
1748-
#[cfg(any(test, feature = "testing"))]
1749-
stall_block_processing();
1750+
#[cfg(test)]
1751+
test_stall::stall_block_processing();
17501752

17511753
let nakamoto_blocks_db = stacks_chain_state.nakamoto_blocks_db();
17521754
let Some((next_ready_block, block_size)) =

0 commit comments

Comments
 (0)