rpc: add missing timer.Stop calls in websocket tests (#20863)
This commit is contained in:
parent
f98cabad7c
commit
f7b29ec942
|
@ -142,6 +142,7 @@ func TestClientWebsocketPing(t *testing.T) {
|
||||||
|
|
||||||
// Wait for the subscription result.
|
// Wait for the subscription result.
|
||||||
timeout := time.NewTimer(5 * time.Second)
|
timeout := time.NewTimer(5 * time.Second)
|
||||||
|
defer timeout.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case err := <-sub.Err():
|
case err := <-sub.Err():
|
||||||
|
@ -227,9 +228,11 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
||||||
|
|
||||||
// Write messages.
|
// Write messages.
|
||||||
var (
|
var (
|
||||||
sendResponse <-chan time.Time
|
wantPong string
|
||||||
wantPong string
|
timer = time.NewTimer(0)
|
||||||
)
|
)
|
||||||
|
defer timer.Stop()
|
||||||
|
<-timer.C
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case _, open := <-sendPing:
|
case _, open := <-sendPing:
|
||||||
|
@ -246,11 +249,10 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
||||||
t.Errorf("got pong with wrong data %q", data)
|
t.Errorf("got pong with wrong data %q", data)
|
||||||
}
|
}
|
||||||
wantPong = ""
|
wantPong = ""
|
||||||
sendResponse = time.NewTimer(200 * time.Millisecond).C
|
timer.Reset(200 * time.Millisecond)
|
||||||
case <-sendResponse:
|
case <-timer.C:
|
||||||
t.Logf("server sending response")
|
t.Logf("server sending response")
|
||||||
conn.WriteMessage(websocket.TextMessage, []byte(subNotify))
|
conn.WriteMessage(websocket.TextMessage, []byte(subNotify))
|
||||||
sendResponse = nil
|
|
||||||
case <-shutdown:
|
case <-shutdown:
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue