@@ -267,8 +267,8 @@ func TestConnectionHook(t *testing.T) {
267267 EndpointType : EndpointTypeAuto ,
268268 MaxWorkers : 2 ,
269269 HandoffQueueSize : 10 ,
270- MaxHandoffRetries : 3 ,
271- HandoffTimeout : 1 * time .Second , // Shorter timeout for faster test
270+ MaxHandoffRetries : 2 , // Reduced retries for faster test
271+ HandoffTimeout : 500 * time .Millisecond , // Shorter timeout for faster test
272272 LogLevel : 2 ,
273273 }
274274 processor := NewPoolHook (failingDialer , "tcp" , config , nil )
@@ -294,13 +294,12 @@ func TestConnectionHook(t *testing.T) {
294294 }
295295
296296 // Wait for handoff to complete and fail with proper timeout and polling
297- // Use longer timeout to account for handoff timeout + processing time
298- timeout := time .After (5 * time .Second )
297+ timeout := time .After (3 * time .Second )
299298 ticker := time .NewTicker (10 * time .Millisecond )
300299 defer ticker .Stop ()
301300
302301 // wait for handoff to start
303- time .Sleep (100 * time .Millisecond )
302+ time .Sleep (50 * time .Millisecond )
304303 handoffCompleted := false
305304 for ! handoffCompleted {
306305 select {
@@ -318,10 +317,17 @@ func TestConnectionHook(t *testing.T) {
318317 t .Error ("Connection should be removed from pending map after failed handoff" )
319318 }
320319
321- // Handoff state should still be set (since handoff failed)
322- if ! conn .ShouldHandoff () {
323- t .Error ("Connection should still be marked for handoff after failed handoff" )
320+ // Wait for retries to complete (with MaxHandoffRetries=2, it will retry twice then give up)
321+ // Each retry has a delay of handoffTimeout/2 = 250ms, so wait for all retries to complete
322+ time .Sleep (800 * time .Millisecond )
323+
324+ // After max retries are reached, the connection should be removed from pool
325+ // and handoff state should be cleared
326+ if conn .ShouldHandoff () {
327+ t .Error ("Connection should not be marked for handoff after max retries reached" )
324328 }
329+
330+ t .Logf ("EventDrivenHandoffDialerError test completed successfully" )
325331 })
326332
327333 t .Run ("BufferedDataRESP2" , func (t * testing.T ) {
0 commit comments