Skip to content

Commit

Permalink
Merge pull request #85 from libp2p/fix-flaky-accept-test
Browse files Browse the repository at this point in the history
increase timeout in TestConnectionsClosedIfNotAccepted on CI
  • Loading branch information
marten-seemann committed Sep 8, 2021
2 parents e2284ac + 289fcae commit 403b19e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions p2p/net/upgrader/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"io"
"net"
"os"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -94,9 +95,13 @@ func TestAcceptMultipleConns(t *testing.T) {
func TestConnectionsClosedIfNotAccepted(t *testing.T) {
require := require.New(t)

const timeout = 200 * time.Millisecond
var timeout = 100 * time.Millisecond
if os.Getenv("CI") != "" {
timeout = 500 * time.Millisecond
}
origAcceptTimeout := transport.AcceptTimeout
transport.AcceptTimeout = timeout
defer func() { transport.AcceptTimeout = 1 * time.Hour }()
t.Cleanup(func() { transport.AcceptTimeout = origAcceptTimeout })

id, upgrader := createUpgrader(t)
ln := createListener(t, upgrader)
Expand Down

0 comments on commit 403b19e

Please sign in to comment.