Removed the message size limit from ws-test dial
This commit is contained in:
1 parent
0e27d2b2f3
commit
aa06b94870
2 files changed
+38
No files matched your search
@@ -344,6 +344,9 @@ func connect(
|
|||||||
}
|
}
|
||||||
return nil, fmt.Errorf("dialling %s: %w", settings.url, err)
|
return nil, fmt.Errorf("dialling %s: %w", settings.url, err)
|
||||||
}
|
}
|
||||||
|
// dial shows whatever the server sends, and an event can be large (one
|
||||||
|
// after a catch-up lists every new opportunity), so there's no limit.
|
||||||
|
conn.SetReadLimit(-1)
|
||||||
fmt.Fprintf(out, "connected (%s)\n", res.Status) //nolint:errcheck // printing only
|
fmt.Fprintf(out, "connected (%s)\n", res.Status) //nolint:errcheck // printing only
|
||||||
|
|
||||||
return conn, nil
|
return conn, nil
|
||||||
|
|||||||
@@ -198,6 +198,41 @@ func TestDialListen(t *testing.T) {
|
|||||||
waitFor(t, out, "closed by the server (1001)")
|
waitFor(t, out, "closed by the server (1001)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A pushed message larger than the WebSocket library's default read limit
|
||||||
|
// (32KiB), as a catch-up event can be, is printed in full.
|
||||||
|
func TestDialLargeMessage(t *testing.T) {
|
||||||
|
hub, url := wsServer(t)
|
||||||
|
out := &syncBuffer{}
|
||||||
|
|
||||||
|
done := make(chan error, 1)
|
||||||
|
go func() {
|
||||||
|
done <- dial(context.Background(), nil, out, dialSettings{
|
||||||
|
url: url,
|
||||||
|
messages: []string{ping},
|
||||||
|
listen: true,
|
||||||
|
timeout: time.Second,
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
|
waitFor(t, out, `< {"type":"pong","id":"1"`)
|
||||||
|
large := strings.Repeat("x", 100_000)
|
||||||
|
hub.Push("event", map[string]string{"large": large, "end": "here"})
|
||||||
|
// encoding/json sorts a map's keys.
|
||||||
|
waitFor(t, out, `{"end":"here","large":"`+large+`"}}`)
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
|
defer cancel()
|
||||||
|
hub.Shutdown(ctx)
|
||||||
|
select {
|
||||||
|
case err := <-done:
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("dial = %v; want nil when the server closes", err)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("dial did not return when the server closed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// syncBuffer is a bytes.Buffer safe to write from one goroutine while
|
// syncBuffer is a bytes.Buffer safe to write from one goroutine while
|
||||||
// another reads it.
|
// another reads it.
|
||||||
type syncBuffer struct {
|
type syncBuffer struct {
|
||||||
|
|||||||
Reference in new issue
Block a user