@@ -109,8 +109,8 @@ use stacks_signer::v0::SpawnedSigner;
109
109
110
110
use super :: bitcoin_regtest:: BitcoinCoreController ;
111
111
use crate :: nakamoto_node:: miner:: {
112
- TEST_BLOCK_ANNOUNCE_STALL , TEST_BROADCAST_PROPOSAL_STALL , TEST_MINE_STALL ,
113
- TEST_P2P_BROADCAST_SKIP , TEST_P2P_BROADCAST_STALL ,
112
+ fault_injection_stall_miner , fault_injection_unstall_miner , TEST_BLOCK_ANNOUNCE_STALL ,
113
+ TEST_BROADCAST_PROPOSAL_STALL , TEST_P2P_BROADCAST_SKIP , TEST_P2P_BROADCAST_STALL ,
114
114
} ;
115
115
use crate :: nakamoto_node:: relayer:: TEST_MINER_THREAD_STALL ;
116
116
use crate :: neon:: Counters ;
@@ -6020,7 +6020,7 @@ fn nakamoto_attempt_time() {
6020
6020
6021
6021
// Stall the miner to make sure it waits until all transactions are
6022
6022
// submitted before it mines a block
6023
- TEST_MINE_STALL . set ( true ) ;
6023
+ fault_injection_stall_miner ( ) ;
6024
6024
6025
6025
let mut sender_nonce = account. nonce ;
6026
6026
for _ in 0 ..txs_per_block {
@@ -6036,7 +6036,7 @@ fn nakamoto_attempt_time() {
6036
6036
submit_tx ( & http_origin, & transfer_tx) ;
6037
6037
}
6038
6038
6039
- TEST_MINE_STALL . set ( false ) ;
6039
+ fault_injection_unstall_miner ( ) ;
6040
6040
6041
6041
// Miner should have made a new block by now
6042
6042
let wait_start = Instant :: now ( ) ;
@@ -6304,7 +6304,7 @@ fn clarity_burn_state() {
6304
6304
result. expect_result_ok ( ) . expect ( "Read-only call failed" ) ;
6305
6305
6306
6306
// Pause mining to prevent the stacks block from being mined before the tenure change is processed
6307
- TEST_MINE_STALL . set ( true ) ;
6307
+ fault_injection_stall_miner ( ) ;
6308
6308
// Submit a tx for the next block (the next block will be a new tenure, so the burn block height will increment)
6309
6309
let call_tx = make_contract_call (
6310
6310
& sender_sk,
@@ -6329,7 +6329,7 @@ fn clarity_burn_state() {
6329
6329
Ok ( commits_submitted. load ( Ordering :: SeqCst ) > commits_before)
6330
6330
} )
6331
6331
. unwrap ( ) ;
6332
- TEST_MINE_STALL . set ( false ) ;
6332
+ fault_injection_unstall_miner ( ) ;
6333
6333
wait_for ( 20 , || {
6334
6334
Ok ( coord_channel
6335
6335
. lock ( )
@@ -10368,7 +10368,7 @@ fn clarity_cost_spend_down() {
10368
10368
. expect ( "Mutex poisoned" )
10369
10369
. get_stacks_blocks_processed ( ) ;
10370
10370
// Pause mining so we can add all our transactions to the mempool at once.
10371
- TEST_MINE_STALL . set ( true ) ;
10371
+ fault_injection_stall_miner ( ) ;
10372
10372
for _nmb_tx in 0 ..nmb_txs_per_signer {
10373
10373
for sender_sk in sender_sks. iter ( ) {
10374
10374
let sender_nonce = get_and_increment_nonce ( sender_sk, & mut sender_nonces) ;
@@ -10394,7 +10394,7 @@ fn clarity_cost_spend_down() {
10394
10394
}
10395
10395
}
10396
10396
}
10397
- TEST_MINE_STALL . set ( false ) ;
10397
+ fault_injection_unstall_miner ( ) ;
10398
10398
wait_for ( 120 , || {
10399
10399
let blocks_processed = coord_channel
10400
10400
. lock ( )
@@ -10672,7 +10672,7 @@ fn test_tenure_extend_from_flashblocks() {
10672
10672
assert_eq ! ( sort_tip. consensus_hash, election_tip. consensus_hash) ;
10673
10673
10674
10674
// stop the relayer thread from starting a miner thread, and stop the miner thread from mining
10675
- TEST_MINE_STALL . set ( true ) ;
10675
+ fault_injection_stall_miner ( ) ;
10676
10676
TEST_MINER_THREAD_STALL . set ( true ) ;
10677
10677
10678
10678
// mine another Bitcoin block right away, and force it to be a flash block
@@ -10738,7 +10738,7 @@ fn test_tenure_extend_from_flashblocks() {
10738
10738
10739
10739
// unstall miner thread and allow block-commits again
10740
10740
counters. naka_skip_commit_op . set ( false ) ;
10741
- TEST_MINE_STALL . set ( false ) ;
10741
+ fault_injection_unstall_miner ( ) ;
10742
10742
10743
10743
// wait for the miner directive to be processed
10744
10744
wait_for ( 60 , || {
@@ -11509,7 +11509,7 @@ fn large_mempool_base(strategy: MemPoolWalkStrategy, set_fee: impl Fn() -> u64)
11509
11509
info ! ( "Pause mining and fill the mempool with the transfers" ) ;
11510
11510
11511
11511
// Pause block mining
11512
- TEST_MINE_STALL . set ( true ) ;
11512
+ fault_injection_stall_miner ( ) ;
11513
11513
11514
11514
let db_tx = conn. transaction ( ) . unwrap ( ) ;
11515
11515
let timer = Instant :: now ( ) ;
@@ -11549,7 +11549,7 @@ fn large_mempool_base(strategy: MemPoolWalkStrategy, set_fee: impl Fn() -> u64)
11549
11549
let proposed_blocks_before = test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) ;
11550
11550
11551
11551
// Unpause block mining
11552
- TEST_MINE_STALL . set ( false ) ;
11552
+ fault_injection_unstall_miner ( ) ;
11553
11553
11554
11554
// Wait for the first block to be proposed.
11555
11555
wait_for ( 30 , || {
@@ -11846,7 +11846,7 @@ fn larger_mempool() {
11846
11846
info ! ( "Pause mining and fill the mempool with the transfers" ) ;
11847
11847
11848
11848
// Pause block mining
11849
- TEST_MINE_STALL . set ( true ) ;
11849
+ fault_injection_stall_miner ( ) ;
11850
11850
11851
11851
let timer = Instant :: now ( ) ;
11852
11852
@@ -11890,7 +11890,7 @@ fn larger_mempool() {
11890
11890
let timer = Instant :: now ( ) ;
11891
11891
11892
11892
// Unpause block mining
11893
- TEST_MINE_STALL . set ( false ) ;
11893
+ fault_injection_unstall_miner ( ) ;
11894
11894
11895
11895
// Wait for the first block to be proposed.
11896
11896
wait_for ( 10 , || {
@@ -12184,7 +12184,7 @@ fn handle_considered_txs_foreign_key_failure() {
12184
12184
let height_before = get_chain_info ( & naka_conf) . stacks_tip_height ;
12185
12185
12186
12186
// Initiate the transaction stall, then submit transactions.
12187
- TEST_MINE_STALL . set ( true ) ;
12187
+ fault_injection_stall_miner ( ) ;
12188
12188
TEST_TX_STALL . set ( true ) ;
12189
12189
12190
12190
let bad_transfer_tx = make_stacks_transfer_serialized (
@@ -12198,7 +12198,7 @@ fn handle_considered_txs_foreign_key_failure() {
12198
12198
let txid = submit_tx ( & http_origin, & bad_transfer_tx) ;
12199
12199
info ! ( "Bad transaction submitted: {txid}" ) ;
12200
12200
12201
- TEST_MINE_STALL . set ( false ) ;
12201
+ fault_injection_unstall_miner ( ) ;
12202
12202
12203
12203
// Sleep long enough to ensure that the miner has started processing the tx
12204
12204
sleep_ms ( 5_000 ) ;
@@ -12432,7 +12432,7 @@ fn miner_constructs_replay_block() {
12432
12432
12433
12433
// Pause mining to prevent any of the submitted txs getting mined.
12434
12434
info ! ( "Stalling mining..." ) ;
12435
- TEST_MINE_STALL . set ( true ) ;
12435
+ fault_injection_stall_miner ( ) ;
12436
12436
let burn_height_before = get_chain_info ( & naka_conf) . burn_block_height ;
12437
12437
// Mine 1 bitcoin block to trigger a new block found transaction
12438
12438
next_block_and ( & mut btc_regtest_controller, 60 , || {
@@ -12515,7 +12515,7 @@ fn miner_constructs_replay_block() {
12515
12515
let blocks_before = test_observer:: get_blocks ( ) . len ( ) ;
12516
12516
assert_eq ! ( observed_before, 0 ) ;
12517
12517
info ! ( "Resuming mining..." ) ;
12518
- TEST_MINE_STALL . set ( false ) ;
12518
+ fault_injection_unstall_miner ( ) ;
12519
12519
12520
12520
info ! ( "Waiting for two stacks block to be mined..." ) ;
12521
12521
wait_for ( 30 , || {
0 commit comments