@@ -94,7 +94,9 @@ use wsts::net::Message;
94
94
95
95
use super :: bitcoin_regtest:: BitcoinCoreController ;
96
96
use crate :: config:: { EventKeyType , EventObserverConfig , InitialBalance } ;
97
- use crate :: nakamoto_node:: miner:: { TEST_BLOCK_ANNOUNCE_STALL , TEST_BROADCAST_STALL } ;
97
+ use crate :: nakamoto_node:: miner:: {
98
+ TEST_BLOCK_ANNOUNCE_STALL , TEST_BROADCAST_STALL , TEST_MINE_STALL ,
99
+ } ;
98
100
use crate :: neon:: { Counters , RunLoopCounter } ;
99
101
use crate :: operations:: BurnchainOpSigner ;
100
102
use crate :: run_loop:: boot_nakamoto;
@@ -5185,21 +5187,68 @@ fn clarity_burn_state() {
5185
5187
vec ! [ & Value :: UInt ( burn_block_height) ] ,
5186
5188
) ;
5187
5189
result. expect_result_ok ( ) . expect ( "Read-only call failed" ) ;
5190
+
5191
+ // Pause mining to prevent the stacks block from being mined before the tenure change is processed
5192
+ TEST_MINE_STALL . lock ( ) . unwrap ( ) . replace ( true ) ;
5193
+ // Submit a tx for the next block (the next block will be a new tenure, so the burn block height will increment)
5194
+ let call_tx = tests:: make_contract_call (
5195
+ & sender_sk,
5196
+ sender_nonce,
5197
+ tx_fee,
5198
+ & sender_addr,
5199
+ contract_name,
5200
+ "bar" ,
5201
+ & [ Value :: UInt ( burn_block_height + 1 ) ] ,
5202
+ ) ;
5203
+ sender_nonce += 1 ;
5204
+ submit_tx ( & http_origin, & call_tx) ;
5188
5205
}
5189
5206
5190
5207
let commits_before = commits_submitted. load ( Ordering :: SeqCst ) ;
5191
- next_block_and_mine_commit (
5192
- & mut btc_regtest_controller,
5193
- 60 ,
5194
- & coord_channel,
5195
- & commits_submitted,
5196
- )
5208
+ let blocks_processed_before = coord_channel
5209
+ . lock ( )
5210
+ . expect ( "Mutex poisoned" )
5211
+ . get_stacks_blocks_processed ( ) ;
5212
+ next_block_and ( & mut btc_regtest_controller, 60 , || {
5213
+ Ok ( commits_submitted. load ( Ordering :: SeqCst ) > commits_before)
5214
+ } )
5215
+ . unwrap ( ) ;
5216
+ TEST_MINE_STALL . lock ( ) . unwrap ( ) . replace ( false ) ;
5217
+ wait_for ( 20 , || {
5218
+ Ok ( coord_channel
5219
+ . lock ( )
5220
+ . expect ( "Mutex poisoned" )
5221
+ . get_stacks_blocks_processed ( )
5222
+ > blocks_processed_before)
5223
+ } )
5197
5224
. unwrap ( ) ;
5198
5225
5199
5226
let info = get_chain_info ( & naka_conf) ;
5200
5227
burn_block_height = info. burn_block_height as u128 ;
5201
5228
info ! ( "Expecting burn block height to be {}" , burn_block_height) ;
5202
5229
5230
+ // Assert that the contract call was successful
5231
+ test_observer:: get_mined_nakamoto_blocks ( )
5232
+ . last ( )
5233
+ . unwrap ( )
5234
+ . tx_events
5235
+ . iter ( )
5236
+ . for_each ( |event| match event {
5237
+ TransactionEvent :: Success ( TransactionSuccessEvent { result, fee, .. } ) => {
5238
+ // Ignore coinbase and tenure transactions
5239
+ if * fee == 0 {
5240
+ return ;
5241
+ }
5242
+
5243
+ info ! ( "Contract call result: {}" , result) ;
5244
+ result. clone ( ) . expect_result_ok ( ) . expect ( "Ok result" ) ;
5245
+ }
5246
+ _ => {
5247
+ info ! ( "Unsuccessful event: {:?}" , event) ;
5248
+ panic ! ( "Expected a successful transaction" ) ;
5249
+ }
5250
+ } ) ;
5251
+
5203
5252
// mine the interim blocks
5204
5253
for interim_block_ix in 0 ..inter_blocks_per_tenure {
5205
5254
info ! ( "Mining interim block {interim_block_ix}" ) ;
0 commit comments