From e7354f6bc0c06a2b4793d519fb44096c486f6ced Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 2 Apr 2020 14:04:20 +0000 Subject: [PATCH] rpc | put the timer out of the loop --- rpc/websocket_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/websocket_test.go b/rpc/websocket_test.go index 65dbab681c..368098704b 100644 --- a/rpc/websocket_test.go +++ b/rpc/websocket_test.go @@ -231,6 +231,8 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <- sendResponse <-chan time.Time wantPong string ) + timer := time.NewTimer(200 * time.Millisecond) + defer timer.Stop() for { select { case _, open := <-sendPing: @@ -247,8 +249,6 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <- t.Errorf("got pong with wrong data %q", data) } wantPong = "" - timer := time.NewTimer(200 * time.Millisecond) - defer timer.Stop() sendResponse = timer.C case <-sendResponse: t.Logf("server sending response")