rpc/websocket_test : add timer var to make sure the timer finally stopped

This commit is contained in:
ucwong 2020-04-02 10:50:02 +00:00
parent e0971d47db
commit 9759ac7816

View file

@ -247,12 +247,9 @@ 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 := time.NewTimer(200 * time.Millisecond)
defer func() { defer timer.Stop()
if sendResponse != nil { sendResponse = timer.C
sendResponse.Stop()
}
}()
case <-sendResponse: case <-sendResponse:
t.Logf("server sending response") t.Logf("server sending response")
conn.WriteMessage(websocket.TextMessage, []byte(subNotify)) conn.WriteMessage(websocket.TextMessage, []byte(subNotify))