]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Wow Zed AI actually passed my refactoring test
authorMatt Joiner <anacrolix@gmail.com>
Mon, 12 May 2025 02:20:01 +0000 (12:20 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 12 May 2025 02:20:01 +0000 (12:20 +1000)
client-nowasm_test.go
client-peerconn_test.go
issue-949_test.go
peerconn_test.go
storage/sqlite/sqlite-storage_test.go
storage/test/bench-piece-mark-complete.go
torrent_test.go
tracker/http/http_test.go
tracker/udp/timeout_test.go
tracker/udp/udp_test.go

index 08ed80ced4df8637df8919c5193939c9fa6fe56d..961c144f94936d8c9eba3028c7eb08c2ac92e53f 100644 (file)
@@ -7,7 +7,7 @@ import (
        "os"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/require"
 
        "github.com/anacrolix/torrent/internal/testutil"
@@ -15,7 +15,6 @@ import (
 )
 
 func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
-       c := qt.New(t)
        cfg := TestingConfig(t)
        pc, err := storage.NewBoltPieceCompletion(cfg.DataDir)
        require.NoError(t, err)
@@ -23,7 +22,7 @@ func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
        defer ci.Close()
        cfg.DefaultStorage = ci
        cl, err := NewClient(cfg)
-       c.Assert(err, qt.IsNil, qt.Commentf("%#v", err))
+       qt.Assert(t, qt.IsNil(err), qt.Commentf("%#v", err))
        cl.Close()
        // And again, https://github.com/anacrolix/torrent/issues/158
        cl, err = NewClient(cfg)
@@ -51,22 +50,21 @@ func TestIssue335(t *testing.T) {
        cfg.Debug = true
        cfg.DataDir = dir
        comp, err := storage.NewBoltPieceCompletion(dir)
-       c := qt.New(t)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer logErr(comp.Close, "closing bolt piece completion")
        mmapStorage := storage.NewMMapWithCompletion(dir, comp)
-       defer logErr(mmapStorage.Close, "closing mmap storage")
+       defer mmapStorage.Close()
        cfg.DefaultStorage = mmapStorage
        cl, err := NewClient(cfg)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cl.Close()
        tor, new, err := cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
-       c.Assert(err, qt.IsNil)
-       c.Assert(new, qt.IsTrue)
-       c.Assert(cl.WaitAll(), qt.IsTrue)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Assert(t, qt.IsTrue(new))
+       qt.Assert(t, qt.IsTrue(cl.WaitAll()))
        tor.Drop()
        _, new, err = cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
-       c.Assert(err, qt.IsNil)
-       c.Assert(new, qt.IsTrue)
-       c.Assert(cl.WaitAll(), qt.IsTrue)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Assert(t, qt.IsTrue(new))
+       qt.Assert(t, qt.IsTrue(cl.WaitAll()))
 }
index 2620f35abadfc553b139278f32261ab8ea3f76cc..d062a134305b721877b315e936f3a74fee719b50 100644 (file)
@@ -8,7 +8,7 @@ import (
 
        "github.com/anacrolix/missinggo/v2"
        "github.com/anacrolix/missinggo/v2/bitmap"
-       "github.com/frankban/quicktest"
+       "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
        "golang.org/x/time/rate"
@@ -185,5 +185,5 @@ func assertReadAllGreeting(t *testing.T, r io.ReadSeeker) {
        pos, err := r.Seek(0, io.SeekStart)
        assert.NoError(t, err)
        assert.EqualValues(t, 0, pos)
-       quicktest.Check(t, iotest.TestReader(r, []byte(testutil.GreetingFileContents)), quicktest.IsNil)
+       qt.Check(t, qt.IsNil(iotest.TestReader(r, []byte(testutil.GreetingFileContents))))
 }
index 89b459294c5ce451ad26c84c414577b5ecb7cbee..60e8c720ffd3004e74ebc337d0a3e0962b2afd91 100644 (file)
@@ -3,7 +3,7 @@ package torrent
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent/metainfo"
 )
@@ -19,11 +19,10 @@ func TestIssue949LastPieceZeroPadding(t *testing.T) {
                panic(err)
        }
        lastPiece := info.Piece(info.NumPieces() - 1)
-       c := qt.New(t)
-       c.Assert(info.FilesArePieceAligned(), qt.IsTrue)
+       qt.Assert(t, qt.IsTrue(info.FilesArePieceAligned()))
        // Check the v1 piece length includes the trailing padding file.
-       c.Check(lastPiece.V1Length(), qt.Equals, info.PieceLength)
+       qt.Check(t, qt.Equals(lastPiece.V1Length(), info.PieceLength))
        // The v2 piece should only include the file data, which fits inside the piece length for this
        // file.
-       c.Check(lastPiece.Length(), qt.Equals, int64(3677645))
+       qt.Check(t, qt.Equals(lastPiece.Length(), int64(3677645)))
 }
index e3d1c8a3bd9e4ae276864016e58c0b8cdf918098..44309293f7cd6727da8983d4ad9751c3da3bfbbf 100644 (file)
@@ -11,8 +11,7 @@ import (
        "testing"
 
        g "github.com/anacrolix/generics"
-       "github.com/frankban/quicktest"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/require"
        "golang.org/x/time/rate"
 
@@ -27,11 +26,10 @@ func TestSendBitfieldThenHave(t *testing.T) {
        var cl Client
        cl.init(TestingConfig(t))
        cl.initLogger()
-       qtc := qt.New(t)
        c := cl.newConnection(nil, newConnectionOpts{network: "io.Pipe"})
        c.setTorrent(cl.newTorrentForTesting())
        err := c.t.setInfo(&metainfo.Info{Pieces: make([]byte, metainfo.HashSize*3)})
-       qtc.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        r, w := io.Pipe()
        // c.r = r
        c.w = w
@@ -91,7 +89,6 @@ func (me *torrentStorage) WriteAt(b []byte, _ int64) (int, error) {
 }
 
 func BenchmarkConnectionMainReadLoop(b *testing.B) {
-       c := quicktest.New(b)
        var cl Client
        cl.init(&ClientConfig{
                DownloadRateLimiter: unlimited,
@@ -109,7 +106,7 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
        t.onSetInfo()
        t._pendingPieces.Add(0)
        r, w := net.Pipe()
-       c.Logf("pipe reader remote addr: %v", r.RemoteAddr())
+       b.Logf("pipe reader remote addr: %v", r.RemoteAddr())
        cn := cl.newConnection(r, newConnectionOpts{
                outgoing: true,
                // TODO: This is a hack to give the pipe a bannable remote address.
@@ -117,7 +114,7 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
                network:    r.RemoteAddr().Network(),
                connString: regularNetConnPeerConnConnString(r),
        })
-       c.Assert(cn.bannableAddr.Ok, qt.IsTrue)
+       qt.Assert(b, qt.IsTrue(cn.bannableAddr.Ok))
        cn.setTorrent(t)
        requestIndexBegin := t.pieceRequestIndexOffset(0)
        requestIndexEnd := t.pieceRequestIndexOffset(1)
@@ -187,9 +184,9 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
                        break
                }
        }
-       c.Assert(err, qt.IsNil)
-       c.Assert(cn._stats.ChunksReadUseful.Int64(), quicktest.Equals, int64(b.N)*int64(numRequests))
-       c.Assert(t.smartBanCache.HasBlocks(), qt.IsTrue)
+       qt.Assert(b, qt.IsNil(err))
+       qt.Assert(b, qt.Equals(cn._stats.ChunksReadUseful.Int64(), int64(b.N)*int64(numRequests)))
+       qt.Assert(b, qt.IsTrue(t.smartBanCache.HasBlocks()))
 }
 
 func TestConnPexPeerFlags(t *testing.T) {
@@ -217,7 +214,6 @@ func TestConnPexPeerFlags(t *testing.T) {
 }
 
 func TestConnPexEvent(t *testing.T) {
-       c := qt.New(t)
        var (
                udpAddr     = &net.UDPAddr{IP: net.IPv6loopback, Port: 4848}
                tcpAddr     = &net.TCPAddr{IP: net.IPv6loopback, Port: 4848}
@@ -260,16 +256,15 @@ func TestConnPexEvent(t *testing.T) {
                },
        }
        for i, tc := range testcases {
-               c.Run(fmt.Sprintf("%v", i), func(c *qt.C) {
+               t.Run(fmt.Sprintf("%v", i), func(t *testing.T) {
                        e, err := tc.c.pexEvent(tc.t)
-                       c.Assert(err, qt.IsNil)
-                       c.Check(e, qt.Equals, tc.e)
+                       qt.Assert(t, qt.IsNil(err))
+                       qt.Check(t, qt.Equals(e, tc.e))
                })
        }
 }
 
 func TestHaveAllThenBitfield(t *testing.T) {
-       c := qt.New(t)
        cl := newTestingClient(t)
        tt := cl.newTorrentForTesting()
        // cl.newConnection()
@@ -279,30 +274,29 @@ func TestHaveAllThenBitfield(t *testing.T) {
        pc.initRequestState()
        pc.legacyPeerImpl = &pc
        tt.conns[&pc] = struct{}{}
-       c.Assert(pc.onPeerSentHaveAll(), qt.IsNil)
-       c.Check(pc.t.connsWithAllPieces, qt.DeepEquals, map[*Peer]struct{}{&pc.Peer: {}})
+       qt.Assert(t, qt.IsNil(pc.onPeerSentHaveAll()))
+       qt.Check(t, qt.DeepEquals(pc.t.connsWithAllPieces, map[*Peer]struct{}{&pc.Peer: {}}))
        pc.peerSentBitfield([]bool{false, false, true, false, true, true, false, false})
-       c.Check(pc.peerMinPieces, qt.Equals, 6)
-       c.Check(pc.t.connsWithAllPieces, qt.HasLen, 0)
-       c.Assert(pc.t.setInfo(&metainfo.Info{
+       qt.Check(t, qt.Equals(pc.peerMinPieces, 6))
+       qt.Check(t, qt.HasLen(pc.t.connsWithAllPieces, 0))
+       qt.Assert(t, qt.IsNil(pc.t.setInfo(&metainfo.Info{
                PieceLength: 0,
                Pieces:      make([]byte, pieceHash.Size()*7),
-       }), qt.IsNil)
+       })))
        pc.t.onSetInfo()
-       c.Check(tt.numPieces(), qt.Equals, 7)
-       c.Check(tt.pieceAvailabilityRuns(), qt.DeepEquals, []pieceAvailabilityRun{
+       qt.Check(t, qt.Equals(tt.numPieces(), 7))
+       qt.Check(t, qt.DeepEquals(tt.pieceAvailabilityRuns(), []pieceAvailabilityRun{
                // The last element of the bitfield is irrelevant, as the Torrent actually only has 7
                // pieces.
                {2, 0}, {1, 1}, {1, 0}, {2, 1}, {1, 0},
-       })
+       }))
 }
 
 func TestApplyRequestStateWriteBufferConstraints(t *testing.T) {
-       c := qt.New(t)
-       c.Check(interestedMsgLen, qt.Equals, 5)
-       c.Check(requestMsgLen, qt.Equals, 17)
-       c.Check(maxLocalToRemoteRequests >= 8, qt.IsTrue)
-       c.Logf("max local to remote requests: %v", maxLocalToRemoteRequests)
+       qt.Check(t, qt.Equals(interestedMsgLen, 5))
+       qt.Check(t, qt.Equals(requestMsgLen, 17))
+       qt.Check(t, qt.IsTrue(maxLocalToRemoteRequests >= 8))
+       t.Logf("max local to remote requests: %v", maxLocalToRemoteRequests)
 }
 
 func peerConnForPreferredNetworkDirection(
@@ -328,42 +322,34 @@ func peerConnForPreferredNetworkDirection(
 
 func TestPreferredNetworkDirection(t *testing.T) {
        pc := peerConnForPreferredNetworkDirection
-       c := qt.New(t)
 
        // Prefer outgoing to lower peer ID
 
-       c.Check(
-               pc(1, 2, true, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, false)),
-               qt.IsFalse,
+       qt.Check(t,
+               qt.IsFalse(pc(1, 2, true, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, false))),
        )
-       c.Check(
-               pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, true, false, false)),
-               qt.IsTrue,
+       qt.Check(t,
+               qt.IsTrue(pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, true, false, false))),
        )
-       c.Check(
-               pc(2, 1, false, false, false).hasPreferredNetworkOver(pc(2, 1, true, false, false)),
-               qt.IsFalse,
+       qt.Check(t,
+               qt.IsFalse(pc(2, 1, false, false, false).hasPreferredNetworkOver(pc(2, 1, true, false, false))),
        )
 
        // Don't prefer uTP
-       c.Check(
-               pc(1, 2, false, true, false).hasPreferredNetworkOver(pc(1, 2, false, false, false)),
-               qt.IsFalse,
+       qt.Check(t,
+               qt.IsFalse(pc(1, 2, false, true, false).hasPreferredNetworkOver(pc(1, 2, false, false, false))),
        )
        // Prefer IPv6
-       c.Check(
-               pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, true)),
-               qt.IsFalse,
+       qt.Check(t,
+               qt.IsFalse(pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, true))),
        )
        // No difference
-       c.Check(
-               pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, false)),
-               qt.IsFalse,
+       qt.Check(t,
+               qt.IsFalse(pc(1, 2, false, false, false).hasPreferredNetworkOver(pc(1, 2, false, false, false))),
        )
 }
 
 func TestReceiveLargeRequest(t *testing.T) {
-       c := qt.New(t)
        cl := newTestingClient(t)
        pc := cl.newConnection(nil, newConnectionOpts{network: "test"})
        tor := cl.newTorrentForTesting()
@@ -375,26 +361,25 @@ func TestReceiveLargeRequest(t *testing.T) {
        pc.initMessageWriter()
        req := Request{}
        req.Length = defaultChunkSize
-       c.Assert(pc.fastEnabled(), qt.IsTrue)
-       c.Check(pc.onReadRequest(req, false), qt.IsNil)
-       c.Check(pc.peerRequests, qt.HasLen, 1)
+       qt.Assert(t, qt.IsTrue(pc.fastEnabled()))
+       qt.Check(t, qt.IsNil(pc.onReadRequest(req, false)))
+       qt.Check(t, qt.HasLen(pc.peerRequests, 1))
        req.Length = 2 << 20
-       c.Check(pc.onReadRequest(req, false), qt.IsNil)
-       c.Check(pc.peerRequests, qt.HasLen, 2)
+       qt.Check(t, qt.IsNil(pc.onReadRequest(req, false)))
+       qt.Check(t, qt.HasLen(pc.peerRequests, 2))
        pc.peerRequests = nil
        pc.t.cl.config.UploadRateLimiter = rate.NewLimiter(1, defaultChunkSize)
        req.Length = defaultChunkSize
-       c.Check(pc.onReadRequest(req, false), qt.IsNil)
-       c.Check(pc.peerRequests, qt.HasLen, 1)
+       qt.Check(t, qt.IsNil(pc.onReadRequest(req, false)))
+       qt.Check(t, qt.HasLen(pc.peerRequests, 1))
        req.Length = 2 << 20
-       c.Check(pc.onReadRequest(req, false), qt.IsNil)
-       c.Check(pc.messageWriter.writeBuffer.Len(), qt.Equals, 17)
+       qt.Check(t, qt.IsNil(pc.onReadRequest(req, false)))
+       qt.Check(t, qt.Equals(pc.messageWriter.writeBuffer.Len(), 17))
 }
 
 func TestChunkOverflowsPiece(t *testing.T) {
-       c := qt.New(t)
        check := func(begin, length, limit pp.Integer, expected bool) {
-               c.Check(chunkOverflowsPiece(ChunkSpec{begin, length}, limit), qt.Equals, expected)
+               qt.Check(t, qt.Equals(chunkOverflowsPiece(ChunkSpec{begin, length}, limit), expected))
        }
        check(2, 3, 1, true)
        check(2, pp.IntegerMax, 1, true)
index a566322d708b5d78075e983684f58d4f3d698ae1..3925734a863654eab0d324bad323266db62258c4 100644 (file)
@@ -12,7 +12,7 @@ import (
        _ "github.com/anacrolix/envpprof"
        "github.com/anacrolix/squirrel"
        "github.com/dustin/go-humanize"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent/storage"
        test_storage "github.com/anacrolix/torrent/storage/test"
@@ -47,7 +47,6 @@ func BenchmarkMarkComplete(b *testing.B) {
        runBench := func(b *testing.B, ci storage.ClientImpl) {
                test_storage.BenchmarkPieceMarkComplete(b, ci, pieceSize, test_storage.DefaultNumPieces, capacity)
        }
-       c := qt.New(b)
        b.Run("CustomDirect", func(b *testing.B) {
                var opts squirrel.NewCacheOpts
                opts.Capacity = capacity
@@ -55,7 +54,7 @@ func BenchmarkMarkComplete(b *testing.B) {
                benchOpts := func(b *testing.B) {
                        opts.Path = filepath.Join(b.TempDir(), "storage.db")
                        ci, err := NewDirectStorage(opts)
-                       c.Assert(err, qt.IsNil)
+                       qt.Assert(b, qt.IsNil(err))
                        defer ci.Close()
                        runBench(b, ci)
                }
@@ -75,7 +74,7 @@ func BenchmarkMarkComplete(b *testing.B) {
                                        if errors.As(err, &ujm) {
                                                b.Skipf("setting journal mode %q: %v", opts.SetJournalMode, err)
                                        }
-                                       c.Assert(err, qt.IsNil)
+                                       qt.Assert(b, qt.IsNil(err))
                                        defer ci.Close()
                                        runBench(b, ci)
                                }
index b665bf4160c702ab19622362f8f52d155eec351e..dee46a88b2508a889335e2b88f08633b0838b713 100644 (file)
@@ -7,7 +7,7 @@ import (
        "sync"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent/metainfo"
        "github.com/anacrolix/torrent/storage"
@@ -28,7 +28,6 @@ func BenchmarkPieceMarkComplete(
        // implementation.
        capacity int64,
 ) {
-       c := qt.New(b)
        info := &metainfo.Info{
                Pieces:      make([]byte, numPieces*metainfo.HashSize),
                PieceLength: pieceSize,
@@ -36,7 +35,7 @@ func BenchmarkPieceMarkComplete(
                Name:        "TorrentName",
        }
        ti, err := ci.OpenTorrent(context.Background(), info, metainfo.Hash{})
-       c.Assert(err, qt.IsNil)
+       qt.Assert(b, qt.IsNil(err))
        tw := storage.Torrent{ti}
        defer tw.Close()
        rand.Read(info.Pieces)
@@ -67,14 +66,14 @@ func BenchmarkPieceMarkComplete(
                                pi.MarkNotComplete()
                        }
                        // This might not apply if users of this benchmark don't cache with the expected capacity.
-                       c.Assert(pi.Completion(), qt.Equals, storage.Completion{Complete: false, Ok: true})
-                       c.Assert(pi.MarkComplete(), qt.IsNil)
-                       c.Assert(pi.Completion(), qt.Equals, storage.Completion{Complete: true, Ok: true})
+                       qt.Assert(b, qt.Equals(pi.Completion(), storage.Completion{Complete: false, Ok: true}))
+                       qt.Assert(b, qt.IsNil(pi.MarkComplete()))
+                       qt.Assert(b, qt.Equals(pi.Completion(), storage.Completion{Complete: true, Ok: true}))
                        n, err := pi.WriteTo(bytes.NewBuffer(readData[:0]))
                        b.StopTimer()
-                       c.Assert(err, qt.IsNil)
-                       c.Assert(n, qt.Equals, int64(len(data)))
-                       c.Assert(bytes.Equal(readData[:n], data), qt.IsTrue)
+                       qt.Assert(b, qt.IsNil(err))
+                       qt.Assert(b, qt.Equals(n, int64(len(data))))
+                       qt.Assert(b, qt.IsTrue(bytes.Equal(readData[:n], data)))
                }
        }
        // Fill the cache
index 2b3a087dc3f69aeead534fc98544f0af1bf38e2e..7940fe2c98c22e4bac4b335b2318a419178f5669 100644 (file)
@@ -13,7 +13,7 @@ import (
        g "github.com/anacrolix/generics"
        "github.com/anacrolix/missinggo/v2"
        "github.com/anacrolix/missinggo/v2/bitmap"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 
@@ -223,7 +223,6 @@ func TestTorrentMetainfoIncompleteMetadata(t *testing.T) {
 }
 
 func TestRelativeAvailabilityHaveNone(t *testing.T) {
-       c := qt.New(t)
        var err error
        cl := newTestingClient(t)
        mi, info := testutil.Greeting.Generate(5)
@@ -237,12 +236,12 @@ func TestRelativeAvailabilityHaveNone(t *testing.T) {
        g.InitNew(&pc.callbacks)
        tt.conns[&pc] = struct{}{}
        err = pc.peerSentHave(0)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        err = tt.setInfo(&info)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        tt.onSetInfo()
        err = pc.peerSentHaveNone()
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        var wg sync.WaitGroup
        tt.close(&wg)
        tt.assertAllPiecesRelativeAvailabilityZero()
index 4e5efaf5721c1e4fad9cc379e90c1f6aaef788e4..fd5e580713bf2bee06091635d5379aa42c2835bb 100644 (file)
@@ -4,7 +4,7 @@ import (
        "net/url"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 
@@ -68,9 +68,8 @@ func TestSetAnnounceInfohashParamWithSpaces(t *testing.T) {
                },
                AnnounceOpt{})
        t.Logf("%q", someUrl)
-       qt.Assert(t, someUrl.Query().Get("info_hash"), qt.Equals, string(ihBytes[:]))
+       qt.Assert(t, qt.Equals(someUrl.Query().Get("info_hash"), string(ihBytes[:])))
        qt.Check(t,
-               someUrl.String(),
-               qt.Contains,
-               "info_hash=%2Bv%0A%A1x%93%200%C8G%DC%DF%8E%AE%BFV%0A%1B%D1l")
+               qt.StringContains(someUrl.String(),
+               "info_hash=%2Bv%0A%A1x%93%200%C8G%DC%DF%8E%AE%BFV%0A%1B%D1l"))
 }
index 4bb0dc83f09609e474f82ae5c7b1bb9e333034d3..85749566e01d2ebb22c360b9a271846fc01c1438 100644 (file)
@@ -4,12 +4,11 @@ import (
        "math"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestTimeoutMax(t *testing.T) {
-       c := qt.New(t)
-       c.Check(timeout(8), qt.Equals, maxTimeout)
-       c.Check(timeout(9), qt.Equals, maxTimeout)
-       c.Check(timeout(math.MaxInt32), qt.Equals, maxTimeout)
+       qt.Check(t, qt.Equals(timeout(8), maxTimeout))
+       qt.Check(t, qt.Equals(timeout(9), maxTimeout))
+       qt.Check(t, qt.Equals(timeout(math.MaxInt32), maxTimeout))
 }
index 378351cd81d760ef5f6e6eb7bd9563209245a2eb..bc73286751771965eca8d3245eb2ca99f799387e 100644 (file)
@@ -14,7 +14,7 @@ import (
        "github.com/anacrolix/dht/v2/krpc"
        _ "github.com/anacrolix/envpprof"
        "github.com/anacrolix/missinggo/v2/iter"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/require"
 )
 
@@ -88,19 +88,18 @@ func TestConnClientLogDispatchUnknownTransactionId(t *testing.T) {
        cc, err := NewConnClient(NewConnClientOpts{
                Network: network,
        })
-       c := qt.New(t)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cc.Close()
        pc, err := net.ListenPacket(network, ":0")
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer pc.Close()
        ccAddr := *cc.LocalAddr().(*net.UDPAddr)
        ipAddrs, err := net.DefaultResolver.LookupIPAddr(context.Background(), "localhost")
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        ccAddr.IP = ipAddrs[0].IP
        ccAddr.Zone = ipAddrs[0].Zone
        _, err = pc.WriteTo(make([]byte, 30), &ccAddr)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
 }
 
 func TestConnectionIdMismatch(t *testing.T) {
@@ -112,8 +111,7 @@ func TestConnectionIdMismatch(t *testing.T) {
                //Host:    "tracker.opentrackr.org:1337",
                Network: "udp",
        })
-       c := qt.New(t)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cl.Close()
        ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
        defer cancel()