]> Sergey Matveev's repositories - btrtrc.git/blobdiff - network_test.go
Drop support for go 1.20
[btrtrc.git] / network_test.go
index 32846e4a35cc4ac978c1728104c8b9014bf03829..a1fd8806c9edec772028afb69a74c800ebe7fe2e 100644 (file)
@@ -1,11 +1,11 @@
 package torrent
 
 import (
-       "log"
        "net"
        "testing"
 
-       "github.com/anacrolix/missinggo"
+       "github.com/anacrolix/log"
+       "github.com/anacrolix/missinggo/v2"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 )
@@ -19,12 +19,12 @@ func testListenerNetwork(
        require.NoError(t, err)
        defer l.Close()
        assert.EqualValues(t, expectedNet, l.Addr().Network())
-       log.Print(missinggo.AddrIP(l.Addr()))
-       assert.Equal(t, validIp4, missinggo.AddrIP(l.Addr()).To4() != nil)
+       ip := missinggo.AddrIP(l.Addr())
+       assert.Equal(t, validIp4, ip.To4() != nil, ip)
 }
 
 func listenUtpListener(net, addr string) (l net.Listener, err error) {
-       l, err = NewUtpSocket(net, addr)
+       l, err = NewUtpSocket(net, addr, nil, log.Default)
        return
 }
 
@@ -71,5 +71,11 @@ func TestListenLocalhostNetwork(t *testing.T) {
        testListenerNetwork(t, listenUtpListener, "udp", "udp6", "[::]:0", false)
        testListenerNetwork(t, listenUtpListener, "udp", "udp4", "localhost:0", true)
 
-       testAcceptedConnAddr(t, "tcp", false, dialClosure(net.Dial, "tcp"), listenClosure(net.Listen, "tcp6", ":0"))
+       testAcceptedConnAddr(
+               t,
+               "tcp",
+               false,
+               dialClosure(net.Dial, "tcp"),
+               listenClosure(net.Listen, "tcp6", "localhost:0"),
+       )
 }