@@ -12558,12 +12558,16 @@ fn miner_constructs_replay_block() {
12558
12558
12559
12559
wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
12560
12560
12561
- // Mine 1 nakamoto tenure
12562
- next_block_and_mine_commit ( & mut btc_regtest_controller, 60 , & naka_conf, & counters) . unwrap ( ) ;
12563
-
12564
12561
// Pause mining to prevent any of the submitted txs getting mined.
12565
12562
info ! ( "Stalling mining..." ) ;
12566
12563
TEST_MINE_STALL . set ( true ) ;
12564
+ let burn_height_before = get_chain_info ( & naka_conf) . burn_block_height ;
12565
+ // Mine 1 bitcoin block to trigger a new block found transaction
12566
+ next_block_and ( & mut btc_regtest_controller, 60 , || {
12567
+ let burn_height = get_chain_info ( & naka_conf) . burn_block_height ;
12568
+ Ok ( burn_height > burn_height_before)
12569
+ } )
12570
+ . expect ( "Failed to mine bitcoin block" ) ;
12567
12571
12568
12572
info ! (
12569
12573
"Filling mempool with {} txs..." ,
@@ -12636,19 +12640,40 @@ fn miner_constructs_replay_block() {
12636
12640
) ;
12637
12641
12638
12642
let observed_before = test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) ;
12639
- assert_eq ! ( observed_before, 1 ) ;
12643
+ let blocks_before = test_observer:: get_blocks ( ) . len ( ) ;
12644
+ assert_eq ! ( observed_before, 0 ) ;
12640
12645
info ! ( "Resuming mining..." ) ;
12641
12646
TEST_MINE_STALL . set ( false ) ;
12642
12647
12643
- info ! ( "Waiting for block to be mined..." ) ;
12648
+ info ! ( "Waiting for two stacks block to be mined..." ) ;
12644
12649
wait_for ( 30 , || {
12645
- Ok ( test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) > observed_before)
12650
+ Ok (
12651
+ test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) > observed_before + 1
12652
+ && test_observer:: get_blocks ( ) . len ( ) > blocks_before + 1 ,
12653
+ )
12646
12654
} )
12647
- . expect ( "Timed out waiting for a block to be mined" ) ;
12655
+ . expect ( "Timed out waiting for two stacks block to be mined" ) ;
12648
12656
12657
+ info ! ( "Verifying that a tenure change block was found BEFORE mining the replay txs..." ) ;
12649
12658
let observed_blocks = test_observer:: get_mined_nakamoto_blocks ( ) ;
12650
- let block = observed_blocks. last ( ) . unwrap ( ) ;
12651
- info ! ( "Verifying block contains the expected txs..." ) ;
12659
+ let blocks = test_observer:: get_blocks ( ) ;
12660
+ let raw_block_found = & blocks[ blocks_before] ;
12661
+ let transactions = raw_block_found
12662
+ . get ( "transactions" )
12663
+ . unwrap ( )
12664
+ . as_array ( )
12665
+ . unwrap ( ) ;
12666
+ assert_eq ! ( transactions. len( ) , 2 ) ; // Should contain a block found and a coinbase
12667
+ let tx = transactions. first ( ) . unwrap ( ) ;
12668
+ let raw_tx = tx. get ( "raw_tx" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
12669
+ let tx_bytes = hex_bytes ( & raw_tx[ 2 ..] ) . unwrap ( ) ;
12670
+ let parsed = StacksTransaction :: consensus_deserialize ( & mut & tx_bytes[ ..] ) . unwrap ( ) ;
12671
+ let tenure_change = parsed. try_as_tenure_change ( ) . unwrap ( ) ;
12672
+ assert_eq ! ( tenure_change. cause, TenureChangeCause :: BlockFound ) ;
12673
+
12674
+ info ! ( "Verifying next block contains the expected replay txs..." ) ;
12675
+ let block = & observed_blocks[ observed_before + 1 ] ;
12676
+ assert_eq ! ( block. tx_events. len( ) , 6 ) ;
12652
12677
if let TransactionEvent :: Success ( tx) = & block. tx_events [ 0 ] {
12653
12678
assert_eq ! ( tx. txid, succeed_tx_1. txid( ) ) ;
12654
12679
} else {
0 commit comments