]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix localhost assumption in connecting 2 clients in tests
authorMatt Joiner <anacrolix@gmail.com>
Sun, 16 Nov 2014 19:06:32 +0000 (13:06 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 16 Nov 2014 19:06:32 +0000 (13:06 -0600)
fs/torrentfs_test.go

index 8cd8ebe55a210477e7e68f92ce6576de5579c794..45e75acf25b51ced90d596b5b37fa601150b2d9a 100644 (file)
@@ -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)