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
|
wantPong string
|
||||||
timer *Timer
|
timer *Timer
|
||||||
)
|
)
|
||||||
//timer := time.NewTimer(200 * time.Millisecond)
|
timer := time.NewTimer(0)
|
||||||
defer func() {
|
defer timer.Stop()
|
||||||
if timer != nil {
|
<-timer.C
|
||||||
timer.Stop()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case _, open := <-sendPing:
|
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)
|
t.Errorf("got pong with wrong data %q", data)
|
||||||
}
|
}
|
||||||
wantPong = ""
|
wantPong = ""
|
||||||
if timer == nil {
|
timer.Reset(200 * time.Millisecond)
|
||||||
timer = time.NewTimer(200 * time.Millisecond)
|
|
||||||
} else {
|
|
||||||
timer.Reset(200 * time.Millisecond)
|
|
||||||
}
|
|
||||||
sendResponse = timer.C
|
sendResponse = timer.C
|
||||||
case <-sendResponse:
|
case <-sendResponse:
|
||||||
t.Logf("server sending response")
|
t.Logf("server sending response")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue