Commit 052a1204 authored by Jeromy's avatar Jeromy

add a test to stress the lock order race condition

parent 34e49ba4
...@@ -201,3 +201,27 @@ func TestFailFirst(t *testing.T) { ...@@ -201,3 +201,27 @@ func TestFailFirst(t *testing.T) {
t.Fatal("should have gotten a 'real' conn back") t.Fatal("should have gotten a 'real' conn back")
} }
} }
func TestStressActiveDial(t *testing.T) {
ds := NewDialSync(func(ctx context.Context, p peer.ID) (*Conn, error) {
return nil, nil
})
wg := sync.WaitGroup{}
pid := peer.ID("foo")
makeDials := func() {
for i := 0; i < 10000; i++ {
ds.DialLock(context.Background(), pid)
}
wg.Done()
}
for i := 0; i < 100; i++ {
wg.Add(1)
go makeDials()
}
wg.Wait()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment