carlos / platform Public

proxyproto: TestQueuedBytes polls without sleeping (code-health ratchet)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 2b9bb4b61ba93434e051ece80c4d23bdbfd60f85 parent 5dc5b83
1 file changed, +4 −2
  • internal/proxyproto/peek_unix_test.go +4 −2

CI passed — run details

diff --git a/internal/proxyproto/peek_unix_test.go b/internal/proxyproto/peek_unix_test.go
index 8da52d1f2..2ba2b7406 100644
--- a/internal/proxyproto/peek_unix_test.go
+++ b/internal/proxyproto/peek_unix_test.go
@@ -4,6 +4,7 @@ package proxyproto
import (
"net"
+ "runtime"
"testing"
"time"
)
@@ -52,14 +53,15 @@ func TestQueuedBytes(t *testing.T) {
if time.Now().After(deadline) {
t.Fatal("written byte never seen")
}
- time.Sleep(time.Millisecond)
+ runtime.Gosched() // loopback delivery is immediate; this only yields
}
b := make([]byte, 1)
if n, err := server.Read(b); n != 1 || b[0] != 'x' || err != nil {
t.Fatalf("peek consumed the byte: %d %q %v", n, b[:n], err)
}
+ // After the peer closes, whether its FIN has landed yet or not, nothing
+ // is queued and the answer is known.
client.Close()
- time.Sleep(20 * time.Millisecond)
if queued, known := queuedBytes(server); queued || !known {
t.Fatalf("closed by peer: queued %v known %v, want false true", queued, known)
}