From 301b2baca3a204ae818c451f7d54c82a665b149e Mon Sep 17 00:00:00 2001 From: MoofMonkey <11695747+MoofMonkey@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:02:14 +0300 Subject: [PATCH] Fix flaky datagramsession test --- datagramsession/session_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datagramsession/session_test.go b/datagramsession/session_test.go index 997624b7..5979cf3f 100644 --- a/datagramsession/session_test.go +++ b/datagramsession/session_test.go @@ -111,8 +111,8 @@ func TestReadFromDstSessionPreventClosed(t *testing.T) { } func testActiveSessionNotClosed(t *testing.T, readFromDst bool, writeToDst bool) { - const closeAfterIdle = time.Millisecond * 100 - const activeTime = time.Millisecond * 500 + const closeAfterIdle = time.Millisecond * 300 + const activeTime = closeAfterIdle * 3 sessionID := uuid.New() cfdConn, originConn := net.Pipe() @@ -129,7 +129,7 @@ func testActiveSessionNotClosed(t *testing.T, readFromDst bool, writeToDst bool) errGroup, ctx := errgroup.WithContext(ctx) errGroup.Go(func() error { session.Serve(ctx, closeAfterIdle) - if time.Now().Before(startTime.Add(activeTime)) { + if time.Now().Before(activeUntil) { return fmt.Errorf("session closed while it's still active") } return nil