@@ -8163,47 +8163,51 @@ fn block_proposal_max_age_rejections() {
8163
8163
8164
8164
info ! ( "------------------------- Test Block Proposal Rejected -------------------------" ) ;
8165
8165
// Verify the signers rejected only the SECOND block proposal. The first was not even processed.
8166
- wait_for ( 30 , || {
8167
- let rejections = test_observer:: get_stackerdb_chunks ( )
8166
+ wait_for ( 120 , || {
8167
+ let mut status_map = HashMap :: new ( ) ;
8168
+ for chunk in test_observer:: get_stackerdb_chunks ( )
8168
8169
. into_iter ( )
8169
8170
. flat_map ( |chunk| chunk. modified_slots )
8170
- . map ( |chunk| {
8171
- let Ok ( message) = SignerMessage :: consensus_deserialize ( & mut chunk. data . as_slice ( ) )
8172
- else {
8173
- return None ;
8174
- } ;
8175
- match message {
8176
- SignerMessage :: BlockResponse ( BlockResponse :: Rejected ( BlockRejection {
8177
- signer_signature_hash,
8178
- signature,
8179
- ..
8180
- } ) ) => {
8181
- assert_eq ! (
8182
- signer_signature_hash, block_signer_signature_hash_2,
8183
- "We should only reject the second block"
8184
- ) ;
8185
- Some ( signature)
8186
- }
8187
- SignerMessage :: BlockResponse ( BlockResponse :: Accepted ( BlockAccepted {
8188
- signer_signature_hash,
8189
- ..
8190
- } ) ) => {
8191
- assert_ne ! (
8192
- signer_signature_hash, block_signer_signature_hash_1,
8193
- "We should never have accepted block"
8194
- ) ;
8195
- None
8196
- }
8197
- _ => None ,
8171
+ {
8172
+ let Ok ( message) = SignerMessage :: consensus_deserialize ( & mut chunk. data . as_slice ( ) )
8173
+ else {
8174
+ continue ;
8175
+ } ;
8176
+ match message {
8177
+ SignerMessage :: BlockResponse ( BlockResponse :: Rejected ( BlockRejection {
8178
+ signer_signature_hash,
8179
+ ..
8180
+ } ) ) => {
8181
+ let entry = status_map. entry ( signer_signature_hash) . or_insert ( ( 0 , 0 ) ) ;
8182
+ entry. 0 += 1 ;
8198
8183
}
8199
- } ) ;
8200
- Ok ( rejections. count ( ) > num_signers * 7 / 10 )
8184
+ SignerMessage :: BlockResponse ( BlockResponse :: Accepted ( BlockAccepted {
8185
+ signer_signature_hash,
8186
+ ..
8187
+ } ) ) => {
8188
+ let entry = status_map. entry ( signer_signature_hash) . or_insert ( ( 0 , 0 ) ) ;
8189
+ entry. 1 += 1 ;
8190
+ }
8191
+ _ => continue ,
8192
+ }
8193
+ }
8194
+ let block_1_status = status_map
8195
+ . get ( & block_signer_signature_hash_1)
8196
+ . cloned ( )
8197
+ . unwrap_or ( ( 0 , 0 ) ) ;
8198
+ assert_eq ! ( block_1_status, ( 0 , 0 ) ) ;
8199
+
8200
+ let block_2_status = status_map
8201
+ . get ( & block_signer_signature_hash_2)
8202
+ . cloned ( )
8203
+ . unwrap_or ( ( 0 , 0 ) ) ;
8204
+ assert_eq ! ( block_2_status. 1 , 0 , "Block 2 should always be rejected" ) ;
8205
+
8206
+ info ! ( "Block 2 status" ; "accepted" => block_2_status. 1 , "rejected" => block_2_status. 0 ) ;
8207
+ Ok ( block_2_status. 0 > num_signers * 7 / 10 )
8201
8208
} )
8202
8209
. expect ( "Timed out waiting for block rejections" ) ;
8203
8210
8204
- info ! ( "------------------------- Test Peer Info-------------------------" ) ;
8205
- assert_eq ! ( info_before, get_chain_info( & signer_test. running_nodes. conf) ) ;
8206
-
8207
8211
info ! ( "------------------------- Test Shutdown-------------------------" ) ;
8208
8212
signer_test. shutdown ( ) ;
8209
8213
}
0 commit comments