2016-07-12 06:42:54 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent/internal/testutil"
|
|
|
|
"github.com/anacrolix/torrent/storage"
|
2018-11-02 12:12:01 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2016-07-12 06:42:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestHashPieceAfterStorageClosed(t *testing.T) {
|
|
|
|
td, err := ioutil.TempDir("", "")
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.RemoveAll(td)
|
2018-01-25 06:10:37 +00:00
|
|
|
tt := &Torrent{
|
|
|
|
storageOpener: storage.NewClient(storage.NewFile(td)),
|
|
|
|
}
|
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)
|
|
|
|
}
|