6
6
"time"
7
7
8
8
"github.com/ipfs/boxo/bitswap/internal/testutil"
9
- "github.com/ipfs/boxo/internal/test"
10
9
"github.com/libp2p/go-libp2p/core/peer"
11
10
"github.com/stretchr/testify/require"
12
11
)
@@ -50,8 +49,6 @@ func wait(t *testing.T, c *connectEventManager) {
50
49
}
51
50
52
51
func TestConnectEventManagerConnectDisconnect (t * testing.T ) {
53
- test .Flaky (t )
54
-
55
52
connListener := newMockConnListener ()
56
53
peers := testutil .GeneratePeers (2 )
57
54
cem := newConnectEventManager (connListener )
@@ -68,31 +65,26 @@ func TestConnectEventManagerConnectDisconnect(t *testing.T) {
68
65
connected : true ,
69
66
})
70
67
71
- // Flush the event queue.
72
- wait (t , cem )
73
68
require .Equal (t , expectedEvents , connListener .events )
74
69
75
- // Block up the event loop.
76
- connListener .Lock ()
77
70
cem .Connected (peers [1 ])
78
71
expectedEvents = append (expectedEvents , mockConnEvent {
79
72
peer : peers [1 ],
80
73
connected : true ,
81
74
})
75
+ require .Equal (t , expectedEvents , connListener .events )
82
76
83
- // We don't expect this to show up.
84
77
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.
89
83
wait (t , cem )
90
84
require .Equal (t , expectedEvents , connListener .events )
91
85
}
92
86
93
87
func TestConnectEventManagerMarkUnresponsive (t * testing.T ) {
94
- test .Flaky (t )
95
-
96
88
connListener := newMockConnListener ()
97
89
p := testutil .GeneratePeers (1 )[0 ]
98
90
cem := newConnectEventManager (connListener )
@@ -142,8 +134,6 @@ func TestConnectEventManagerMarkUnresponsive(t *testing.T) {
142
134
}
143
135
144
136
func TestConnectEventManagerDisconnectAfterMarkUnresponsive (t * testing.T ) {
145
- test .Flaky (t )
146
-
147
137
connListener := newMockConnListener ()
148
138
p := testutil .GeneratePeers (1 )[0 ]
149
139
cem := newConnectEventManager (connListener )
0 commit comments