Skip to content

Commit df0cbcc

Browse files
committed
test: update old unit test
Added mock reactor with single channel, to use reactor-specific-peers and maintain connection. Increased timeout, to make test more stable - usually it finishes within 260ms, but sometimes it needs to wait and request for peers again, after 30s.
1 parent 96021b9 commit df0cbcc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

p2p/pex/pex_reactor_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/cometbft/cometbft/config"
1717
"github.com/cometbft/cometbft/libs/log"
1818
"github.com/cometbft/cometbft/p2p"
19+
"github.com/cometbft/cometbft/p2p/conn"
1920
"github.com/cometbft/cometbft/p2p/mock"
2021
tmp2p "github.com/cometbft/cometbft/proto/tendermint/p2p"
2122
)
@@ -91,6 +92,11 @@ func TestPEXReactorRunning(t *testing.T) {
9192
r.SetLogger(logger.With("pex", i))
9293
r.SetEnsurePeersPeriod(250 * time.Millisecond)
9394
sw.AddReactor("pex", r)
95+
mr := mock.NewReactor()
96+
mr.Channels = []*conn.ChannelDescriptor{
97+
{ID: 123, Priority: 123},
98+
}
99+
sw.AddReactor("mock", mr)
94100

95101
return sw
96102
})
@@ -111,7 +117,7 @@ func TestPEXReactorRunning(t *testing.T) {
111117
require.Nil(t, err)
112118
}
113119

114-
assertPeersWithTimeout(t, switches, 10*time.Millisecond, 10*time.Second, N-1)
120+
assertPeersWithTimeout(t, switches, 10*time.Millisecond, 60*time.Second, N-1)
115121

116122
// stop them
117123
for _, s := range switches {

0 commit comments

Comments
 (0)