@@ -109,8 +109,8 @@ func TestResourceManagerServiceInbound(t *testing.T) {
109
109
defer closeEchos (echos )
110
110
defer closeRcmgrs (echos )
111
111
112
- ready := new (chan struct {})
113
- echos [0 ].BeforeDone = waitForChannel (ready , time .Minute )
112
+ ready := make (chan struct {})
113
+ echos [0 ].BeforeDone ( waitForChannel (ready , time .Minute ) )
114
114
115
115
for i := 1 ; i < 5 ; i ++ {
116
116
err := echos [i ].Host .Connect (context .Background (), peer.AddrInfo {ID : echos [0 ].Host .ID ()})
@@ -120,8 +120,6 @@ func TestResourceManagerServiceInbound(t *testing.T) {
120
120
time .Sleep (10 * time .Millisecond )
121
121
}
122
122
123
- * ready = make (chan struct {})
124
-
125
123
var once sync.Once
126
124
var wg sync.WaitGroup
127
125
for i := 1 ; i < 5 ; i ++ {
@@ -133,7 +131,7 @@ func TestResourceManagerServiceInbound(t *testing.T) {
133
131
if err != nil {
134
132
t .Log (err )
135
133
once .Do (func () {
136
- close (* ready )
134
+ close (ready )
137
135
})
138
136
}
139
137
}(i )
@@ -160,8 +158,9 @@ func TestResourceManagerServicePeerInbound(t *testing.T) {
160
158
defer closeRcmgrs (echos )
161
159
162
160
count := new (int32 )
163
- ready := new (chan struct {})
164
- echos [0 ].BeforeDone = waitForBarrier (count , ready , time .Minute )
161
+ ready := make (chan struct {})
162
+ * count = 4
163
+ echos [0 ].BeforeDone (waitForBarrier (count , ready , time .Minute ))
165
164
166
165
for i := 1 ; i < 5 ; i ++ {
167
166
err := echos [i ].Host .Connect (context .Background (), peer.AddrInfo {ID : echos [0 ].Host .ID ()})
@@ -171,9 +170,6 @@ func TestResourceManagerServicePeerInbound(t *testing.T) {
171
170
time .Sleep (10 * time .Millisecond )
172
171
}
173
172
174
- * count = 4
175
- * ready = make (chan struct {})
176
-
177
173
var wg sync.WaitGroup
178
174
for i := 1 ; i < 5 ; i ++ {
179
175
wg .Add (1 )
@@ -195,8 +191,8 @@ func TestResourceManagerServicePeerInbound(t *testing.T) {
195
191
ResourceServiceErrors : 0 ,
196
192
})
197
193
198
- * ready = make (chan struct {})
199
- echos [0 ].BeforeDone = waitForChannel (ready , time .Minute )
194
+ ready = make (chan struct {})
195
+ echos [0 ].BeforeDone ( waitForChannel (ready , time .Minute ) )
200
196
201
197
var once sync.Once
202
198
for i := 0 ; i < 3 ; i ++ {
@@ -208,7 +204,7 @@ func TestResourceManagerServicePeerInbound(t *testing.T) {
208
204
if err != nil {
209
205
t .Log (err )
210
206
once .Do (func () {
211
- close (* ready )
207
+ close (ready )
212
208
})
213
209
}
214
210
}()
@@ -223,25 +219,25 @@ func TestResourceManagerServicePeerInbound(t *testing.T) {
223
219
})
224
220
}
225
221
226
- func waitForBarrier (count * int32 , ready * chan struct {}, timeout time.Duration ) func () error {
222
+ func waitForBarrier (count * int32 , ready chan struct {}, timeout time.Duration ) func () error {
227
223
return func () error {
228
224
if atomic .AddInt32 (count , - 1 ) == 0 {
229
- close (* ready )
225
+ close (ready )
230
226
}
231
227
232
228
select {
233
- case <- * ready :
229
+ case <- ready :
234
230
return nil
235
231
case <- time .After (timeout ):
236
232
return fmt .Errorf ("timeout" )
237
233
}
238
234
}
239
235
}
240
236
241
- func waitForChannel (ready * chan struct {}, timeout time.Duration ) func () error {
237
+ func waitForChannel (ready chan struct {}, timeout time.Duration ) func () error {
242
238
return func () error {
243
239
select {
244
- case <- * ready :
240
+ case <- ready :
245
241
return nil
246
242
case <- time .After (timeout ):
247
243
return fmt .Errorf ("timeout" )
0 commit comments