]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Unit test for connection address comparison to avoid adding bootstrap peers when...
authorMatt Joiner <anacrolix@gmail.com>
Mon, 4 Nov 2013 13:10:16 +0000 (00:10 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 4 Nov 2013 13:10:16 +0000 (00:10 +1100)
cmd/torrentfs/main_test.go [new file with mode: 0644]

diff --git a/cmd/torrentfs/main_test.go b/cmd/torrentfs/main_test.go
new file mode 100644 (file)
index 0000000..e4ea512
--- /dev/null
@@ -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()
+       }
+}