2
0
mirror of synced 2025-02-24 06:38:14 +00:00

Unit test for connection address comparison to avoid adding bootstrap peers when already present

This commit is contained in:
Matt Joiner 2013-11-05 00:10:16 +11:00
parent 69c674606f
commit c7ca000f25

View File

@ -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()
}
}