]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent_test.go
Add Torrent.setInfo
[btrtrc.git] / torrent_test.go
index 39575dcc1fa0deb0ec52292a47e63fdeadfa345e..0f70cb979279cba9f98e367784e9d836e7faefc6 100644 (file)
@@ -75,13 +75,17 @@ func TestTorrentString(t *testing.T) {
 // a large torrent with small pieces had a lot of overhead in recalculating
 // piece priorities everytime a reader (possibly in another Torrent) changed.
 func BenchmarkUpdatePiecePriorities(b *testing.B) {
+       const (
+               numPieces   = 13410
+               pieceLength = 256 << 10
+       )
        cl := &Client{}
        t := cl.newTorrent(metainfo.Hash{}, nil)
-       t.info = &metainfo.Info{
-               Pieces:      make([]byte, 20*13410),
-               PieceLength: 256 << 10,
-       }
-       t.makePieces()
+       require.NoError(b, t.setInfo(&metainfo.Info{
+               Pieces:      make([]byte, metainfo.HashSize*numPieces),
+               PieceLength: pieceLength,
+               Length:      pieceLength * numPieces,
+       }))
        assert.EqualValues(b, 13410, t.numPieces())
        for range iter.N(7) {
                r := t.NewReader()