From aeb4ad65967178036430221b185830fccd32360d Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Mon, 5 Feb 2024 15:40:55 +0300 Subject: [PATCH] fix flapping test --- internal/testutil/udpechoserver.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/testutil/udpechoserver.go b/internal/testutil/udpechoserver.go index 9e861b7..8702a47 100644 --- a/internal/testutil/udpechoserver.go +++ b/internal/testutil/udpechoserver.go @@ -24,7 +24,7 @@ func (s *UDPEchoServer) ReceivedMsg(num int) (b []byte) { s.mu.Lock() defer s.mu.Unlock() - if len(s.received) < num { + if len(s.received) <= num { return nil } @@ -96,10 +96,11 @@ func (s *UDPEchoServer) serveConn(conn net.Conn) { msg := make([]byte, n) copy(msg, buf[:n]) - _, _ = conn.Write(msg) s.mu.Lock() s.received = append(s.received, msg) s.mu.Unlock() + + _, _ = conn.Write(msg) } }