@@ -3175,7 +3175,7 @@ fn tenure_extend_after_idle_miner() {
3175
3175
wait_for_tenure_change_tx (
3176
3176
miner_idle_timeout. as_secs ( ) + 20 ,
3177
3177
TenureChangeCause :: Extended ,
3178
- tip_height_before + 1 ,
3178
+ tip_height_before + 2 ,
3179
3179
)
3180
3180
. expect ( "Timed out waiting for a block with a tenure extend" ) ;
3181
3181
signer_test. shutdown ( ) ;
@@ -6546,30 +6546,36 @@ fn continue_after_tenure_extend() {
6546
6546
let sortdb = burnchain. open_sortition_db ( true ) . unwrap ( ) ;
6547
6547
6548
6548
signer_test. boot_to_epoch_3 ( ) ;
6549
+ info ! ( "------------------------- Mine A Normal Tenure -------------------------" ) ;
6550
+ signer_test. mine_and_verify_confirmed_naka_block ( timeout, num_signers, true ) ;
6551
+
6552
+ info ! ( "------------------------- Pause Block Commits-------------------------" ) ;
6549
6553
signer_test
6550
6554
. running_nodes
6551
6555
. counters
6552
6556
. naka_skip_commit_op
6553
6557
. set ( true ) ;
6554
- info ! ( "------------------------- Mine A Normal Tenure -------------------------" ) ;
6555
- signer_test . mine_and_verify_confirmed_naka_block ( timeout , num_signers , true ) ;
6556
-
6557
- info ! ( "------------------------- Extend Tenure -------------------------" ) ;
6558
- let stacks_height_before = signer_test . get_peer_info ( ) . stacks_tip_height ;
6558
+ info ! ( "------------------------- Flush Pending Commits -------------------------" ) ;
6559
+ // Mine a couple blocks to flush the last submitted commit out.
6560
+ let peer_info = signer_test . get_peer_info ( ) ;
6561
+ let burn_height_before = peer_info . burn_block_height ;
6562
+ let stacks_height_before = peer_info . stacks_tip_height ;
6559
6563
signer_test
6560
6564
. running_nodes
6561
6565
. btc_regtest_controller
6562
- . build_next_block ( 1 ) ;
6566
+ . build_next_block ( 2 ) ;
6567
+ wait_for ( 30 , || {
6568
+ let peer_info = signer_test. get_peer_info ( ) ;
6569
+ Ok ( peer_info. burn_block_height > burn_height_before + 1 )
6570
+ } )
6571
+ . expect ( "Timed out waiting for burn block height to increase" ) ;
6563
6572
// assure we have NO sortition
6564
6573
let tip = SortitionDB :: get_canonical_burn_chain_tip ( sortdb. conn ( ) ) . unwrap ( ) ;
6565
6574
assert ! ( !tip. sortition) ;
6566
6575
6567
- let extend_block = wait_for_block_pushed_by_miner_key ( 30 , stacks_height_before + 1 , & miner_pk)
6568
- . expect ( "Timed out waiting for block N+1 to be mined" ) ;
6569
- assert_eq ! (
6570
- extend_block. try_get_tenure_change_payload( ) . unwrap( ) . cause,
6571
- TenureChangeCause :: Extended
6572
- ) ;
6576
+ info ! ( "------------------------- Extend Tenure -------------------------" ) ;
6577
+ wait_for_tenure_change_tx ( 30 , TenureChangeCause :: Extended , stacks_height_before + 2 )
6578
+ . expect ( "Timed out waiting for tenure change tx" ) ;
6573
6579
6574
6580
// Verify that the miner can continue mining in the tenure with the tenure extend
6575
6581
info ! ( "------------------------- Mine After Tenure Extend -------------------------" ) ;
@@ -8141,9 +8147,8 @@ fn global_acceptance_depends_on_block_announcement() {
8141
8147
let tx = submit_tx ( & http_origin, & transfer_tx) ;
8142
8148
info ! ( "Submitted tx {tx} in to mine block N+1" ) ;
8143
8149
8144
- let block_n_1 =
8145
- wait_for_block_pushed_by_miner_key ( 30 , info_before. stacks_tip_height + 1 , & miner_pk)
8146
- . expect ( "Timed out waiting for block N+1 to be mined" ) ;
8150
+ let block_n_1 = wait_for_block_proposal ( 30 , info_before. stacks_tip_height + 1 , & miner_pk)
8151
+ . expect ( "Timed out waiting for block N+1 to be proposed" ) ;
8147
8152
8148
8153
// Even though one of the signers rejected the block, it will eventually accept the block as it sees the 70% threshold of signatures
8149
8154
wait_for_block_global_acceptance_from_signers (
@@ -8386,17 +8391,18 @@ fn no_reorg_due_to_successive_block_validation_ok() {
8386
8391
info ! ( "------------------------- Unpause Block Validation Submission and Response for N+1' -------------------------" ) ;
8387
8392
TEST_STALL_BLOCK_VALIDATION_SUBMISSION . set ( false ) ;
8388
8393
8389
- info ! ( "------------------------- Confirm N+1 is Accepted ------------------------" ) ;
8390
- let block_n_1 = wait_for_block_pushed ( 30 , block_n_1_signature_hash)
8391
- . expect ( "Timed out waiting for Block N+1 to be mined" ) ;
8392
- debug ! ( "Miner 1 mined block N+1: {block_n_1_signature_hash}" ) ;
8393
-
8394
8394
info ! ( "------------------------- Confirm N+1' is Rejected ------------------------" ) ;
8395
8395
wait_for_block_global_rejection ( 30 , block_n_1_prime_signature_hash, num_signers)
8396
8396
. expect ( "Failed to find block N+1'" ) ;
8397
8397
8398
- info ! ( "------------------------- Confirm N+2 Accepted ------------------------" ) ;
8398
+ info ! ( "------------------------- Confirm N+1 Accepted -------------------------" ) ;
8399
+ let mined_block_n_1 = test_observer:: get_mined_nakamoto_blocks ( )
8400
+ . into_iter ( )
8401
+ . find ( |block| block. signer_signature_hash == block_n_1_signature_hash)
8402
+ . expect ( "Failed to find block N+1" ) ;
8399
8403
8404
+ // Miner 2 will see block N+1 as a valid block and reattempt to mine N+2 on top.
8405
+ info ! ( "------------------------- Confirm N+2 Accepted ------------------------" ) ;
8400
8406
let block_n_2 =
8401
8407
wait_for_block_pushed_by_miner_key ( 30 , block_n_1. header . chain_length + 1 , & miner_pk_2)
8402
8408
. expect ( "Failed to find block N+2" ) ;
@@ -8415,8 +8421,8 @@ fn no_reorg_due_to_successive_block_validation_ok() {
8415
8421
block_n_2. header. consensus_hash
8416
8422
) ;
8417
8423
assert_eq ! (
8418
- block_n_2. header. parent_block_id,
8419
- block_n_1 . header . block_id( )
8424
+ block_n_2. header. parent_block_id. to_string ( ) ,
8425
+ mined_block_n_1 . block_id
8420
8426
) ;
8421
8427
assert_eq ! ( block_n_1. header. parent_block_id, block_n. header. block_id( ) ) ;
8422
8428
0 commit comments