mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rpc/websocket_test | Add missing timer.Stop calls if response timer is not nil
This commit is contained in:
parent
f15849cf00
commit
e0971d47db
1 changed files with 6 additions and 0 deletions
|
|
@ -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():
|
||||||
|
|
@ -247,6 +248,11 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
||||||
}
|
}
|
||||||
wantPong = ""
|
wantPong = ""
|
||||||
sendResponse = time.NewTimer(200 * time.Millisecond).C
|
sendResponse = time.NewTimer(200 * time.Millisecond).C
|
||||||
|
defer func() {
|
||||||
|
if sendResponse != nil {
|
||||||
|
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))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue