From 0b8ddd872003d348d2f54d93188af4f4e9477b9e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 16 Nov 2014 13:06:32 -0600 Subject: [PATCH] Fix localhost assumption in connecting 2 clients in tests --- fs/torrentfs_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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) -- 2.48.1