@@ -5623,7 +5623,7 @@ fn block_validation_response_timeout() {
5623
5623
5624
5624
info ! ( "------------------------- Test Setup -------------------------" ) ;
5625
5625
let num_signers = 5 ;
5626
- let timeout = Duration :: from_secs ( 60 ) ;
5626
+ let timeout = Duration :: from_secs ( 30 ) ;
5627
5627
let sender_sk = Secp256k1PrivateKey :: new ( ) ;
5628
5628
let sender_addr = tests:: to_addr ( & sender_sk) ;
5629
5629
let send_amt = 100 ;
@@ -5676,7 +5676,12 @@ fn block_validation_response_timeout() {
5676
5676
} )
5677
5677
. expect ( "Timed out waiting for block proposal" ) ;
5678
5678
5679
- info ! ( "------------------------- Propose Another Block -------------------------" ) ;
5679
+ assert ! (
5680
+ validation_stall_start. elapsed( ) < timeout,
5681
+ "Test was too slow to propose another block before the timeout"
5682
+ ) ;
5683
+
5684
+ info ! ( "------------------------- Propose Another Block Before Hitting the Timeout -------------------------" ) ;
5680
5685
let proposal_conf = ProposalEvalConfig {
5681
5686
first_proposal_burn_block_timing : Duration :: from_secs ( 0 ) ,
5682
5687
block_proposal_timeout : Duration :: from_secs ( 100 ) ,
@@ -5686,26 +5691,27 @@ fn block_validation_response_timeout() {
5686
5691
txs : vec ! [ ] ,
5687
5692
} ;
5688
5693
5694
+ let info_before = get_chain_info ( & signer_test. running_nodes . conf ) ;
5689
5695
// Propose a block to the signers that passes initial checks but will not be submitted to the stacks node due to the submission stall
5690
5696
let view = SortitionsView :: fetch_view ( proposal_conf, & signer_test. stacks_client ) . unwrap ( ) ;
5691
5697
block. header . pox_treatment = BitVec :: ones ( 1 ) . unwrap ( ) ;
5692
5698
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
5693
- block. header . chain_length = 1 ; // We have mined 1 block so far
5699
+ block. header . chain_length = info_before . stacks_tip_height + 1 ;
5694
5700
5695
5701
let block_signer_signature_hash_1 = block. header . signer_signature_hash ( ) ;
5696
- let info_before = get_chain_info ( & signer_test. running_nodes . conf ) ;
5697
- signer_test. propose_block ( block, Duration :: from_secs ( 30 ) ) ;
5702
+ signer_test. propose_block ( block, timeout) ;
5698
5703
5699
5704
info ! ( "------------------------- Waiting for Timeout -------------------------" ) ;
5700
5705
// Sleep the necessary timeout to make sure the validation times out.
5701
5706
let elapsed = validation_stall_start. elapsed ( ) ;
5707
+ let wait = timeout. saturating_sub ( elapsed) ;
5708
+ info ! ( "Sleeping for {} ms" , wait. as_millis( ) ) ;
5702
5709
std:: thread:: sleep ( timeout. saturating_sub ( elapsed) ) ;
5703
5710
5704
5711
info ! ( "------------------------- Wait for Block Rejection Due to Timeout -------------------------" ) ;
5705
5712
// Verify the signers rejected the first block due to timeout
5706
- let start = Instant :: now ( ) ;
5707
5713
let mut rejected_signers = vec ! [ ] ;
5708
- let mut saw_connectivity_complaint = false ;
5714
+ let start = Instant :: now ( ) ;
5709
5715
while rejected_signers. len ( ) < num_signers {
5710
5716
std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
5711
5717
let chunks = test_observer:: get_stackerdb_chunks ( ) ;
@@ -5714,32 +5720,30 @@ fn block_validation_response_timeout() {
5714
5720
else {
5715
5721
continue ;
5716
5722
} ;
5717
- if let SignerMessage :: BlockResponse ( BlockResponse :: Rejected ( BlockRejection {
5723
+ let SignerMessage :: BlockResponse ( BlockResponse :: Rejected ( BlockRejection {
5718
5724
reason : _reason,
5719
5725
reason_code,
5720
5726
signer_signature_hash,
5721
5727
signature,
5722
5728
..
5723
5729
} ) ) = message
5724
- {
5725
- if signer_signature_hash == block_signer_signature_hash_1 {
5726
- rejected_signers. push ( signature) ;
5727
- if matches ! ( reason_code, RejectCode :: ConnectivityIssues ) {
5728
- saw_connectivity_complaint = true ;
5729
- }
5730
+ else {
5731
+ continue ;
5732
+ } ;
5733
+ // We are waiting for the original block proposal which will have a diff signature to our
5734
+ // second proposed block.
5735
+ if signer_signature_hash != block_signer_signature_hash_1 {
5736
+ rejected_signers. push ( signature) ;
5737
+ if matches ! ( reason_code, RejectCode :: ConnectivityIssues ) {
5738
+ break ;
5730
5739
}
5731
5740
}
5732
5741
}
5733
5742
assert ! (
5734
- start. elapsed( ) <= Duration :: from_secs ( 10 ) ,
5735
- "Timed out after waiting for response from signer "
5743
+ start. elapsed( ) <= timeout ,
5744
+ "Timed out after waiting for ConenctivityIssues block rejection "
5736
5745
) ;
5737
5746
}
5738
-
5739
- assert ! (
5740
- saw_connectivity_complaint,
5741
- "We did not see the expected connectity rejection reason"
5742
- ) ;
5743
5747
// Make sure our chain has still not advanced
5744
5748
let info_after = get_chain_info ( & signer_test. running_nodes . conf ) ;
5745
5749
assert_eq ! ( info_before, info_after) ;
0 commit comments