Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
fix go vet
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Schwartz committed Apr 15, 2021
1 parent 68ae307 commit f0aa4f2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package swarm

import (
"context"
"errors"
"fmt"
"math/rand"
"strconv"
Expand Down Expand Up @@ -379,8 +380,12 @@ func TestFDLimitUnderflow(t *testing.T) {
addrs = append(addrs, addrWithPort(t, i))
}

wg := sync.WaitGroup{}
wg.Add(1000)
errs := make(chan error, 1000)
for i := 0; i < 1000; i++ {
go func(id peer.ID, i int) {
defer wg.Done()
ctx, cancel := context.WithCancel(context.Background())

resp := make(chan dialResult)
Expand All @@ -406,12 +411,19 @@ func TestFDLimitUnderflow(t *testing.T) {
if res.Err != nil {
return
}
t.Fatal("got dial res, shouldn't")
errs <- errors.New("got dial res, but shouldn't")
}
}(peer.ID(fmt.Sprintf("testpeer%d", i%20)), i)
}

time.Sleep(time.Second * 3)
go func() {
wg.Wait()
close(errs)
}()

for err := range errs {
t.Fatal(err)
}

l.lk.Lock()
fdConsuming := l.fdConsuming
Expand Down

0 comments on commit f0aa4f2

Please sign in to comment.