Skip to content

Commit 7ec68c5

Browse files
rvaggJorropo
authored andcommitted
fix(connecteventmanager): clean up tests for new synchronous flow
1 parent 59a2bca commit 7ec68c5

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

bitswap/network/connecteventmanager_test.go

+6-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/ipfs/boxo/bitswap/internal/testutil"
9-
"github.com/ipfs/boxo/internal/test"
109
"github.com/libp2p/go-libp2p/core/peer"
1110
"github.com/stretchr/testify/require"
1211
)
@@ -50,8 +49,6 @@ func wait(t *testing.T, c *connectEventManager) {
5049
}
5150

5251
func TestConnectEventManagerConnectDisconnect(t *testing.T) {
53-
test.Flaky(t)
54-
5552
connListener := newMockConnListener()
5653
peers := testutil.GeneratePeers(2)
5754
cem := newConnectEventManager(connListener)
@@ -68,31 +65,26 @@ func TestConnectEventManagerConnectDisconnect(t *testing.T) {
6865
connected: true,
6966
})
7067

71-
// Flush the event queue.
72-
wait(t, cem)
7368
require.Equal(t, expectedEvents, connListener.events)
7469

75-
// Block up the event loop.
76-
connListener.Lock()
7770
cem.Connected(peers[1])
7871
expectedEvents = append(expectedEvents, mockConnEvent{
7972
peer: peers[1],
8073
connected: true,
8174
})
75+
require.Equal(t, expectedEvents, connListener.events)
8276

83-
// We don't expect this to show up.
8477
cem.Disconnected(peers[0])
85-
cem.Connected(peers[0])
86-
87-
connListener.Unlock()
88-
78+
expectedEvents = append(expectedEvents, mockConnEvent{
79+
peer: peers[0],
80+
connected: false,
81+
})
82+
// Flush the event queue.
8983
wait(t, cem)
9084
require.Equal(t, expectedEvents, connListener.events)
9185
}
9286

9387
func TestConnectEventManagerMarkUnresponsive(t *testing.T) {
94-
test.Flaky(t)
95-
9688
connListener := newMockConnListener()
9789
p := testutil.GeneratePeers(1)[0]
9890
cem := newConnectEventManager(connListener)
@@ -142,8 +134,6 @@ func TestConnectEventManagerMarkUnresponsive(t *testing.T) {
142134
}
143135

144136
func TestConnectEventManagerDisconnectAfterMarkUnresponsive(t *testing.T) {
145-
test.Flaky(t)
146-
147137
connListener := newMockConnListener()
148138
p := testutil.GeneratePeers(1)[0]
149139
cem := newConnectEventManager(connListener)

0 commit comments

Comments
 (0)