]> Sergey Matveev's repositories - btrtrc.git/blobdiff - bad_storage.go
Drop support for go 1.20
[btrtrc.git] / bad_storage.go
index 16fd557cea0e11f1057603d7ab86c66068052895..fc15beb90762862c7e2f8b0c9fe39560d0a541eb 100644 (file)
@@ -5,6 +5,7 @@ import (
        "math/rand"
        "strings"
 
+       "github.com/anacrolix/torrent/internal/testutil"
        "github.com/anacrolix/torrent/metainfo"
        "github.com/anacrolix/torrent/storage"
 )
@@ -14,11 +15,9 @@ type badStorage struct{}
 var _ storage.ClientImpl = badStorage{}
 
 func (bs badStorage) OpenTorrent(*metainfo.Info, metainfo.Hash) (storage.TorrentImpl, error) {
-       return bs, nil
-}
-
-func (bs badStorage) Close() error {
-       return nil
+       return storage.TorrentImpl{
+               Piece: bs.Piece,
+       }, nil
 }
 
 func (bs badStorage) Piece(p metainfo.Piece) storage.PieceImpl {
@@ -48,7 +47,7 @@ func (p badStoragePiece) MarkNotComplete() error {
 }
 
 func (p badStoragePiece) randomlyTruncatedDataString() string {
-       return "hello, world\n"[:rand.Intn(14)]
+       return testutil.GreetingFileContents[:rand.Intn(14)]
 }
 
 func (p badStoragePiece) ReadAt(b []byte, off int64) (n int, err error) {