From: Matt Joiner Date: Mon, 12 May 2025 02:20:01 +0000 (+1000) Subject: Wow Zed AI actually passed my refactoring test X-Git-Tag: v1.59.0~160 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=62688f87ca9222fd73b448d7f010c48532db54f2;p=btrtrc.git Wow Zed AI actually passed my refactoring test --- diff --git a/client-nowasm_test.go b/client-nowasm_test.go index 08ed80ce..961c144f 100644 --- a/client-nowasm_test.go +++ b/client-nowasm_test.go @@ -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())) } diff --git a/client-peerconn_test.go b/client-peerconn_test.go index 2620f35a..d062a134 100644 --- a/client-peerconn_test.go +++ b/client-peerconn_test.go @@ -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)))) } diff --git a/issue-949_test.go b/issue-949_test.go index 89b45929..60e8c720 100644 --- a/issue-949_test.go +++ b/issue-949_test.go @@ -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))) } diff --git a/peerconn_test.go b/peerconn_test.go index e3d1c8a3..44309293 100644 --- a/peerconn_test.go +++ b/peerconn_test.go @@ -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) diff --git a/storage/sqlite/sqlite-storage_test.go b/storage/sqlite/sqlite-storage_test.go index a566322d..3925734a 100644 --- a/storage/sqlite/sqlite-storage_test.go +++ b/storage/sqlite/sqlite-storage_test.go @@ -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) } diff --git a/storage/test/bench-piece-mark-complete.go b/storage/test/bench-piece-mark-complete.go index b665bf41..dee46a88 100644 --- a/storage/test/bench-piece-mark-complete.go +++ b/storage/test/bench-piece-mark-complete.go @@ -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 diff --git a/torrent_test.go b/torrent_test.go index 2b3a087d..7940fe2c 100644 --- a/torrent_test.go +++ b/torrent_test.go @@ -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() diff --git a/tracker/http/http_test.go b/tracker/http/http_test.go index 4e5efaf5..fd5e5807 100644 --- a/tracker/http/http_test.go +++ b/tracker/http/http_test.go @@ -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")) } diff --git a/tracker/udp/timeout_test.go b/tracker/udp/timeout_test.go index 4bb0dc83..85749566 100644 --- a/tracker/udp/timeout_test.go +++ b/tracker/udp/timeout_test.go @@ -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)) } diff --git a/tracker/udp/udp_test.go b/tracker/udp/udp_test.go index 378351cd..bc732867 100644 --- a/tracker/udp/udp_test.go +++ b/tracker/udp/udp_test.go @@ -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()