@@ -51,6 +51,11 @@ use crate::Config;
5151/// Used to test that the signers will broadcast a block if it gets enough signatures
5252pub static TEST_IGNORE_SIGNERS : LazyLock < TestFlag < bool > > = LazyLock :: new ( TestFlag :: default) ;
5353
54+ #[ cfg( test) ]
55+ /// Fault injection flag to prevent the miner from notifying listeners about signer signatures across a block.
56+ pub static TEST_STALL_BLOCK_NOTIFICATION : LazyLock < TestFlag < bool > > =
57+ LazyLock :: new ( TestFlag :: default) ;
58+
5459/// How long should the coordinator poll on the event receiver before
5560/// waking up to check timeouts?
5661pub static EVENT_RECEIVER_POLL : Duration = Duration :: from_millis ( 500 ) ;
@@ -425,6 +430,7 @@ impl StackerDBListener {
425430
426431 if block. total_weight_approved >= self . weight_threshold {
427432 // Signal to anyone waiting on this block that we have enough signatures
433+ Self :: fault_injection_stall_notification ( ) ;
428434 cvar. notify_all ( ) ;
429435 }
430436
@@ -605,6 +611,24 @@ impl StackerDBListener {
605611 fn fault_injection_ignore_signatures ( ) -> bool {
606612 false
607613 }
614+
615+ #[ cfg( test) ]
616+ fn fault_injection_stall_notification ( ) {
617+ let mut first_stall = true ;
618+ while TEST_STALL_BLOCK_NOTIFICATION . get ( ) {
619+ std:: thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
620+ if first_stall {
621+ warn ! ( "StackerDBListener: fault injection: stalling block notification to miner" ) ;
622+ first_stall = false ;
623+ }
624+ }
625+ info ! ( "StackerDBListener: fault injection: resuming block notification to miner" ) ;
626+ }
627+
628+ #[ cfg( not( test) ) ]
629+ fn fault_injection_stall_notification ( ) {
630+ // no-op
631+ }
608632}
609633
610634impl Drop for StackerDBListener {
0 commit comments