]> Sergey Matveev's repositories - btrtrc.git/blob - issue97_test.go
1e6373cc64fe7e760b0432b403fa07e8b01068aa
[btrtrc.git] / issue97_test.go
1 package torrent
2
3 import (
4         "io/ioutil"
5         "os"
6         "testing"
7
8         "github.com/stretchr/testify/require"
9
10         "github.com/anacrolix/torrent/internal/testutil"
11         "github.com/anacrolix/torrent/storage"
12 )
13
14 func TestHashPieceAfterStorageClosed(t *testing.T) {
15         td, err := ioutil.TempDir("", "")
16         require.NoError(t, err)
17         defer os.RemoveAll(td)
18         cs := storage.NewFile(td)
19         tt := &Torrent{}
20         mi := testutil.GreetingMetaInfo()
21         info := mi.UnmarshalInfo()
22         tt.info = &info
23         tt.makePieces()
24         tt.storage, err = cs.OpenTorrent(tt.info, mi.HashInfoBytes())
25         require.NoError(t, err)
26         require.NoError(t, tt.storage.Close())
27         tt.hashPiece(0)
28 }