From: Matt Joiner Date: Mon, 4 Nov 2013 13:10:16 +0000 (+1100) Subject: Unit test for connection address comparison to avoid adding bootstrap peers when... X-Git-Tag: v1.0.0~1783 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c7ca000f25aa070b75ce7cbc1963894493638f8f;p=btrtrc.git Unit test for connection address comparison to avoid adding bootstrap peers when already present --- diff --git a/cmd/torrentfs/main_test.go b/cmd/torrentfs/main_test.go new file mode 100644 index 00000000..e4ea512e --- /dev/null +++ b/cmd/torrentfs/main_test.go @@ -0,0 +1,28 @@ +package main + +import ( + "net" + "testing" +) + +func TestTCPAddrString(t *testing.T) { + ta := &net.TCPAddr{ + IP: net.IPv4(127, 0, 0, 1), + Port: 3000, + } + s := ta.String() + l, err := net.Listen("tcp4", "localhost:3000") + if err != nil { + t.Fatal(err) + } + defer l.Close() + c, err := net.Dial("tcp", l.Addr().String()) + if err != nil { + t.Fatal(err) + } + defer c.Close() + ras := c.RemoteAddr().String() + if ras != s { + t.FailNow() + } +}