Browse Source

read ping

pull/1095/head
Anton Kaliaev 7 years ago
parent
commit
5834a59816
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 6 additions and 1 deletions
  1. +1
    -1
      p2p/conn/connection.go
  2. +5
    -0
      p2p/conn/connection_test.go

+ 1
- 1
p2p/conn/connection.go View File

@ -332,7 +332,7 @@ FOR_LOOP:
c.Logger.Debug("Send Ping")
wire.WriteByte(packetTypePing, c.bufWriter, &n, &err)
c.sendMonitor.Update(int(n))
go c.flush()
c.flush()
c.Logger.Debug("Starting pong timer")
c.pongTimer.Reset(c.config.pongTimeout)
case <-c.pongTimer.C:


+ 5
- 0
p2p/conn/connection_test.go View File

@ -137,6 +137,11 @@ func TestPongTimeoutResultsInError(t *testing.T) {
require.Nil(t, err)
defer mconn.Stop()
go func() {
// read ping
server.Read(make([]byte, 1))
}()
expectErrorAfter := 10*time.Millisecond + mconn.config.pingInterval + mconn.config.pongTimeout
select {
case msgBytes := <-receivedCh:


Loading…
Cancel
Save