From bf9301d6bee4427c52bdb414aed1ebff8e9c1c9d Mon Sep 17 00:00:00 2001 From: Neo <321592+Neo-Desktop@users.noreply.github.com> Date: Sun, 8 Nov 2026 21:37:08 -0800 Subject: [PATCH] msn test: wait for the switchboard to close before Carol writes (#39) TestIRC had alice send OUT on her switchboard and Carol write at once. When Carol's message beat the server's handling of OUT, it went to the old switchboard and no RNG came: a flake seen under load (menu's CI). The test now waits for the server to close the connection first. Claude-Session: https://claude.ai/code/session_01B82eRRm1WrfJdB863kw36V Signed-off-by: Claude Co-authored-by: Claude --- internal/msn/msn_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/msn/msn_test.go b/internal/msn/msn_test.go index dc759f7..fd80858 100644 --- a/internal/msn/msn_test.go +++ b/internal/msn/msn_test.go @@ -6,7 +6,9 @@ import ( "context" "crypto/md5" "encoding/hex" + "errors" "fmt" + "io" "log" "net" "path/filepath" @@ -187,6 +189,19 @@ func (cl *client) expect(want string) (string, string) { } } +// gone waits for the server to close the connection. +func (cl *client) gone() { + cl.t.Helper() + for { + if _, _, err := cl.line(); err != nil { + if !errors.Is(err, io.EOF) { + cl.t.Fatalf("waiting for the server to close: %v", err) + } + return + } + } +} + // quiet: nothing beginning with any of these comes for a moment. func (cl *client) quiet(not ...string) { cl.t.Helper() @@ -539,6 +554,7 @@ func TestIRC(t *testing.T) { } as.cmd("OUT") + as.gone() // the server has her out of the switchboard before Carol writes carol.send("PRIVMSG alice :still there?") rng, _ := alice.expect("RNG ") if !strings.HasSuffix(rng, " CarolAnn@bbs.test Carol%20Ann") {