Commit 27f6c394 authored by vyzo's avatar vyzo

add TestSelfDial

parent acc35e8a
......@@ -651,3 +651,23 @@ func TestDialSimultaneousJoin(t *testing.T) {
t.Fatal("no connection from first dial")
}
}
func TestDialSelf(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
swarms := makeSwarms(ctx, t, 2)
s1 := swarms[0]
defer s1.Close()
_, err := s1.DialPeer(ctx, s1.LocalPeer())
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