]> Sergey Matveev's repositories - btrtrc.git/blobdiff - tracker/udp_test.go
gorond test files
[btrtrc.git] / tracker / udp_test.go
index 323047306f02c6f7ac60cfc1b6e698b712de5f79..cf18e0de9f2dc20fc07f7f13fd9a6b99fc48fe03 100644 (file)
@@ -15,14 +15,16 @@ import (
 
        "github.com/anacrolix/dht/v2/krpc"
        _ "github.com/anacrolix/envpprof"
-       "github.com/anacrolix/torrent/tracker/udp"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
+
+       "github.com/anacrolix/torrent/tracker/udp"
 )
 
 var trackers = []string{
        "udp://tracker.opentrackr.org:1337/announce",
        "udp://tracker.openbittorrent.com:6969/announce",
+       "udp://localhost:42069",
 }
 
 func TestAnnounceLocalhost(t *testing.T) {
@@ -40,7 +42,7 @@ func TestAnnounceLocalhost(t *testing.T) {
                },
        }
        var err error
-       srv.pc, err = net.ListenPacket("udp", ":0")
+       srv.pc, err = net.ListenPacket("udp", "localhost:0")
        require.NoError(t, err)
        defer srv.pc.Close()
        go func() {
@@ -92,7 +94,7 @@ func TestUDPTracker(t *testing.T) {
                t.Skip(err)
        }
        require.NoError(t, err)
-       t.Log(ar)
+       t.Logf("%+v", ar)
 }
 
 func TestAnnounceRandomInfoHashThirdParty(t *testing.T) {
@@ -143,7 +145,7 @@ func TestAnnounceRandomInfoHashThirdParty(t *testing.T) {
 
 // Check that URLPath option is done correctly.
 func TestURLPathOption(t *testing.T) {
-       conn, err := net.ListenUDP("udp", nil)
+       conn, err := net.ListenPacket("udp", "localhost:0")
        if err != nil {
                panic(err)
        }
@@ -161,6 +163,7 @@ func TestURLPathOption(t *testing.T) {
                announceErr <- err
        }()
        var b [512]byte
+       // conn.SetReadDeadline(time.Now().Add(time.Second))
        _, addr, _ := conn.ReadFrom(b[:])
        r := bytes.NewReader(b[:])
        var h udp.RequestHeader