mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 06:57:24 +00:00
test: fix TestSwitchAcceptRoutine flake by ignoring error type (#6000)
Fixes #5998. Sometimes the connection returns "use of closed network connection" instead, so for now we just accept any error. The switch is not long for this world anyway.
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -607,9 +606,8 @@ func TestSwitchAcceptRoutine(t *testing.T) {
|
||||
err = sw.Start()
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
if err := sw.Stop(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err := sw.Stop()
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
// 0. check there are no peers
|
||||
@@ -634,7 +632,7 @@ func TestSwitchAcceptRoutine(t *testing.T) {
|
||||
}
|
||||
}(c)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
assert.Equal(t, cfg.MaxNumInboundPeers, sw.Peers().Size())
|
||||
|
||||
// 2. check we close new connections if we already have MaxNumInboundPeers peers
|
||||
@@ -647,7 +645,7 @@ func TestSwitchAcceptRoutine(t *testing.T) {
|
||||
err = conn.SetReadDeadline(time.Now().Add(10 * time.Millisecond))
|
||||
require.NoError(t, err)
|
||||
_, err = conn.Read(one)
|
||||
assert.Equal(t, io.EOF, err)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, cfg.MaxNumInboundPeers, sw.Peers().Size())
|
||||
peer.Stop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user