FedP2P/issue97_test.go

30 lines
665 B
Go
Raw Normal View History

2016-07-12 14:42:54 +08:00
package torrent
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/anacrolix/torrent/internal/testutil"
"github.com/anacrolix/torrent/storage"
)
func TestHashPieceAfterStorageClosed(t *testing.T) {
td, err := ioutil.TempDir("", "")
require.NoError(t, err)
defer os.RemoveAll(td)
cs := storage.NewClient(storage.NewFile(td))
2016-07-12 14:42:54 +08:00
tt := &Torrent{}
mi := testutil.GreetingMetaInfo()
info, err := mi.UnmarshalInfo()
require.NoError(t, err)
tt.info = &info
2016-07-12 14:42:54 +08:00
tt.makePieces()
tt.storage, err = cs.OpenTorrent(tt.info, mi.HashInfoBytes())
2016-07-12 14:42:54 +08:00
require.NoError(t, err)
require.NoError(t, tt.storage.Close())
tt.hashPiece(0)
}