From: Matt Joiner Date: Sun, 16 Nov 2014 19:06:32 +0000 (-0600) Subject: Fix localhost assumption in connecting 2 clients in tests X-Git-Tag: v1.0.0~1547 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=0b8ddd872003d348d2f54d93188af4f4e9477b9e;p=btrtrc.git Fix localhost assumption in connecting 2 clients in tests --- diff --git a/fs/torrentfs_test.go b/fs/torrentfs_test.go index 8cd8ebe5..45e75acf 100644 --- a/fs/torrentfs_test.go +++ b/fs/torrentfs_test.go @@ -10,6 +10,7 @@ import ( _ "net/http/pprof" "os" "path/filepath" + "strconv" "testing" "time" @@ -160,10 +161,17 @@ func TestDownloadOnDemand(t *testing.T) { var ih torrent.InfoHash util.CopyExact(ih[:], layout.Metainfo.Info.Hash) leecher.AddPeers(ih, []torrent.Peer{func() torrent.Peer { - tcpAddr := seeder.ListenAddr().(*net.TCPAddr) + _, port, err := net.SplitHostPort(seeder.ListenAddr().String()) + if err != nil { + panic(err) + } + portInt64, err := strconv.ParseInt(port, 0, 0) + if err != nil { + panic(err) + } return torrent.Peer{ - IP: tcpAddr.IP, - Port: tcpAddr.Port, + IP: net.IPv6loopback, + Port: int(portInt64), } }()}) fs := New(leecher)