Commit 43b03828 authored by vyzo's avatar vyzo

add new TestDialSelf

so that we exercise the dialWorker dial to self error path
parent 4a69fa2f
......@@ -270,3 +270,26 @@ func TestStressActiveDial(t *testing.T) {
wg.Wait()
}
func TestDialSelf(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
self := peer.ID("ABC")
s := NewSwarm(ctx, self, nil, nil)
defer s.Close()
ds := NewDialSync(s.dialWorker)
// this should fail
_, err := ds.DialLock(ctx, self)
if err != ErrDialToSelf {
t.Fatal("expected error from self dial")
}
// do it twice to make sure we get a new active dial object that fails again
_, err = ds.DialLock(ctx, self)
if err != ErrDialToSelf {
t.Fatal("expected error from self dial")
}
}
......@@ -652,7 +652,7 @@ func TestDialSimultaneousJoin(t *testing.T) {
}
}
func TestDialSelf(t *testing.T) {
func TestDialSelf2(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
......@@ -664,10 +664,4 @@ func TestDialSelf(t *testing.T) {
if err != ErrDialToSelf {
t.Fatal("expected error from self dial")
}
// do it twice to make sure we get a new active dial object that fails again
_, err = s1.DialPeer(ctx, s1.LocalPeer())
if err != ErrDialToSelf {
t.Fatal("expected error from self dial")
}
}
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