From e7ee568c52dfcdfb4608978c4f823bab29a89a37 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 15 Dec 2021 18:54:47 +1100 Subject: [PATCH] Fix BenchmarkConnectionMainReadLoop Broken by piece request order changes. --- peerconn_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/peerconn_test.go b/peerconn_test.go index 304a3ec4..679648bb 100644 --- a/peerconn_test.go +++ b/peerconn_test.go @@ -7,7 +7,6 @@ import ( "sync" "testing" - "github.com/anacrolix/missinggo/pubsub" "github.com/frankban/quicktest" "github.com/stretchr/testify/require" @@ -93,17 +92,15 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) { }) cl.initLogger() ts := &torrentStorage{} - t := &Torrent{ - cl: &cl, - storage: &storage.Torrent{TorrentImpl: storage.TorrentImpl{Piece: ts.Piece, Close: ts.Close}}, - pieceStateChanges: pubsub.NewPubSub(), - } - t.setChunkSize(defaultChunkSize) + t := cl.newTorrent(metainfo.Hash{}, nil) + t.initialPieceCheckDisabled = true require.NoError(b, t.setInfo(&metainfo.Info{ Pieces: make([]byte, 20), Length: 1 << 20, PieceLength: 1 << 20, })) + t.storage = &storage.Torrent{TorrentImpl: storage.TorrentImpl{Piece: ts.Piece, Close: ts.Close}} + t.onSetInfo() t._pendingPieces.Add(0) r, w := net.Pipe() cn := cl.newConnection(r, true, r.RemoteAddr(), r.RemoteAddr().Network(), regularNetConnPeerConnConnString(r))