mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
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 <noreply@anthropic.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
a9f2319640
commit
bf9301d6be
1 file changed
+16
@@ -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") {
|
||||
|
||||
Reference in new issue
Block a user