]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix BenchmarkConnectionMainReadLoop
authorMatt Joiner <anacrolix@gmail.com>
Wed, 15 Dec 2021 07:54:47 +0000 (18:54 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 16 Dec 2021 03:00:19 +0000 (14:00 +1100)
Broken by piece request order changes.

peerconn_test.go

index 304a3ec48ec266fca9adcbbb1be0fb550687c8b3..679648bbd098c9bcdc6a0e05620bac9f5ef89ec8 100644 (file)
@@ -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))