Skip to content

Commit 09910a2

Browse files
committed
Re-enable stream ping tests
Should not fail now that I've adjusted the chunk size.
1 parent b74c66b commit 09910a2

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

conn_test.go

+26-23
Original file line numberDiff line numberDiff line change
@@ -1141,14 +1141,13 @@ func TestAutobahn(t *testing.T) {
11411141
err := c.PingWithPayload(ctx, string(p))
11421142
return assertCloseStatus(err, websocket.StatusProtocolError)
11431143
})
1144-
// See comment on the tenStreamedPings test.
1145-
// run(t, "streamPingPayload", func(ctx context.Context, c *websocket.Conn) error {
1146-
// err := assertStreamPing(ctx, c, 125)
1147-
// if err != nil {
1148-
// return err
1149-
// }
1150-
// return c.Close(websocket.StatusNormalClosure, "")
1151-
// })
1144+
run(t, "streamPingPayload", func(ctx context.Context, c *websocket.Conn) error {
1145+
err := assertStreamPing(ctx, c, 125)
1146+
if err != nil {
1147+
return err
1148+
}
1149+
return c.Close(websocket.StatusNormalClosure, "")
1150+
})
11521151
t.Run("unsolicitedPong", func(t *testing.T) {
11531152
t.Parallel()
11541153

@@ -1212,18 +1211,16 @@ func TestAutobahn(t *testing.T) {
12121211
return assertCloseStatus(err, websocket.StatusNormalClosure)
12131212
})
12141213

1215-
// Streamed pings tests are not useful with this implementation since we always
1216-
// use io.ReadFull. These tests cause failures when running with -race on my mac.
1217-
// run(t, "tenStreamedPings", func(ctx context.Context, c *websocket.Conn) error {
1218-
// for i := 0; i < 10; i++ {
1219-
// err := assertStreamPing(ctx, c, 125)
1220-
// if err != nil {
1221-
// return err
1222-
// }
1223-
// }
1224-
//
1225-
// return c.Close(websocket.StatusNormalClosure, "")
1226-
// })
1214+
run(t, "tenStreamedPings", func(ctx context.Context, c *websocket.Conn) error {
1215+
for i := 0; i < 10; i++ {
1216+
err := assertStreamPing(ctx, c, 125)
1217+
if err != nil {
1218+
return err
1219+
}
1220+
}
1221+
1222+
return c.Close(websocket.StatusNormalClosure, "")
1223+
})
12271224
})
12281225

12291226
// Section 3.
@@ -1964,11 +1961,17 @@ func assertStreamPing(ctx context.Context, c *websocket.Conn, l int) error {
19641961
if err != nil {
19651962
return fmt.Errorf("failed to write byte %d: %w", i, err)
19661963
}
1967-
err = c.BW().Flush()
1968-
if err != nil {
1969-
return fmt.Errorf("failed to flush byte %d: %w", i, err)
1964+
if i%32 == 0 {
1965+
err = c.BW().Flush()
1966+
if err != nil {
1967+
return fmt.Errorf("failed to flush at byte %d: %w", i, err)
1968+
}
19701969
}
19711970
}
1971+
err = c.BW().Flush()
1972+
if err != nil {
1973+
return fmt.Errorf("failed to flush: %v", err)
1974+
}
19721975
return assertReadFrame(ctx, c, websocket.OpPong, bytes.Repeat([]byte{0xFE}, l))
19731976
}
19741977

0 commit comments

Comments
 (0)