Skip to content

Commit 1e5b654

Browse files
committed
test: fix tests::signer::v0::continue_after_fast_block_no_sortition
This test was not quite matching its description and the behavior changed a bit with the changes in this PR. This commit updates the test and the description.
1 parent 02d595c commit 1e5b654

File tree

1 file changed

+35
-37
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+35
-37
lines changed

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6535,19 +6535,22 @@ fn miner_recovers_when_broadcast_block_delay_across_tenures_occurs() {
65356535
/// Mine 2 empty burn blocks (simulate fast blocks scenario)
65366536
/// Miner 2 proposes block N+1 with a TenureChangePayload
65376537
/// Signers accept and the stacks tip advances to N+1
6538-
/// Miner 2 proposes block N+2 with a TokenTransfer
6538+
/// Miner 2 proposes block N+2 with a TenureExtend
65396539
/// Signers accept and the stacks tip advances to N+2
6540+
/// Miner 2 proposes block N+3 with a TokenTransfer
6541+
/// Signers accept and the stacks tip advances to N+3
65406542
/// Mine an empty burn block
6541-
/// Miner 2 proposes block N+3 with a TenureExtend
6542-
/// Signers accept and the chain advances to N+3
6543-
/// Miner 1 wins the next tenure and proposes a block N+4 with a TenureChangePayload
6543+
/// Miner 2 proposes block N+4 with a TenureExtend
65446544
/// Signers accept and the chain advances to N+4
6545+
/// Miner 1 wins the next tenure and proposes a block N+5 with a TenureChangePayload
6546+
/// Signers accept and the chain advances to N+5
65456547
/// Asserts:
65466548
/// - Block N+1 contains the TenureChangePayload
6547-
/// - Block N+2 contains the TokenTransfer
6548-
/// - Block N+3 contains the TenureExtend
6549-
/// - Block N+4 contains the TenureChangePayload
6550-
/// - The stacks tip advances to N+4
6549+
/// - Block N+2 contains the TenureExtend
6550+
/// - Block N+3 contains the TokenTransfer
6551+
/// - Block N+4 contains the TenureExtend
6552+
/// - Block N+5 contains the TenureChangePayload
6553+
/// - The stacks tip advances to N+5
65516554
#[test]
65526555
#[ignore]
65536556
fn continue_after_fast_block_no_sortition() {
@@ -6908,7 +6911,7 @@ fn continue_after_fast_block_no_sortition() {
69086911
// Allow signers to respond to proposals again
69096912
TEST_REJECT_ALL_BLOCK_PROPOSAL.set(Vec::new());
69106913

6911-
info!("------------------------- Wait for Miner B's Block N -------------------------";
6914+
info!("------------------------- Wait for Miner B's Block N+1 -------------------------";
69126915
"blocks_processed_before_2" => %blocks_processed_before_2,
69136916
"stacks_height_before" => %stacks_height_before,
69146917
"nmb_old_blocks" => %nmb_old_blocks);
@@ -6923,7 +6926,7 @@ fn continue_after_fast_block_no_sortition() {
69236926

69246927
let blocks_mined1_val = blocks_mined1.load(Ordering::SeqCst);
69256928
let blocks_mined2_val = blocks_mined2.load(Ordering::SeqCst);
6926-
info!("Waiting for Miner B's Block N";
6929+
info!("Waiting for Miner B's Block N+1";
69276930
"blocks_mined1_val" => %blocks_mined1_val,
69286931
"blocks_mined2_val" => %blocks_mined2_val,
69296932
"stacks_height" => %stacks_height,
@@ -6938,11 +6941,11 @@ fn continue_after_fast_block_no_sortition() {
69386941
.expect("Timed out waiting for block to be mined and processed");
69396942

69406943
info!(
6941-
"------------------------- Verify Tenure Change Tx in Miner B's Block N -------------------------"
6944+
"------------------------- Verify Tenure Change Tx in Miner B's Block N+1 -------------------------"
69426945
);
69436946
verify_last_block_contains_tenure_change_tx(TenureChangeCause::BlockFound);
69446947

6945-
info!("------------------------- Wait for Miner B's Block N+1 -------------------------");
6948+
info!("------------------------- Wait for Miner B's Block N+2 -------------------------");
69466949

69476950
let nmb_old_blocks = test_observer::get_blocks().len();
69486951
let blocks_processed_before_2 = blocks_mined2.load(Ordering::SeqCst);
@@ -6952,18 +6955,7 @@ fn continue_after_fast_block_no_sortition() {
69526955
.expect("Failed to get peer info")
69536956
.stacks_tip_height;
69546957

6955-
// submit a tx so that the miner will mine an extra block
6956-
let transfer_tx = make_stacks_transfer(
6957-
&sender_sk,
6958-
sender_nonce,
6959-
send_fee,
6960-
signer_test.running_nodes.conf.burnchain.chain_id,
6961-
&recipient,
6962-
send_amt,
6963-
);
6964-
submit_tx(&http_origin, &transfer_tx);
6965-
6966-
// wait for the tenure-extend block to be processed
6958+
// wait for the transfer block to be processed
69676959
wait_for(30, || {
69686960
let stacks_height = signer_test
69696961
.stacks_client
@@ -6978,8 +6970,12 @@ fn continue_after_fast_block_no_sortition() {
69786970
})
69796971
.expect("Timed out waiting for block to be mined and processed");
69806972

6973+
info!("------------------------- Verify Miner B's Block N+2 -------------------------");
6974+
69816975
verify_last_block_contains_tenure_change_tx(TenureChangeCause::Extended);
69826976

6977+
info!("------------------------- Wait for Miner B's Block N+3 -------------------------");
6978+
69836979
let nmb_old_blocks = test_observer::get_blocks().len();
69846980
let blocks_processed_before_2 = blocks_mined2.load(Ordering::SeqCst);
69856981
let stacks_height_before = signer_test
@@ -6988,22 +6984,24 @@ fn continue_after_fast_block_no_sortition() {
69886984
.expect("Failed to get peer info")
69896985
.stacks_tip_height;
69906986

6991-
// wait for the new block with the STX transfer to be processed
6987+
// submit a tx so that the miner will mine an extra block
6988+
let transfer_tx = make_stacks_transfer(
6989+
&sender_sk,
6990+
sender_nonce,
6991+
send_fee,
6992+
signer_test.running_nodes.conf.burnchain.chain_id,
6993+
&recipient,
6994+
send_amt,
6995+
);
6996+
submit_tx(&http_origin, &transfer_tx);
6997+
6998+
// wait for the transfer block to be processed
69926999
wait_for(30, || {
69937000
let stacks_height = signer_test
69947001
.stacks_client
69957002
.get_peer_info()
69967003
.expect("Failed to get peer info")
69977004
.stacks_tip_height;
6998-
6999-
let blocks_mined1_val = blocks_mined1.load(Ordering::SeqCst);
7000-
let blocks_mined2_val = blocks_mined2.load(Ordering::SeqCst);
7001-
info!("Waiting for Miner B's Block N";
7002-
"blocks_mined1_val" => %blocks_mined1_val,
7003-
"blocks_mined2_val" => %blocks_mined2_val,
7004-
"stacks_height" => %stacks_height,
7005-
"observed_blocks" => %test_observer::get_blocks().len());
7006-
70077005
Ok(
70087006
blocks_mined2.load(Ordering::SeqCst) > blocks_processed_before_2
70097007
&& stacks_height > stacks_height_before
@@ -7012,7 +7010,7 @@ fn continue_after_fast_block_no_sortition() {
70127010
})
70137011
.expect("Timed out waiting for block to be mined and processed");
70147012

7015-
info!("------------------------- Verify Miner B's Block N+1 -------------------------");
7013+
info!("------------------------- Verify Miner B's Block N+3 -------------------------");
70167014

70177015
verify_last_block_contains_transfer_tx();
70187016

@@ -7029,7 +7027,7 @@ fn continue_after_fast_block_no_sortition() {
70297027
.unwrap();
70307028
btc_blocks_mined += 1;
70317029

7032-
info!("------------------------- Verify Miner B's Issues a Tenure Change Extend in Block N+2 -------------------------");
7030+
info!("------------------------- Verify Miner B's Issues a Tenure Change Extend in Block N+4 -------------------------");
70337031
verify_last_block_contains_tenure_change_tx(TenureChangeCause::Extended);
70347032

70357033
info!("------------------------- Unpause Miner A's Block Commits -------------------------");
@@ -7064,7 +7062,7 @@ fn continue_after_fast_block_no_sortition() {
70647062
assert!(tip.sortition);
70657063
assert_eq!(tip.miner_pk_hash.unwrap(), mining_pkh_1);
70667064

7067-
info!("------------------------- Verify Miner A's Issued a Tenure Change in Block N+4 -------------------------");
7065+
info!("------------------------- Verify Miner A's Issued a Tenure Change in Block N+5 -------------------------");
70687066
verify_last_block_contains_tenure_change_tx(TenureChangeCause::BlockFound);
70697067

70707068
info!(

0 commit comments

Comments
 (0)