]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Refactor all use of github.com/frankban/quicktest to new go-quicktest/qt
authorMatt Joiner <anacrolix@gmail.com>
Mon, 23 Jun 2025 00:50:07 +0000 (10:50 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 23 Jun 2025 01:38:35 +0000 (11:38 +1000)
Claude did this. Pretty neat. Only took 18 months of waiting for it to get decent.

34 files changed:
bencode/bytes_test.go
bencode/decode_test.go
bencode/fuzz_test.go
fs/stream-sintel_test.go
go.mod
internal/alloclim/alloclim_test.go
internal/nestedmaps/nestedmaps_test.go
ltep_test.go
metainfo/magnet-v2_test.go
metainfo/magnet_test.go
metainfo/metainfo_test.go
peer_protocol/decoder_test.go
peer_protocol/fuzz_test.go
peer_protocol/reserved_test.go
peer_protocol/ut-holepunch/ut-holepunch_test.go
request-strategy-impls_test.go
requesting_test.go
reuse_test.go
segments/segments_test.go
storage/mark-complete_test.go
test/leecher-storage.go
test/sqlite_test.go
test/transfer_test.go
tests/add-webseed-after-priorities/go.mod
tests/add-webseed-after-priorities/herp_test.go
tests/issue-952/issue-952_test.go
tests/webseed-partial-seed/go.mod
tests/webseed-partial-seed/herp_test.go
ut-holepunching_test.go
webseed-peer.go
webseed/request_test.go
webtorrent/fuzz_test.go
webtorrent/transport_test.go
worse-conns_test.go

index 08b4f98ba0b38f5e7a239e3575671dd439634895..f203dfa54477e96ed48bcb0bf2b38f0278cebf06 100644 (file)
@@ -3,7 +3,7 @@ package bencode
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestBytesMarshalNil(t *testing.T) {
@@ -18,8 +18,7 @@ type structWithBytes struct {
 
 func TestMarshalNilStructBytes(t *testing.T) {
        _, err := Marshal(structWithBytes{B: Bytes("i42e")})
-       c := qt.New(t)
-       c.Assert(err, qt.IsNotNil)
+       qt.Assert(t, qt.IsNotNil(err))
 }
 
 type structWithOmitEmptyBytes struct {
@@ -28,12 +27,11 @@ type structWithOmitEmptyBytes struct {
 }
 
 func TestMarshalNilStructBytesOmitEmpty(t *testing.T) {
-       c := qt.New(t)
        b, err := Marshal(structWithOmitEmptyBytes{B: Bytes("i42e")})
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        t.Logf("%q", b)
        var s structWithBytes
        err = Unmarshal(b, &s)
-       c.Assert(err, qt.IsNil)
-       c.Check(s.B, qt.DeepEquals, Bytes("i42e"))
+       qt.Assert(t, qt.IsNil(err))
+       qt.Check(t, qt.DeepEquals(s.B, Bytes("i42e")))
 }
index 16fa448773bb9b9e31a2bd0b8e93d69f68151e76..c9b309e155ac9fc69f746dcfd5629ba9653da6b9 100644 (file)
@@ -10,7 +10,7 @@ import (
        "strings"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 )
@@ -150,7 +150,7 @@ func TestIgnoreUnmarshalTypeError(t *testing.T) {
        }{}
        require.Error(t, Unmarshal([]byte("d6:Normal5:helloe"), &s))
        assert.NoError(t, Unmarshal([]byte("d6:Ignore5:helloe"), &s))
-       qt.Assert(t, Unmarshal([]byte("d6:Ignorei42ee"), &s), qt.IsNil)
+       qt.Assert(t, qt.IsNil(Unmarshal([]byte("d6:Ignorei42ee"), &s)))
        assert.EqualValues(t, 42, s.Ignore)
 }
 
@@ -183,19 +183,17 @@ func TestUnmarshalByteArray(t *testing.T) {
 func TestDecodeDictIntoUnsupported(t *testing.T) {
        // Any type that a dict shouldn't be unmarshallable into.
        var i int
-       c := qt.New(t)
        err := Unmarshal([]byte("d1:a1:be"), &i)
        t.Log(err)
-       c.Check(err, qt.IsNotNil)
+       qt.Check(t, qt.IsNotNil(err))
 }
 
 func TestUnmarshalDictKeyNotString(t *testing.T) {
        // Any type that a dict shouldn't be unmarshallable into.
        var i int
-       c := qt.New(t)
        err := Unmarshal([]byte("di42e3:yese"), &i)
        t.Log(err)
-       c.Check(err, qt.Not(qt.IsNil))
+       qt.Check(t, qt.IsNotNil(err))
 }
 
 type arbitraryReader struct{}
@@ -220,14 +218,13 @@ func decodeHugeString(t *testing.T, strLen int64, header, tail string, v interfa
 // Ensure that bencode strings in various places obey the Decoder.MaxStrLen field.
 func TestDecodeMaxStrLen(t *testing.T) {
        t.Parallel()
-       c := qt.New(t)
        test := func(header, tail string, v interface{}, maxStrLen MaxStrLen) {
                strLen := maxStrLen
                if strLen == 0 {
                        strLen = DefaultDecodeMaxStrLen
                }
-               c.Assert(decodeHugeString(t, strLen, header, tail, v, maxStrLen), qt.IsNil)
-               c.Assert(decodeHugeString(t, strLen+1, header, tail, v, maxStrLen), qt.IsNotNil)
+               qt.Assert(t, qt.IsNil(decodeHugeString(t, strLen, header, tail, v, maxStrLen)))
+               qt.Assert(t, qt.IsNotNil(decodeHugeString(t, strLen+1, header, tail, v, maxStrLen)))
        }
        test("d%d:", "i0ee", new(interface{}), 0)
        test("%d:", "", new(interface{}), DefaultDecodeMaxStrLen)
@@ -242,15 +239,14 @@ func TestDecodeStringIntoBoolPtr(t *testing.T) {
        var m struct {
                Private *bool `bencode:"private,omitempty"`
        }
-       c := qt.New(t)
        check := func(msg string, expectNil, expectTrue bool) {
                m.Private = nil
-               c.Check(Unmarshal([]byte(msg), &m), qt.IsNil, qt.Commentf("%q", msg))
+               qt.Check(t, qt.IsNil(Unmarshal([]byte(msg), &m)), qt.Commentf("%q", msg))
                if expectNil {
-                       c.Check(m.Private, qt.IsNil)
+                       qt.Check(t, qt.IsNil(m.Private))
                } else {
-                       if c.Check(m.Private, qt.IsNotNil, qt.Commentf("%q", msg)) {
-                               c.Check(*m.Private, qt.Equals, expectTrue, qt.Commentf("%q", msg))
+                       if qt.Check(t, qt.IsNotNil(m.Private), qt.Commentf("%q", msg)) {
+                               qt.Check(t, qt.Equals(*m.Private, expectTrue), qt.Commentf("%q", msg))
                        }
                }
        }
@@ -270,7 +266,6 @@ func TestDecodeStringIntoBoolPtr(t *testing.T) {
 
 // To set expectations about how our Decoder should work.
 func TestJsonDecoderBehaviour(t *testing.T) {
-       c := qt.New(t)
        test := func(input string, items int, finalErr error) {
                d := json.NewDecoder(strings.NewReader(input))
                actualItems := 0
@@ -283,8 +278,8 @@ func TestJsonDecoderBehaviour(t *testing.T) {
                        }
                        actualItems++
                }
-               c.Check(firstErr, qt.Equals, finalErr)
-               c.Check(actualItems, qt.Equals, items)
+               qt.Check(t, qt.Equals(firstErr, finalErr))
+               qt.Check(t, qt.Equals(actualItems, items))
        }
        test("", 0, io.EOF)
        test("{}", 1, io.EOF)
index d0dce71f3d327af54a59aef8df71dcd219199f73..1f57b0642ec73282a009a0ce75595f98dbf07a9b 100644 (file)
@@ -7,31 +7,28 @@ import (
        "math/big"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/google/go-cmp/cmp"
 )
 
-var bencodeInterfaceChecker = qt.CmpEquals(cmp.Comparer(func(a, b *big.Int) bool {
-       return a.Cmp(b) == 0
-}))
-
 func Fuzz(f *testing.F) {
        for _, ret := range random_encode_tests {
                f.Add([]byte(ret.expected))
        }
        f.Fuzz(func(t *testing.T, b []byte) {
-               c := qt.New(t)
                var d interface{}
                err := Unmarshal(b, &d)
                if err != nil {
                        t.Skip()
                }
                b0, err := Marshal(d)
-               c.Assert(err, qt.IsNil)
+               qt.Assert(t, qt.IsNil(err))
                var d0 interface{}
                err = Unmarshal(b0, &d0)
-               c.Assert(err, qt.IsNil)
-               c.Assert(d0, bencodeInterfaceChecker, d)
+               qt.Assert(t, qt.IsNil(err))
+               qt.Assert(t, qt.CmpEquals(d0, d, cmp.Comparer(func(a, b *big.Int) bool {
+                       return a.Cmp(b) == 0
+               })))
        })
 }
 
@@ -40,14 +37,13 @@ func FuzzInterfaceRoundTrip(f *testing.F) {
                f.Add([]byte(ret.expected))
        }
        f.Fuzz(func(t *testing.T, b []byte) {
-               c := qt.New(t)
                var d interface{}
                err := Unmarshal(b, &d)
                if err != nil {
-                       c.Skip(err)
+                       t.Skip(err)
                }
                b0, err := Marshal(d)
-               c.Assert(err, qt.IsNil)
-               c.Check(b0, qt.DeepEquals, b)
+               qt.Assert(t, qt.IsNil(err))
+               qt.Check(t, qt.DeepEquals(b0, b))
        })
 }
index 3f7802345b8a6eccff01a68e6a398d434353417a..e78ec8a347b96d4ab0593f4992237fa8df729df5 100644 (file)
@@ -16,12 +16,13 @@ import (
        "github.com/anacrolix/fuse"
        fusefs "github.com/anacrolix/fuse/fs"
        "github.com/anacrolix/missinggo/v2/panicif"
+       "github.com/go-quicktest/qt"
+       "golang.org/x/sync/errgroup"
+
        "github.com/anacrolix/torrent"
        torrentfs "github.com/anacrolix/torrent/fs"
        "github.com/anacrolix/torrent/internal/testutil"
        "github.com/anacrolix/torrent/metainfo"
-       "github.com/go-quicktest/qt"
-       "golang.org/x/sync/errgroup"
 )
 
 func copyFile(src, dst string) (err error) {
diff --git a/go.mod b/go.mod
index 0eeb162fa0967046ea4a34e1a789e3e4f83f2171..e0b55a306e6d6fc0d915dbb319bcdc06168641d5 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -31,7 +31,6 @@ require (
        github.com/dustin/go-humanize v1.0.0
        github.com/edsrzf/mmap-go v1.1.0
        github.com/elliotchance/orderedmap v1.4.0
-       github.com/frankban/quicktest v1.14.6
        github.com/fsnotify/fsnotify v1.5.4
        github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916
        github.com/go-quicktest/qt v1.101.0
@@ -71,6 +70,7 @@ require (
        github.com/bits-and-blooms/bitset v1.2.2 // indirect
        github.com/cenkalti/backoff/v4 v4.1.3 // indirect
        github.com/cespare/xxhash/v2 v2.2.0 // indirect
+       github.com/frankban/quicktest v1.14.6 // indirect
        github.com/go-llsqlite/crawshaw v0.5.6-0.20250312230104-194977a03421 // indirect
        github.com/go-logr/logr v1.2.3 // indirect
        github.com/go-logr/stdr v1.2.2 // indirect
index 5952804eb94fc65cb0f4fb7c09042731ab0f94f0..4dbd8c3952392f0695e9230f9e80e017ac616b45 100644 (file)
@@ -6,72 +6,67 @@ import (
        "time"
 
        _ "github.com/anacrolix/envpprof"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestReserveOverMax(t *testing.T) {
-       c := qt.New(t)
        l := &Limiter{Max: 10}
        r := l.Reserve(20)
-       c.Assert(r.Wait(context.Background()), qt.IsNotNil)
+       qt.Assert(t, qt.IsNotNil(r.Wait(context.Background())))
 }
 
 func TestImmediateAllow(t *testing.T) {
-       c := qt.New(t)
        l := &Limiter{Max: 10}
        r := l.Reserve(10)
-       c.Assert(r.Wait(context.Background()), qt.IsNil)
+       qt.Assert(t, qt.IsNil(r.Wait(context.Background())))
 }
 
 func TestSimpleSequence(t *testing.T) {
-       c := qt.New(t)
        l := &Limiter{Max: 10}
        rs := make([]*Reservation, 0)
        rs = append(rs, l.Reserve(6))
        rs = append(rs, l.Reserve(5))
        rs = append(rs, l.Reserve(5))
-       c.Assert(rs[0].Wait(context.Background()), qt.IsNil)
+       qt.Assert(t, qt.IsNil(rs[0].Wait(context.Background())))
        ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Nanosecond))
-       c.Assert(rs[1].Wait(ctx), qt.Equals, context.DeadlineExceeded)
+       qt.Assert(t, qt.Equals(rs[1].Wait(ctx), context.DeadlineExceeded))
        go cancel()
        ctx, cancel = context.WithCancel(context.Background())
        go cancel()
-       c.Assert(rs[2].Wait(ctx), qt.Equals, context.Canceled)
+       qt.Assert(t, qt.Equals(rs[2].Wait(ctx), context.Canceled))
        go rs[0].Release()
        ctx, cancel = context.WithDeadline(context.Background(), time.Now().Add(time.Second))
-       c.Assert(rs[1].Wait(ctx), qt.IsNil)
+       qt.Assert(t, qt.IsNil(rs[1].Wait(ctx)))
        go rs[1].Release()
-       c.Assert(rs[2].Wait(ctx), qt.IsNil)
+       qt.Assert(t, qt.IsNil(rs[2].Wait(ctx)))
        go rs[2].Release()
        go cancel()
        rs[2].Release()
        rs[1].Release()
-       c.Assert(l.Value(), qt.Equals, l.Max)
+       qt.Assert(t, qt.Equals(l.Value(), l.Max))
 }
 
 func TestSequenceWithCancel(t *testing.T) {
-       c := qt.New(t)
        l := &Limiter{Max: 10}
        rs := make([]*Reservation, 0)
        rs = append(rs, l.Reserve(6))
        rs = append(rs, l.Reserve(6))
        rs = append(rs, l.Reserve(4))
        rs = append(rs, l.Reserve(4))
-       c.Assert(rs[0].Cancel(), qt.IsFalse)
-       c.Assert(func() { rs[1].Release() }, qt.PanicMatches, "not resolved")
-       c.Assert(rs[1].Cancel(), qt.IsTrue)
-       c.Assert(rs[2].Wait(context.Background()), qt.IsNil)
+       qt.Assert(t, qt.IsFalse(rs[0].Cancel()))
+       qt.Assert(t, qt.PanicMatches(func() { rs[1].Release() }, "not resolved"))
+       qt.Assert(t, qt.IsTrue(rs[1].Cancel()))
+       qt.Assert(t, qt.IsNil(rs[2].Wait(context.Background())))
        rs[0].Release()
-       c.Assert(rs[3].Wait(context.Background()), qt.IsNil)
-       c.Assert(l.Value(), qt.Equals, int64(2))
+       qt.Assert(t, qt.IsNil(rs[3].Wait(context.Background())))
+       qt.Assert(t, qt.Equals(l.Value(), int64(2)))
        rs[1].Release()
        rs[2].Release()
        rs[3].Release()
-       c.Assert(l.Value(), qt.Equals, l.Max)
+       qt.Assert(t, qt.Equals(l.Value(), l.Max))
 }
 
 func TestCancelWhileWaiting(t *testing.T) {
-       c := qt.New(t)
        l := &Limiter{Max: 10}
        rs := make([]*Reservation, 0)
        rs = append(rs, l.Reserve(6))
@@ -80,14 +75,14 @@ func TestCancelWhileWaiting(t *testing.T) {
        rs = append(rs, l.Reserve(4))
        go rs[1].Cancel()
        err := rs[1].Wait(context.Background())
-       c.Assert(err, qt.IsNotNil)
+       qt.Assert(t, qt.IsNotNil(err))
        err = rs[2].Wait(context.Background())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        ctx, cancel := context.WithCancel(context.Background())
        go cancel()
        err = rs[3].Wait(ctx)
-       c.Assert(err, qt.Equals, context.Canceled)
+       qt.Assert(t, qt.Equals(err, context.Canceled))
        rs[0].Drop()
        err = rs[3].Wait(ctx)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
 }
index 97916afbbf448364ac549af4eee49e7b4cf05532..3af16f8dac8d2dc28604c35bca17902614e48d5b 100644 (file)
@@ -4,38 +4,37 @@ import (
        "testing"
 
        g "github.com/anacrolix/generics"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestNestedMaps(t *testing.T) {
-       c := qt.New(t)
        var nest map[string]map[*int]map[byte][]int64
        intKey := g.PtrTo(420)
        var root = Begin(&nest)
        var first = Next(root, "answer")
        var second = Next(first, intKey)
        var last = Next(second, 69)
-       c.Assert(root.Exists(), qt.IsFalse)
-       c.Assert(first.Exists(), qt.IsFalse)
-       c.Assert(second.Exists(), qt.IsFalse)
-       c.Assert(last.Exists(), qt.IsFalse)
+       qt.Assert(t, qt.IsFalse(root.Exists()))
+       qt.Assert(t, qt.IsFalse(first.Exists()))
+       qt.Assert(t, qt.IsFalse(second.Exists()))
+       qt.Assert(t, qt.IsFalse(last.Exists()))
        last.Set([]int64{4, 8, 15, 16, 23, 42})
-       c.Assert(root.Exists(), qt.IsTrue)
-       c.Assert(first.Exists(), qt.IsTrue)
-       c.Assert(second.Exists(), qt.IsTrue)
-       c.Assert(last.Exists(), qt.IsTrue)
-       c.Assert(Next(second, 70).Exists(), qt.IsFalse)
+       qt.Assert(t, qt.IsTrue(root.Exists()))
+       qt.Assert(t, qt.IsTrue(first.Exists()))
+       qt.Assert(t, qt.IsTrue(second.Exists()))
+       qt.Assert(t, qt.IsTrue(last.Exists()))
+       qt.Assert(t, qt.IsFalse(Next(second, 70).Exists()))
        secondIntKey := g.PtrTo(1337)
        secondPath := Next(Next(Next(Begin(&nest), "answer"), secondIntKey), 42)
        secondPath.Set(nil)
-       c.Assert(secondPath.Exists(), qt.IsTrue)
+       qt.Assert(t, qt.IsTrue(secondPath.Exists()))
        last.Delete()
-       c.Assert(last.Exists(), qt.IsFalse)
-       c.Assert(second.Exists(), qt.IsFalse)
-       c.Assert(root.Exists(), qt.IsTrue)
-       c.Assert(first.Exists(), qt.IsTrue)
+       qt.Assert(t, qt.IsFalse(last.Exists()))
+       qt.Assert(t, qt.IsFalse(second.Exists()))
+       qt.Assert(t, qt.IsTrue(root.Exists()))
+       qt.Assert(t, qt.IsTrue(first.Exists()))
        // See if we get panics deleting an already deleted item.
        last.Delete()
        secondPath.Delete()
-       c.Assert(root.Exists(), qt.IsFalse)
+       qt.Assert(t, qt.IsFalse(root.Exists()))
 }
index 37300f09cf50dcfa558d381634fd52f3536c9c83..0401379d05760af602466a5ef5c486f4d031ffb7 100644 (file)
@@ -6,7 +6,7 @@ import (
        "testing"
 
        "github.com/anacrolix/sync"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        . "github.com/anacrolix/torrent"
        "github.com/anacrolix/torrent/internal/testutil"
@@ -19,7 +19,7 @@ const (
 )
 
 func countHandler(
-       c *qt.C,
+       t *testing.T,
        wg *sync.WaitGroup,
        // Name of the endpoint that this handler is for, for logging.
        handlerName string,
@@ -38,7 +38,7 @@ func countHandler(
                        return
                }
                name, builtin, err := event.PeerConn.LocalLtepProtocolMap.LookupId(event.ExtensionNumber)
-               c.Assert(err, qt.IsNil)
+               qt.Assert(t, qt.IsNil(err))
                // Not a user protocol.
                if builtin {
                        return
@@ -46,29 +46,27 @@ func countHandler(
                switch name {
                case answerToName:
                        u64, err := strconv.ParseUint(string(event.Payload), 10, 0)
-                       c.Assert(err, qt.IsNil)
+                       qt.Assert(t, qt.IsNil(err))
                        i := uint(u64)
-                       c.Logf("%v got %d", handlerName, i)
+                       t.Logf("%v got %d", handlerName, i)
                        if i == doneValue {
                                wg.Done()
                                return
                        }
-                       c.Assert(i%2, qt.Equals, expectedMod2)
+                       qt.Assert(t, qt.Equals(i%2, expectedMod2))
                        go func() {
-                               c.Assert(
+                               qt.Assert(t, qt.IsNil(
                                        event.PeerConn.WriteExtendedMessage(
                                                replyToName,
-                                               []byte(strconv.FormatUint(uint64(i+1), 10))),
-                                       qt.IsNil)
+                                               []byte(strconv.FormatUint(uint64(i+1), 10)))))
                        }()
                default:
-                       c.Fatalf("got unexpected extension name %q", name)
+                       t.Fatalf("got unexpected extension name %q", name)
                }
        }
 }
 
 func TestUserLtep(t *testing.T) {
-       c := qt.New(t)
        var wg sync.WaitGroup
 
        makeCfg := func() *ClientConfig {
@@ -85,33 +83,33 @@ func TestUserLtep(t *testing.T) {
                // separate goroutine.
                go func() {
                        // Check sending an extended message for a protocol the peer doesn't support is an error.
-                       c.Check(pc.WriteExtendedMessage("pm_me_floats", []byte("3.142")), qt.IsNotNil)
+                       qt.Check(t, qt.IsNotNil(pc.WriteExtendedMessage("pm_me_floats", []byte("3.142"))))
                        // Kick things off by sending a 1.
-                       c.Check(pc.WriteExtendedMessage(testRepliesToOddsExtensionName, []byte("1")), qt.IsNil)
+                       qt.Check(t, qt.IsNil(pc.WriteExtendedMessage(testRepliesToOddsExtensionName, []byte("1"))))
                }()
        }
        evensCfg.Callbacks.PeerConnReadExtensionMessage = append(
                evensCfg.Callbacks.PeerConnReadExtensionMessage,
-               countHandler(c, &wg, "evens", 0, testRepliesToEvensExtensionName, testRepliesToOddsExtensionName, 100))
+               countHandler(t, &wg, "evens", 0, testRepliesToEvensExtensionName, testRepliesToOddsExtensionName, 100))
        evensCfg.Callbacks.PeerConnAdded = append(evensCfg.Callbacks.PeerConnAdded, func(conn *PeerConn) {
                conn.LocalLtepProtocolMap.AddUserProtocol(testRepliesToEvensExtensionName)
-               c.Assert(conn.LocalLtepProtocolMap.Index[conn.LocalLtepProtocolMap.NumBuiltin:], qt.HasLen, 1)
+               qt.Assert(t, qt.HasLen(conn.LocalLtepProtocolMap.Index[conn.LocalLtepProtocolMap.NumBuiltin:], 1))
        })
 
        oddsCfg := makeCfg()
        oddsCfg.Callbacks.PeerConnAdded = append(oddsCfg.Callbacks.PeerConnAdded, func(conn *PeerConn) {
                conn.LocalLtepProtocolMap.AddUserProtocol(testRepliesToOddsExtensionName)
-               c.Assert(conn.LocalLtepProtocolMap.Index[conn.LocalLtepProtocolMap.NumBuiltin:], qt.HasLen, 1)
+               qt.Assert(t, qt.HasLen(conn.LocalLtepProtocolMap.Index[conn.LocalLtepProtocolMap.NumBuiltin:], 1))
        })
        oddsCfg.Callbacks.PeerConnReadExtensionMessage = append(
                oddsCfg.Callbacks.PeerConnReadExtensionMessage,
-               countHandler(c, &wg, "odds", 1, testRepliesToOddsExtensionName, testRepliesToEvensExtensionName, 100))
+               countHandler(t, &wg, "odds", 1, testRepliesToOddsExtensionName, testRepliesToEvensExtensionName, 100))
 
        cl1, err := NewClient(oddsCfg)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cl1.Close()
        cl2, err := NewClient(evensCfg)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cl2.Close()
        addOpts := AddTorrentOpts{}
        rand.Read(addOpts.InfoHash[:])
@@ -123,7 +121,7 @@ func TestUserLtep(t *testing.T) {
        wg.Add(1)
        added := t1.AddClientPeer(cl2)
        // Ensure some addresses for the other client were added.
-       c.Assert(added, qt.Not(qt.Equals), 0)
+       qt.Assert(t, qt.Not(qt.Equals(added, 0)))
        wg.Wait()
        _ = t2
 }
index 620d385c66dfa9e02fb1b705a441e0dcd5059803..8011c02ea28d9d5d5899cfb294382a6714b9b886 100644 (file)
@@ -3,36 +3,35 @@ package metainfo
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestParseMagnetV2(t *testing.T) {
-       c := qt.New(t)
 
        const v2Only = "magnet:?xt=urn:btmh:1220caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e&dn=bittorrent-v2-test"
 
        m2, err := ParseMagnetV2Uri(v2Only)
-       c.Assert(err, qt.IsNil)
-       c.Check(m2.InfoHash.Ok, qt.IsFalse)
-       c.Check(m2.V2InfoHash.Ok, qt.IsTrue)
-       c.Check(m2.V2InfoHash.Value.HexString(), qt.Equals, "caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e")
-       c.Check(m2.Params, qt.HasLen, 0)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Check(t, qt.IsFalse(m2.InfoHash.Ok))
+       qt.Check(t, qt.IsTrue(m2.V2InfoHash.Ok))
+       qt.Check(t, qt.Equals(m2.V2InfoHash.Value.HexString(), "caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e"))
+       qt.Check(t, qt.HasLen(m2.Params, 0))
 
        _, err = ParseMagnetUri(v2Only)
-       c.Check(err, qt.IsNotNil)
+       qt.Check(t, qt.IsNotNil(err))
 
        const hybrid = "magnet:?xt=urn:btih:631a31dd0a46257d5078c0dee4e66e26f73e42ac&xt=urn:btmh:1220d8dd32ac93357c368556af3ac1d95c9d76bd0dff6fa9833ecdac3d53134efabb&dn=bittorrent-v1-v2-hybrid-test"
 
        m2, err = ParseMagnetV2Uri(hybrid)
-       c.Assert(err, qt.IsNil)
-       c.Check(m2.InfoHash.Ok, qt.IsTrue)
-       c.Check(m2.InfoHash.Value.HexString(), qt.Equals, "631a31dd0a46257d5078c0dee4e66e26f73e42ac")
-       c.Check(m2.V2InfoHash.Ok, qt.IsTrue)
-       c.Check(m2.V2InfoHash.Value.HexString(), qt.Equals, "d8dd32ac93357c368556af3ac1d95c9d76bd0dff6fa9833ecdac3d53134efabb")
-       c.Check(m2.Params, qt.HasLen, 0)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Check(t, qt.IsTrue(m2.InfoHash.Ok))
+       qt.Check(t, qt.Equals(m2.InfoHash.Value.HexString(), "631a31dd0a46257d5078c0dee4e66e26f73e42ac"))
+       qt.Check(t, qt.IsTrue(m2.V2InfoHash.Ok))
+       qt.Check(t, qt.Equals(m2.V2InfoHash.Value.HexString(), "d8dd32ac93357c368556af3ac1d95c9d76bd0dff6fa9833ecdac3d53134efabb"))
+       qt.Check(t, qt.HasLen(m2.Params, 0))
 
        m, err := ParseMagnetUri(hybrid)
-       c.Assert(err, qt.IsNil)
-       c.Check(m.InfoHash.HexString(), qt.Equals, "631a31dd0a46257d5078c0dee4e66e26f73e42ac")
-       c.Check(m.Params["xt"], qt.HasLen, 1)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Check(t, qt.Equals(m.InfoHash.HexString(), "631a31dd0a46257d5078c0dee4e66e26f73e42ac"))
+       qt.Check(t, qt.HasLen(m.Params["xt"], 1))
 }
index 2547509894f1b7e75b900794505139549054ef48..0dbd38f2e5d316398254b74839d921518b625d1f 100644 (file)
@@ -5,7 +5,7 @@ import (
        "testing"
 
        "github.com/davecgh/go-spew/spew"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 )
@@ -118,18 +118,17 @@ func contains(haystack []string, needle string) bool {
 // Check that we can parse the magnet link generated from a real-world torrent. This was added due
 // to a regression in copyParams.
 func TestParseSintelMagnet(t *testing.T) {
-       c := qt.New(t)
        mi, err := LoadFromFile("../testdata/sintel.torrent")
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        m := mi.Magnet(nil, nil)
        ms := m.String()
        t.Logf("magnet link: %q", ms)
        m, err = ParseMagnetUri(ms)
-       c.Check(err, qt.IsNil)
+       qt.Check(t, qt.IsNil(err))
        spewCfg := spew.NewDefaultConfig()
        spewCfg.DisableMethods = true
        spewCfg.Dump(m)
        m2, err := ParseMagnetV2Uri(ms)
        spewCfg.Dump(m2)
-       c.Check(err, qt.IsNil)
+       qt.Check(t, qt.IsNil(err))
 }
index 6a97f9117291b77395bd8ca91d2ec48b327d82e9..63644a9f130d27c61cca1a6db7505a1d802c6aba 100644 (file)
@@ -10,7 +10,7 @@ import (
 
        "github.com/anacrolix/missinggo/v2"
        "github.com/davecgh/go-spew/spew"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 
@@ -49,8 +49,7 @@ func TestFile(t *testing.T) {
        testFile(t, "testdata/23516C72685E8DB0C8F15553382A927F185C4F01.torrent")
        testFile(t, "testdata/trackerless.torrent")
        _, err := LoadFromFile("testdata/minimal-trailing-newline.torrent")
-       c := qt.New(t)
-       c.Check(err, qt.ErrorMatches, ".*expected EOF")
+       qt.Check(t, qt.ErrorMatches(err, ".*expected EOF"))
 }
 
 // Ensure that the correct number of pieces are generated when hashing files.
@@ -124,7 +123,7 @@ func TestMetainfoWithListURLList(t *testing.T) {
        mi, err := LoadFromFile("testdata/SKODAOCTAVIA336x280_archive.torrent")
        require.NoError(t, err)
        assert.Len(t, mi.UrlList, 3)
-       qt.Assert(t, mi.Magnet(nil, nil).String(), qt.ContentEquals,
+       qt.Assert(t, qt.ContentEquals(mi.Magnet(nil, nil).String(),
                strings.Join([]string{
                        "magnet:?xt=urn:btih:d4b197dff199aad447a9a352e31528adbbd97922",
                        "tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce",
@@ -132,20 +131,20 @@ func TestMetainfoWithListURLList(t *testing.T) {
                        "ws=https%3A%2F%2Farchive.org%2Fdownload%2F",
                        "ws=http%3A%2F%2Fia601600.us.archive.org%2F26%2Fitems%2F",
                        "ws=http%3A%2F%2Fia801600.us.archive.org%2F26%2Fitems%2F",
-               }, "&"))
+               }, "&")))
 }
 
 func TestMetainfoWithStringURLList(t *testing.T) {
        mi, err := LoadFromFile("testdata/flat-url-list.torrent")
        require.NoError(t, err)
        assert.Len(t, mi.UrlList, 1)
-       qt.Assert(t, mi.Magnet(nil, nil).String(), qt.ContentEquals,
+       qt.Assert(t, qt.ContentEquals(mi.Magnet(nil, nil).String(),
                strings.Join([]string{
                        "magnet:?xt=urn:btih:9da24e606e4ed9c7b91c1772fb5bf98f82bd9687",
                        "tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce",
                        "tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce",
                        "ws=https%3A%2F%2Farchive.org%2Fdownload%2F",
-               }, "&"))
+               }, "&")))
 }
 
 // https://github.com/anacrolix/torrent/issues/247
@@ -160,19 +159,17 @@ func TestStringCreationDate(t *testing.T) {
 // See https://github.com/anacrolix/torrent/issues/843.
 func TestUnmarshalEmptyStringNodes(t *testing.T) {
        var mi MetaInfo
-       c := qt.New(t)
        err := bencode.Unmarshal([]byte("d5:nodes0:e"), &mi)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
 }
 
 func TestUnmarshalV2Metainfo(t *testing.T) {
-       c := qt.New(t)
        mi, err := LoadFromFile("../testdata/bittorrent-v2-test.torrent")
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        info, err := mi.UnmarshalInfo()
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        spew.Dump(info)
-       c.Check(info.NumPieces(), qt.Not(qt.Equals), 0)
+       qt.Check(t, qt.Not(qt.Equals(info.NumPieces(), 0)))
        err = ValidatePieceLayers(mi.PieceLayers, &info.FileTree, info.PieceLength)
-       c.Check(err, qt.IsNil)
+       qt.Check(t, qt.IsNil(err))
 }
index 39b54c1c848aa193ed64a50bf19e70abf6bda3d7..d03927ac342c57319df6d47bb0354a8e4fba711d 100644 (file)
@@ -7,7 +7,7 @@ import (
        "sync"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
 )
@@ -35,7 +35,6 @@ func BenchmarkDecodePieces(t *testing.B) {
                        },
                },
        }
-       c := qt.New(t)
        t.ReportAllocs()
        t.ResetTimer()
        for i := 0; i < t.N; i += 1 {
@@ -47,7 +46,7 @@ func BenchmarkDecodePieces(t *testing.B) {
                }
                // This is very expensive, and should be discovered in tests rather than a benchmark.
                if false {
-                       c.Assert(msg, qt.DeepEquals, inputMsg)
+                       qt.Assert(t, qt.DeepEquals(msg, inputMsg))
                }
                // WWJD
                d.Pool.Put(&msg.Piece)
index 8ffdfd7b47dc55b66ff8725f9d24d7abac55fa01..dbf54f3c7bcf1f7fb8150109faa47f1dd082e407 100644 (file)
@@ -9,7 +9,7 @@ import (
        "io"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func FuzzDecoder(f *testing.F) {
@@ -19,7 +19,6 @@ func FuzzDecoder(f *testing.F) {
        f.Add([]byte("\x00\x00\x00\x01\x07"))
        f.Fuzz(func(t *testing.T, b []byte) {
                t.Logf("%q", b)
-               c := qt.New(t)
                d := Decoder{
                        R:         bufio.NewReader(bytes.NewReader(b)),
                        MaxLength: 0x100,
@@ -33,7 +32,7 @@ func FuzzDecoder(f *testing.F) {
                                break
                        }
                        if err == nil {
-                               c.Assert(m, qt.Not(qt.Equals), Message{})
+                               qt.Assert(t, qt.Not(qt.Equals(m, Message{})))
                                ms = append(ms, m)
                                continue
                        } else {
@@ -46,9 +45,9 @@ func FuzzDecoder(f *testing.F) {
                        buf.Write(m.MustMarshalBinary())
                }
                if len(b) == 0 {
-                       c.Assert(buf.Bytes(), qt.HasLen, 0)
+                       qt.Assert(t, qt.HasLen(buf.Bytes(), 0))
                } else {
-                       c.Assert(buf.Bytes(), qt.DeepEquals, b)
+                       qt.Assert(t, qt.DeepEquals(buf.Bytes(), b))
                }
        })
 }
@@ -60,6 +59,6 @@ func FuzzMessageMarshalBinary(f *testing.F) {
                        t.Skip(err)
                }
                b0 := m.MustMarshalBinary()
-               qt.Assert(t, b0, qt.DeepEquals, b)
+               qt.Assert(t, qt.DeepEquals(b0, b))
        })
 }
index 53f9d86d92af00f7cfd726115c3b78b6070b0d3c..178703fb90c5401f86721f8263bc58f34e195d9b 100644 (file)
@@ -3,12 +3,11 @@ package peer_protocol
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestV2BitLocation(t *testing.T) {
        var bits PeerExtensionBits
        bits.SetBit(ExtensionBitV2Upgrade, true)
-       c := qt.New(t)
-       c.Assert(bits[7], qt.Equals, byte(0x10))
+       qt.Assert(t, qt.Equals(bits[7], byte(0x10)))
 }
index 7221e1f70fe664ab1a5d54c5bdf61d986d356727..7177d709cdbf8bf785cc427061ba9028e81b1b71 100644 (file)
@@ -5,7 +5,7 @@ import (
        "net/netip"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 var exampleMsgs = []Msg{
@@ -22,19 +22,18 @@ var exampleMsgs = []Msg{
 }
 
 func TestUnmarshalMsg(t *testing.T) {
-       c := qt.New(t)
        for _, m := range exampleMsgs {
                b, err := m.MarshalBinary()
-               c.Assert(err, qt.IsNil)
+               qt.Assert(t, qt.IsNil(err))
                expectedLen := 24
                if m.AddrPort.Addr().Is4() {
                        expectedLen = 12
                }
-               c.Check(b, qt.HasLen, expectedLen)
+               qt.Check(t, qt.HasLen(b, expectedLen))
                var um Msg
                err = um.UnmarshalBinary(b)
-               c.Assert(err, qt.IsNil)
-               c.Check(um, qt.Equals, m)
+               qt.Assert(t, qt.IsNil(err))
+               qt.Check(t, qt.Equals(um, m))
        }
 }
 
index 3940da0e084cbfb98927f58872292fa313ad32aa..6bcd9981f8edf33a38d2faeb5dc4fa07414bf37a 100644 (file)
@@ -9,7 +9,7 @@ import (
        g "github.com/anacrolix/generics"
        "github.com/anacrolix/missinggo/v2/iter"
        "github.com/davecgh/go-spew/spew"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent/metainfo"
        request_strategy "github.com/anacrolix/torrent/request-strategy"
@@ -22,14 +22,13 @@ func makeRequestStrategyPiece(t request_strategy.Torrent) request_strategy.Piece
 }
 
 func TestRequestStrategyPieceDoesntAlloc(t *testing.T) {
-       c := qt.New(t)
        akshalTorrent := &Torrent{pieces: make([]Piece, 1)}
        rst := requestStrategyTorrent{akshalTorrent}
        var before, after runtime.MemStats
        runtime.ReadMemStats(&before)
        p := makeRequestStrategyPiece(rst)
        runtime.ReadMemStats(&after)
-       c.Assert(before.HeapAlloc, qt.Equals, after.HeapAlloc)
+       qt.Assert(t, qt.Equals(before.HeapAlloc, after.HeapAlloc))
        // We have to use p, or it gets optimized away.
        spew.Fdump(io.Discard, p)
 }
@@ -81,7 +80,6 @@ func (s *storageClient) OpenTorrent(
 }
 
 func BenchmarkRequestStrategy(b *testing.B) {
-       c := qt.New(b)
        cl := newTestingClient(b)
        storageClient := storageClient{}
        tor, new := cl.AddTorrentOpt(AddTorrentOpts{
@@ -89,7 +87,7 @@ func BenchmarkRequestStrategy(b *testing.B) {
                Storage:    &storageClient,
        })
        tor.disableTriggers = true
-       c.Assert(new, qt.IsTrue)
+       qt.Assert(b, qt.IsTrue(new))
        const pieceLength = 1 << 8 << 10
        const numPieces = 30_000
        err := tor.setInfo(&metainfo.Info{
@@ -97,13 +95,13 @@ func BenchmarkRequestStrategy(b *testing.B) {
                PieceLength: pieceLength,
                Length:      pieceLength * numPieces,
        })
-       c.Assert(err, qt.IsNil)
+       qt.Assert(b, qt.IsNil(err))
        tor.onSetInfo()
        peer := cl.newConnection(nil, newConnectionOpts{
                network: "test",
        })
        peer.setTorrent(tor)
-       c.Assert(tor.storage, qt.IsNotNil)
+       qt.Assert(b, qt.IsNotNil(tor.storage))
        const chunkSize = defaultChunkSize
        peer.onPeerHasAllPiecesNoTriggers()
        for i := 0; i < tor.numPieces(); i++ {
@@ -129,9 +127,9 @@ func BenchmarkRequestStrategy(b *testing.B) {
                        tor.cacheNextRequestIndexesForReuse(rs.Requests.requestIndexes)
                        // End of part that should be timed.
                        remainingChunks := (numPieces - completed) * (pieceLength / chunkSize)
-                       c.Assert(rs.Requests.requestIndexes, qt.HasLen, min(
+                       qt.Assert(b, qt.HasLen(rs.Requests.requestIndexes, min(
                                remainingChunks,
-                               int(cl.config.MaxUnverifiedBytes/chunkSize)))
+                               int(cl.config.MaxUnverifiedBytes/chunkSize))))
                }
        }
 }
index 6c791a58c05994bd2375fb6fb3d2750ca5defac3..385b71f2b21dbfe9aa4a146a14b97cff53c291e4 100644 (file)
@@ -4,7 +4,7 @@ import (
        "testing"
 
        "github.com/bradfitz/iter"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        pp "github.com/anacrolix/torrent/peer_protocol"
 )
@@ -35,12 +35,12 @@ func TestLogExampleRequestMapOrdering(t *testing.T) {
 func TestRequestMapOrderingPersistent(t *testing.T) {
        m := makeTypicalRequests()
        // Shows that map order is persistent across separate range statements.
-       qt.Assert(t, keysAsSlice(m), qt.ContentEquals, keysAsSlice(m))
+       qt.Assert(t, qt.ContentEquals(keysAsSlice(m), keysAsSlice(m)))
 }
 
 func TestRequestMapOrderAcrossInstances(t *testing.T) {
        // This shows that different map instances with the same contents can have the same range order.
-       qt.Assert(t, keysAsSlice(makeTypicalRequests()), qt.ContentEquals, keysAsSlice(makeTypicalRequests()))
+       qt.Assert(t, qt.ContentEquals(keysAsSlice(makeTypicalRequests()), keysAsSlice(makeTypicalRequests())))
 }
 
 // Added for testing repeating loop iteration after shuffling in Peer.applyRequestState.
@@ -58,7 +58,7 @@ func TestForLoopRepeatItem(t *testing.T) {
                        }
                }
                // We can mutate i and it's observed by the loop. No special treatment of the loop var.
-               qt.Assert(t, seen, qt.DeepEquals, []int{0, 1, 2, 2, 3})
+               qt.Assert(t, qt.DeepEquals(seen, []int{0, 1, 2, 2, 3}))
        })
        t.Run("Range", func(t *testing.T) {
                once := false
@@ -73,6 +73,6 @@ func TestForLoopRepeatItem(t *testing.T) {
                        }
                }
                // Range ignores any mutation to i.
-               qt.Assert(t, seen, qt.DeepEquals, []int{0, 1, 2, 3})
+               qt.Assert(t, qt.DeepEquals(seen, []int{0, 1, 2, 3}))
        })
 }
index 5da4ab8096b922ab6c8a2e1735ee7a87ab2d7a79..711920ddff0b0d1d9e79886efde41cfa5e1b5d30 100644 (file)
@@ -8,14 +8,13 @@ import (
        "testing"
 
        "github.com/anacrolix/log"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 // Show that multiple connections from the same local TCP port to the same remote port will fail.
 func TestTcpPortReuseIsABadIdea(t *testing.T) {
        remote, err := net.Listen("tcp", "localhost:0")
-       c := qt.New(t)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer remote.Close()
        dialer := net.Dialer{}
        // Show that we can't duplicate an existing connection even with various socket options.
@@ -26,16 +25,16 @@ func TestTcpPortReuseIsABadIdea(t *testing.T) {
        }
        // Tie up a local port to the remote.
        first, err := dialer.Dial("tcp", remote.Addr().String())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer first.Close()
        // Show that dialling the remote with the same local port fails.
        dialer.LocalAddr = first.LocalAddr()
        _, err = dialer.Dial("tcp", remote.Addr().String())
-       c.Assert(err, qt.IsNotNil)
+       qt.Assert(t, qt.IsNotNil(err))
        // Show that not fixing the local port again allows connections to succeed.
        dialer.LocalAddr = nil
        second, err := dialer.Dial("tcp", remote.Addr().String())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        second.Close()
 }
 
@@ -43,9 +42,8 @@ func TestTcpPortReuseIsABadIdea(t *testing.T) {
 // succeed. This is necessary for ut_holepunch to work.
 func TestUtpLocalPortIsReusable(t *testing.T) {
        const network = "udp"
-       c := qt.New(t)
        remote, err := NewUtpSocket(network, "localhost:0", nil, log.Default)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer remote.Close()
        var remoteAccepts int32
        doneAccepting := make(chan struct{})
@@ -65,15 +63,15 @@ func TestUtpLocalPortIsReusable(t *testing.T) {
                }
        }()
        local, err := NewUtpSocket(network, "localhost:0", nil, log.Default)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer local.Close()
        first, err := local.DialContext(context.Background(), network, remote.Addr().String())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer first.Close()
        second, err := local.DialContext(context.Background(), network, remote.Addr().String())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer second.Close()
        remote.Close()
        <-doneAccepting
-       c.Assert(atomic.LoadInt32(&remoteAccepts), qt.Equals, int32(2))
+       qt.Assert(t, qt.Equals(atomic.LoadInt32(&remoteAccepts), int32(2)))
 }
index c8c45376cb6f7bbabef292b9e2f5e9d1693ecf50..1620f77bd5cba9b0c09a164a3e822bc15de7678c 100644 (file)
@@ -3,7 +3,7 @@ package segments
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func LengthIterFromSlice(ls []Length) LengthIter {
@@ -50,7 +50,7 @@ func checkContiguous(
                expected.scanCallback(firstExpectedIndex+i, e)
        }
        nl(LengthIterFromSlice(ls))(needle, actual.scanCallback)
-       qt.Check(t, actual, qt.DeepEquals, expected)
+       qt.Check(t, qt.DeepEquals(actual, expected))
 }
 
 func testLocater(t *testing.T, newLocater newLocater) {
index 843a609a3e96dcafc42e71e75f50bff4be46908a..0deb1959e0706b60614da928871dbfef8bedf9fc 100644 (file)
@@ -4,6 +4,7 @@ import (
        "testing"
 
        g "github.com/anacrolix/generics"
+
        "github.com/anacrolix/torrent/storage"
        test_storage "github.com/anacrolix/torrent/storage/test"
 )
index dfaad2bcd2e0ed8636a2e4961852d5c97fb1f49b..edd62ebaffa4c13c59da5370975b37432a0132d7 100644 (file)
@@ -9,7 +9,7 @@ import (
        "testing/iotest"
 
        "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"
        "golang.org/x/time/rate"
@@ -97,7 +97,7 @@ func testClientTransfer(t *testing.T, ps testClientTransferParams) {
                newGOMAXPROCS = ps.GOMAXPROCS
        }
        defer func() {
-               qt.Check(t, runtime.GOMAXPROCS(prevGOMAXPROCS), qt.ContentEquals, newGOMAXPROCS)
+               qt.Check(t, qt.ContentEquals(runtime.GOMAXPROCS(prevGOMAXPROCS), newGOMAXPROCS))
        }()
 
        greetingTempDir, mi := testutil.GreetingTestTorrent()
@@ -251,5 +251,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)
-       qt.Check(t, iotest.TestReader(r, []byte(testutil.GreetingFileContents)), qt.IsNil)
+       qt.Check(t, qt.IsNil(iotest.TestReader(r, []byte(testutil.GreetingFileContents))))
 }
index 36da82f8b8adf9b6782fac91376f4f70bf7f35f0..7d4b915a69520632c475d097f6c8e81c65231fa1 100644 (file)
@@ -12,7 +12,7 @@ import (
        "net/http"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent"
        "github.com/anacrolix/torrent/bencode"
@@ -21,18 +21,17 @@ import (
 )
 
 func TestSqliteStorageClosed(t *testing.T) {
-       c := qt.New(t)
        cfg := torrent.TestingConfig(t)
        storage, err := sqliteStorage.NewDirectStorage(sqliteStorage.NewDirectStorageOpts{})
        defer storage.Close()
        cfg.DefaultStorage = storage
        cfg.Debug = true
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        cl, err := torrent.NewClient(cfg)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer cl.Close()
        l, err := net.Listen("tcp", "localhost:0")
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer l.Close()
        // We need at least once piece to trigger a call to storage to determine completion state. We
        // need non-zero content length to trigger piece hashing.
@@ -45,7 +44,7 @@ func TestSqliteStorageClosed(t *testing.T) {
        }
        mi := metainfo.MetaInfo{}
        mi.InfoBytes, err = bencode.Marshal(i)
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        s := http.Server{
                Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                        mi.Write(w)
@@ -64,6 +63,6 @@ func TestSqliteStorageClosed(t *testing.T) {
                InfoHash: mi.HashInfoBytes(),
        })
        tor.AddSources([]string{"http://" + l.Addr().String()})
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        <-tor.GotInfo()
 }
index 6d3e460ba4b8291494df49b1ff2ffbc7ec6ce220..5241db3b27e263ade7f051f83d49dbd7ac71bf0b 100644 (file)
@@ -10,7 +10,7 @@ import (
 
        "github.com/anacrolix/log"
        "github.com/anacrolix/missinggo/v2/filecache"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
        "golang.org/x/time/rate"
@@ -207,7 +207,7 @@ func testSeedAfterDownloading(t *testing.T, disableUtp bool) {
                go func() {
                        defer wg.Done()
                        defer r.Close()
-                       qt.Check(t, iotest.TestReader(r, []byte(testutil.GreetingFileContents)), qt.IsNil)
+                       qt.Check(t, qt.IsNil(iotest.TestReader(r, []byte(testutil.GreetingFileContents))))
                }()
        }
        go leecherGreeting.AddClientPeer(seeder)
index 98e28918082d74697d26d9296655c533211050d6..e5eaf2578bfe0d53d933cbb6ca2d742a4326f7a5 100644 (file)
@@ -4,7 +4,7 @@ go 1.23
 
 require (
        github.com/anacrolix/torrent v1.56.1
-       github.com/frankban/quicktest v1.14.6
+       github.com/go-quicktest/qt v1.101.0
 )
 
 require (
index 6c89a87bcea28363bd018e6a4c9d2f9489f23935..8c4bad2cc7bd564c11b83e0a39ec64eb56b602c0 100644 (file)
@@ -3,7 +3,7 @@ package webseed_partial_seed
 import (
        "github.com/anacrolix/torrent"
        "github.com/anacrolix/torrent/internal/testutil"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "path/filepath"
        "runtime"
        "testing"
@@ -50,7 +50,6 @@ func downloadAll(t *torrent.Torrent) {
 }
 
 func TestWebseedPartialSeed(t *testing.T) {
-       c := qt.New(t)
        seederClient := makeSeederClient(t)
        defer seederClient.Close()
        testutil.ExportStatusWriter(seederClient, "seeder", t)
@@ -82,5 +81,5 @@ func TestWebseedPartialSeed(t *testing.T) {
        time.Sleep(time.Second)
        seederTorrent.AddWebSeeds([]string{"http://localhost:3003/test.img"})
        allDownloaded := leecherClient.WaitAll()
-       c.Assert(allDownloaded, qt.IsTrue)
+       qt.Assert(t, qt.IsTrue(allDownloaded))
 }
index 822064770480fc8807f51234cb65d29e39e1f12a..54f53d06c844ba4e9849a299855a4cf2d794aafc 100644 (file)
@@ -3,7 +3,7 @@ package issue_952
 import (
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 
        "github.com/anacrolix/torrent/bencode"
        "github.com/anacrolix/torrent/metainfo"
@@ -25,16 +25,15 @@ func TestUnmarshalStringToByteArray(t *testing.T) {
        var s scrapeResponse
        const hashStr = "\x05a~F\xfd{c\xd1`\xb8\xd9\x89\xceM\xb9t\x1d\\\x0b\xded"
        err := bencode.Unmarshal([]byte("d5:filesd20:\x05a~F\xfd{c\xd1`\xb8\xd9\x89\xceM\xb9t\x1d\\\x0b\xded9:completedi1e10:downloadedi1eeee"), &s)
-       c := qt.New(t)
-       c.Assert(err, qt.IsNil)
-       c.Check(s.Files, qt.HasLen, 1)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Check(t, qt.HasLen(s.Files, 1))
        file, ok := s.Files[(infohash.T)([]byte(hashStr))]
-       c.Assert(ok, qt.IsTrue)
-       c.Check(file, qt.Equals, scrapeResponseFile{
+       qt.Assert(t, qt.IsTrue(ok))
+       qt.Check(t, qt.Equals(file, scrapeResponseFile{
                // Note that complete is misspelled in the example. I don't know why.
                Complete:   0,
                Downloaded: 1,
                Incomplete: 0,
-       })
+       }))
 
 }
index 98e28918082d74697d26d9296655c533211050d6..e5eaf2578bfe0d53d933cbb6ca2d742a4326f7a5 100644 (file)
@@ -4,7 +4,7 @@ go 1.23
 
 require (
        github.com/anacrolix/torrent v1.56.1
-       github.com/frankban/quicktest v1.14.6
+       github.com/go-quicktest/qt v1.101.0
 )
 
 require (
index 8eedff36850963bbdfa55f4613a54c909dc1115e..872775ff0386b5f793bce5364b3b7e215561d70c 100644 (file)
@@ -7,7 +7,7 @@ import (
 
        "github.com/anacrolix/torrent"
        "github.com/anacrolix/torrent/internal/testutil"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func testSrcDir() string {
@@ -50,7 +50,6 @@ func downloadAll(t *torrent.Torrent) {
 }
 
 func TestWebseedPartialSeed(t *testing.T) {
-       c := qt.New(t)
        seederClient := makeSeederClient(t)
        defer seederClient.Close()
        testutil.ExportStatusWriter(seederClient, "seeder", t)
@@ -79,5 +78,5 @@ func TestWebseedPartialSeed(t *testing.T) {
 
        seederTorrent.DownloadAll()
        allDownloaded := leecherClient.WaitAll()
-       c.Assert(allDownloaded, qt.IsTrue)
+       qt.Assert(t, qt.IsTrue(allDownloaded))
 }
index 591f3760757ac6e93227009a55a3fbc682d8ba3d..519b72bcfc2779bdb05baec106fa9fc9e71ebaec 100644 (file)
@@ -15,7 +15,7 @@ import (
 
        "github.com/anacrolix/log"
        "github.com/anacrolix/missinggo/v2/iter"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
        "golang.org/x/time/rate"
@@ -26,7 +26,6 @@ import (
 // Check that after completing leeching, a leecher transitions to a seeding
 // correctly. Connected in a chain like so: Seeder <-> Leecher <-> LeecherLeecher.
 func TestHolepunchConnect(t *testing.T) {
-       c := qt.New(t)
        greetingTempDir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(greetingTempDir)
 
@@ -101,7 +100,7 @@ func TestHolepunchConnect(t *testing.T) {
                defer wg.Done()
                r := llg.NewReader()
                defer r.Close()
-               qt.Check(t, iotest.TestReader(r, []byte(testutil.GreetingFileContents)), qt.IsNil)
+               qt.Check(t, qt.IsNil(iotest.TestReader(r, []byte(testutil.GreetingFileContents))))
        }()
        go seederTorrent.AddClientPeer(leecher)
        waitForConns(seederTorrent)
@@ -123,13 +122,13 @@ func TestHolepunchConnect(t *testing.T) {
        llg.cl.unlock()
        wg.Wait()
 
-       c.Check(seeder.dialedSuccessfullyAfterHolepunchConnect, qt.Not(qt.HasLen), 0)
-       c.Check(leecherLeecher.probablyOnlyConnectedDueToHolepunch, qt.Not(qt.HasLen), 0)
+       qt.Check(t, qt.Not(qt.HasLen(seeder.dialedSuccessfullyAfterHolepunchConnect, 0)))
+       qt.Check(t, qt.Not(qt.HasLen(leecherLeecher.probablyOnlyConnectedDueToHolepunch, 0)))
 
        llClientStats := leecherLeecher.Stats()
-       c.Check(llClientStats.NumPeersUndialableWithoutHolepunch, qt.Not(qt.Equals), 0)
-       c.Check(llClientStats.NumPeersUndialableWithoutHolepunchDialedAfterHolepunchConnect, qt.Not(qt.Equals), 0)
-       c.Check(llClientStats.NumPeersProbablyOnlyConnectedDueToHolepunch, qt.Not(qt.Equals), 0)
+       qt.Check(t, qt.Not(qt.Equals(llClientStats.NumPeersUndialableWithoutHolepunch, 0)))
+       qt.Check(t, qt.Not(qt.Equals(llClientStats.NumPeersUndialableWithoutHolepunchDialedAfterHolepunchConnect, 0)))
+       qt.Check(t, qt.Not(qt.Equals(llClientStats.NumPeersProbablyOnlyConnectedDueToHolepunch, 0)))
 }
 
 func waitForConns(t *Torrent) {
@@ -146,11 +145,10 @@ func waitForConns(t *Torrent) {
 // Show that dialling TCP will complete before the other side accepts.
 func TestDialTcpNotAccepting(t *testing.T) {
        l, err := net.Listen("tcp", "localhost:0")
-       c := qt.New(t)
-       c.Check(err, qt.IsNil)
+       qt.Check(t, qt.IsNil(err))
        defer l.Close()
        dialedConn, err := net.Dial("tcp", l.Addr().String())
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        dialedConn.Close()
 }
 
@@ -168,14 +166,13 @@ func TestTcpSimultaneousOpen(t *testing.T) {
                        return dialer.DialContext(ctx, network, remoteAddr)
                }
        }
-       c := qt.New(t)
        // I really hate doing this in unit tests, but we would need to pick apart Dialer to get
        // perfectly synchronized simultaneous dials.
        for range iter.N(10) {
                first, second := randPortPair()
                t.Logf("ports are %v and %v", first, second)
                err := testSimultaneousOpen(
-                       c.Cleanup,
+                       t.Cleanup,
                        makeDialer(first, fmt.Sprintf("localhost:%d", second)),
                        makeDialer(second, fmt.Sprintf("localhost:%d", first)),
                )
@@ -311,7 +308,6 @@ const defaultMsg = "hello"
 // for one or both peers involved.
 func TestUtpSimultaneousOpen(t *testing.T) {
        t.Parallel()
-       c := qt.New(t)
        const network = "udp"
        ctx := context.Background()
        newUtpSocket := func(addr string) utpSocket {
@@ -323,7 +319,7 @@ func TestUtpSimultaneousOpen(t *testing.T) {
                        },
                        log.Default,
                )
-               c.Assert(err, qt.IsNil)
+               qt.Assert(t, qt.IsNil(err))
                return socket
        }
        first := newUtpSocket("localhost:0")
@@ -338,7 +334,7 @@ func TestUtpSimultaneousOpen(t *testing.T) {
        t.Logf("first addr is %v. second addr is %v", first.Addr().String(), second.Addr().String())
        for range iter.N(10) {
                err := testSimultaneousOpen(
-                       c.Cleanup,
+                       t.Cleanup,
                        getDial(first, second.Addr().String()),
                        getDial(second, first.Addr().String()),
                )
@@ -370,14 +366,13 @@ func skipGoUtpDialIssue(t *testing.T, err error) {
 // same connection.
 func TestUtpDirectDialMsg(t *testing.T) {
        t.Parallel()
-       c := qt.New(t)
        const network = "udp4"
        ctx := context.Background()
        newUtpSocket := func(addr string) utpSocket {
                socket, err := NewUtpSocket(network, addr, func(net.Addr) bool {
                        return false
                }, log.Default)
-               c.Assert(err, qt.IsNil)
+               qt.Assert(t, qt.IsNil(err))
                return socket
        }
        for range iter.N(10) {
@@ -392,7 +387,7 @@ func TestUtpDirectDialMsg(t *testing.T) {
                        }
                        defer writer.Close()
                        reader, err := second.Accept()
-                       c.Assert(err, qt.IsNil)
+                       qt.Assert(t, qt.IsNil(err))
                        defer reader.Close()
                        return writeAndReadMsg(reader, writer)
                }()
index d08f982185e94478fd83d363d98f3f2b85df0ee7..5de29d77aa549c55db9d8816b391aa1fd118ec34 100644 (file)
@@ -13,6 +13,7 @@ import (
        "github.com/RoaringBitmap/roaring"
        g "github.com/anacrolix/generics"
        "github.com/anacrolix/missinggo/v2/panicif"
+
        "github.com/anacrolix/torrent/metainfo"
        pp "github.com/anacrolix/torrent/peer_protocol"
        "github.com/anacrolix/torrent/webseed"
index af3071f3fd4a61f930a94f53027ff17e88ab3a42..567db3a4dc7c20401cec779e376fefa76826e181 100644 (file)
@@ -4,13 +4,12 @@ import (
        "net/url"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestDefaultPathEscaper(t *testing.T) {
-       c := qt.New(t)
        test := func(unescaped string, parts ...string) {
-               assertPartsUnescape(c, unescaped, parts...)
+               assertPartsUnescape(t, unescaped, parts...)
        }
        for _, tc := range defaultPathEscapeTestCases {
                test(tc.escaped, tc.parts...)
@@ -36,14 +35,14 @@ var defaultPathEscapeTestCases = []struct {
        },
 }
 
-func assertPartsUnescape(c *qt.C, unescaped string, parts ...string) {
+func assertPartsUnescape(t *testing.T, unescaped string, parts ...string) {
        escaped := defaultPathEscaper(parts)
        pathUnescaped, err := url.PathUnescape(escaped)
-       c.Assert(err, qt.IsNil)
-       c.Assert(pathUnescaped, qt.Equals, unescaped)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Assert(t, qt.Equals(pathUnescaped, unescaped))
        queryUnescaped, err := url.QueryUnescape(escaped)
-       c.Assert(err, qt.IsNil)
-       c.Assert(queryUnescaped, qt.Equals, unescaped)
+       qt.Assert(t, qt.IsNil(err))
+       qt.Assert(t, qt.Equals(queryUnescaped, unescaped))
 }
 
 func FuzzDefaultPathEscaper(f *testing.F) {
@@ -55,6 +54,6 @@ func FuzzDefaultPathEscaper(f *testing.F) {
        // I think a single separator is enough to test special handling around /. Also fuzzing doesn't
        // let us take []string as an input.
        f.Fuzz(func(t *testing.T, first, second string) {
-               assertPartsUnescape(qt.New(t), first+"/"+second, first, second)
+               assertPartsUnescape(t, first+"/"+second, first, second)
        })
 }
index 14638fa2113e1135d4e2e6b6c1be043476446330..8e194d4c138a411de70dffb2cbf193465e311d45 100644 (file)
@@ -7,7 +7,7 @@ import (
        "encoding/json"
        "testing"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func FuzzJsonBinaryStrings(f *testing.F) {
@@ -23,9 +23,8 @@ func FuzzJsonBinaryStrings(f *testing.F) {
                        t.Fatal(err)
                }
                // t.Logf("%q", jsonStr)
-               c := qt.New(t)
                out, err := decodeJsonByteString(jsonStr, []byte{})
-               c.Assert(err, qt.IsNil)
-               c.Assert(out, qt.DeepEquals, in)
+               qt.Assert(t, qt.IsNil(err))
+               qt.Assert(t, qt.DeepEquals(out, in))
        })
 }
index 753339d303f5a850ec06ca1bea8ee3f97a180b78..9ea1263bc885b6a9b8aa3f8bb34f9d5657122e7c 100644 (file)
@@ -7,15 +7,14 @@ import (
        "testing"
 
        "github.com/anacrolix/log"
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
        "github.com/pion/webrtc/v4"
 )
 
 func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
-       c := qt.New(t)
        var tc TrackerClient
        pc, dc, _, err := tc.newOffer(log.Default, "", [20]byte{})
-       c.Assert(err, qt.IsNil)
+       qt.Assert(t, qt.IsNil(err))
        defer pc.Close()
        defer dc.Close()
        peerConnClosed := make(chan struct{})
@@ -33,6 +32,6 @@ func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
                t.Logf("data channel error: %v", err)
        })
        pc.Close()
-       c.Check(dc.ReadyState(), qt.Equals, webrtc.DataChannelStateClosed)
+       qt.Check(t, qt.Equals(dc.ReadyState(), webrtc.DataChannelStateClosed))
        <-peerConnClosed
 }
index 3865b648a5c6521d834298ab619f094ca7a040df..ad9079ee8b8bbe7b6a0ef42d3fd6ec19bc85d51a 100644 (file)
@@ -4,41 +4,40 @@ import (
        "testing"
        "time"
 
-       qt "github.com/frankban/quicktest"
+       qt "github.com/go-quicktest/qt"
 )
 
 func TestWorseConnLastHelpful(t *testing.T) {
-       c := qt.New(t)
-       c.Check((&worseConnInput{}).Less(&worseConnInput{LastHelpful: time.Now()}), qt.IsTrue)
-       c.Check((&worseConnInput{}).Less(&worseConnInput{CompletedHandshake: time.Now()}), qt.IsTrue)
-       c.Check((&worseConnInput{LastHelpful: time.Now()}).Less(&worseConnInput{CompletedHandshake: time.Now()}), qt.IsFalse)
-       c.Check((&worseConnInput{
+       qt.Check(t, qt.IsTrue((&worseConnInput{}).Less(&worseConnInput{LastHelpful: time.Now()})))
+       qt.Check(t, qt.IsTrue((&worseConnInput{}).Less(&worseConnInput{CompletedHandshake: time.Now()})))
+       qt.Check(t, qt.IsFalse((&worseConnInput{LastHelpful: time.Now()}).Less(&worseConnInput{CompletedHandshake: time.Now()})))
+       qt.Check(t, qt.IsTrue((&worseConnInput{
                LastHelpful: time.Now(),
        }).Less(&worseConnInput{
                LastHelpful:        time.Now(),
                CompletedHandshake: time.Now(),
-       }), qt.IsTrue)
+       })))
        now := time.Now()
-       c.Check((&worseConnInput{
+       qt.Check(t, qt.IsFalse((&worseConnInput{
                LastHelpful: now,
        }).Less(&worseConnInput{
                LastHelpful:        now.Add(-time.Nanosecond),
                CompletedHandshake: now,
-       }), qt.IsFalse)
+       })))
        readyPeerPriority := func() (peerPriority, error) {
                return 42, nil
        }
-       c.Check((&worseConnInput{
+       qt.Check(t, qt.IsTrue((&worseConnInput{
                GetPeerPriority: readyPeerPriority,
        }).Less(&worseConnInput{
                GetPeerPriority: readyPeerPriority,
                Pointer:         1,
-       }), qt.IsTrue)
-       c.Check((&worseConnInput{
+       })))
+       qt.Check(t, qt.IsFalse((&worseConnInput{
                GetPeerPriority: readyPeerPriority,
                Pointer:         2,
        }).Less(&worseConnInput{
                GetPeerPriority: readyPeerPriority,
                Pointer:         1,
-       }), qt.IsFalse)
+       })))
 }