mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rpc: simplify wsPingTestHandler
This commit is contained in:
parent
eb616bd618
commit
792c779892
1 changed files with 2 additions and 6 deletions
|
|
@ -228,11 +228,9 @@ 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 *Timer
|
timer = time.NewTimer(0)
|
||||||
)
|
)
|
||||||
timer := time.NewTimer(0)
|
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
<-timer.C
|
<-timer.C
|
||||||
for {
|
for {
|
||||||
|
|
@ -252,11 +250,9 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
||||||
}
|
}
|
||||||
wantPong = ""
|
wantPong = ""
|
||||||
timer.Reset(200 * time.Millisecond)
|
timer.Reset(200 * time.Millisecond)
|
||||||
sendResponse = timer.C
|
case <-timer.C:
|
||||||
case <-sendResponse:
|
|
||||||
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 a new issue