@@ -76,17 +76,22 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {
7676 lock , p2pkeys , _ := cluster .NewForT (t , 1 , threshold , nodes , seed , random )
7777
7878 var (
79- peers []p2p.Peer
80- hosts []host.Host
81- hostsInfo []peer.AddrInfo
82- components []* qbft.Consensus
83- results = make (chan core.UnsignedDataSet , threshold )
84- runErrs = make (chan error , threshold )
85- sniffed = make (chan int , threshold )
86- ctx , cancel = context .WithCancel (context .Background ())
79+ peers []p2p.Peer
80+ hosts []host.Host
81+ hostsInfo []peer.AddrInfo
82+ components []* qbft.Consensus
83+ results = make (chan core.UnsignedDataSet , threshold )
84+ runErrs = make (chan error , threshold )
85+ sniffed = make (chan int , threshold )
86+ deadlineChan = make (chan core.Duty )
87+ ctx , cancel = context .WithCancel (context .Background ())
8788 )
8889 defer cancel ()
8990
91+ // Add a test timeout to fail fast instead of waiting for CI's 10-minute timeout
92+ testCtx , testCancel := context .WithTimeout (ctx , 30 * time .Second )
93+ defer testCancel ()
94+
9095 // Create hosts and enrs (only for threshold).
9196 for i := range threshold {
9297 addr := testutil .AvailableAddr (t )
@@ -127,7 +132,7 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {
127132
128133 deadliner := coremocks .NewDeadliner (t )
129134 deadliner .On ("Add" , mock .Anything ).Return (true )
130- deadliner .On ("C" ).Return (nil )
135+ deadliner .On ("C" ).Return (( <- chan core. Duty )( deadlineChan ) )
131136
132137 // Create a mock beacon client for test
133138 // Use zero genesis time so timer uses relative timing instead of absolute slot-based timing
@@ -165,6 +170,8 @@ func testQBFTConsensus(t *testing.T, threshold, nodes int) {
165170
166171 for {
167172 select {
173+ case <- testCtx .Done ():
174+ t .Fatal ("test timed out waiting for consensus" )
168175 case err := <- runErrs :
169176 testutil .RequireNoError (t , err )
170177 case res := <- results :
0 commit comments