From 5834a598160928eefb50530ed408656b6ab98948 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 10 Jan 2018 20:24:31 -0600 Subject: [PATCH] read ping --- p2p/conn/connection.go | 2 +- p2p/conn/connection_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 23c8edc9d..7c7cee344 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -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: diff --git a/p2p/conn/connection_test.go b/p2p/conn/connection_test.go index 5570331e7..863642113 100644 --- a/p2p/conn/connection_test.go +++ b/p2p/conn/connection_test.go @@ -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: