mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rpc : init timer at first
This commit is contained in:
parent
f4f075cd9b
commit
eb616bd618
1 changed files with 4 additions and 11 deletions
|
|
@ -232,12 +232,9 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
|||
wantPong string
|
||||
timer *Timer
|
||||
)
|
||||
//timer := time.NewTimer(200 * time.Millisecond)
|
||||
defer func() {
|
||||
if timer != nil {
|
||||
timer.Stop()
|
||||
}
|
||||
}()
|
||||
timer := time.NewTimer(0)
|
||||
defer timer.Stop()
|
||||
<-timer.C
|
||||
for {
|
||||
select {
|
||||
case _, open := <-sendPing:
|
||||
|
|
@ -254,11 +251,7 @@ func wsPingTestHandler(t *testing.T, conn *websocket.Conn, shutdown, sendPing <-
|
|||
t.Errorf("got pong with wrong data %q", data)
|
||||
}
|
||||
wantPong = ""
|
||||
if timer == nil {
|
||||
timer = time.NewTimer(200 * time.Millisecond)
|
||||
} else {
|
||||
timer.Reset(200 * time.Millisecond)
|
||||
}
|
||||
timer.Reset(200 * time.Millisecond)
|
||||
sendResponse = timer.C
|
||||
case <-sendResponse:
|
||||
t.Logf("server sending response")
|
||||
|
|
|
|||
Loading…
Reference in a new issue