@@ -1103,11 +1103,24 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1103
1103
/// Mine a BTC block and wait for a new Stacks block to be mined
1104
1104
/// Note: do not use nakamoto blocks mined heuristic if running a test with multiple miners
1105
1105
fn mine_nakamoto_block ( & self , timeout : Duration , use_nakamoto_blocks_mined : bool ) {
1106
- let mined_before = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
1107
1106
let info_before = get_chain_info ( & self . running_nodes . conf ) ;
1108
1107
let mined_btc_block_time = Instant :: now ( ) ;
1109
1108
info ! ( "Pausing stacks block mining" ) ;
1110
1109
TEST_MINE_SKIP . set ( true ) ;
1110
+
1111
+ let Counters {
1112
+ naka_submitted_commits : commits_submitted,
1113
+ naka_submitted_commit_last_burn_height : commits_last_burn_height,
1114
+ naka_submitted_commit_last_stacks_tip : commits_last_stacks_tip,
1115
+ naka_mined_blocks : mined_blocks,
1116
+ ..
1117
+ } = self . running_nodes . counters . clone ( ) ;
1118
+
1119
+ let commits_before = commits_submitted. load ( Ordering :: SeqCst ) ;
1120
+ let commit_burn_height_before = commits_last_burn_height. load ( Ordering :: SeqCst ) ;
1121
+ let commits_stacks_tip_before = commits_last_stacks_tip. load ( Ordering :: SeqCst ) ;
1122
+ let mined_before = mined_blocks. load ( Ordering :: SeqCst ) ;
1123
+
1111
1124
next_block_and (
1112
1125
& self . running_nodes . btc_regtest_controller ,
1113
1126
timeout. as_secs ( ) ,
@@ -1128,13 +1141,15 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1128
1141
info ! ( "Unpausing stacks block mining" ) ;
1129
1142
let mined_block_time = Instant :: now ( ) ;
1130
1143
TEST_MINE_SKIP . set ( false ) ;
1144
+ // Ensure that the tenure change transaction is mined and that the subsequent block commit confirms it
1131
1145
wait_for ( timeout. as_secs ( ) , || {
1132
- let info_after = get_chain_info ( & self . running_nodes . conf ) ;
1133
- let blocks_mined = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
1134
- // println!("HERE BEFORE {}, AFTER {}", info_before.stacks_tip_height, info_after.stacks_tip_height);
1135
- // println!("HERE BEFORE {mined_before}, AFTER {blocks_mined}");
1136
- Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height
1137
- && ( !use_nakamoto_blocks_mined || blocks_mined > mined_before) )
1146
+ Ok ( commits_submitted. load ( Ordering :: SeqCst ) > commits_before
1147
+ && commits_last_burn_height. load ( Ordering :: SeqCst ) >= commit_burn_height_before
1148
+ && commits_last_stacks_tip. load ( Ordering :: SeqCst ) >= commits_stacks_tip_before
1149
+ && get_chain_info ( & self . running_nodes . conf ) . stacks_tip_height
1150
+ > info_before. stacks_tip_height
1151
+ && ( !use_nakamoto_blocks_mined
1152
+ || mined_blocks. load ( Ordering :: SeqCst ) > mined_before) )
1138
1153
} )
1139
1154
. expect ( "Failed to mine Tenure Change block" ) ;
1140
1155
info ! (
0 commit comments