2016-07-12 06:42:54 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-01-07 08:18:07 +00:00
|
|
|
"github.com/anacrolix/log"
|
2019-08-21 10:58:40 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2016-07-12 06:42:54 +00:00
|
|
|
"github.com/anacrolix/torrent/internal/testutil"
|
|
|
|
"github.com/anacrolix/torrent/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHashPieceAfterStorageClosed(t *testing.T) {
|
2022-02-02 07:26:46 +00:00
|
|
|
td := t.TempDir()
|
2023-05-27 04:57:41 +00:00
|
|
|
cs := storage.NewFile(td)
|
|
|
|
defer cs.Close()
|
2018-01-25 06:10:37 +00:00
|
|
|
tt := &Torrent{
|
2023-05-27 04:57:41 +00:00
|
|
|
storageOpener: storage.NewClient(cs),
|
2020-01-07 08:18:07 +00:00
|
|
|
logger: log.Default,
|
2021-10-13 04:17:48 +00:00
|
|
|
chunkSize: defaultChunkSize,
|
2018-01-25 06:10:37 +00:00
|
|
|
}
|
2016-08-26 10:29:05 +00:00
|
|
|
mi := testutil.GreetingMetaInfo()
|
2016-09-20 08:39:07 +00:00
|
|
|
info, err := mi.UnmarshalInfo()
|
|
|
|
require.NoError(t, err)
|
2018-01-25 06:10:37 +00:00
|
|
|
require.NoError(t, tt.setInfo(&info))
|
2016-07-12 06:42:54 +00:00
|
|
|
require.NoError(t, tt.storage.Close())
|
|
|
|
tt.hashPiece(0)
|
|
|
|
}
|