6 "github.com/anacrolix/missinggo/v2/resource"
7 "github.com/stretchr/testify/assert"
8 "github.com/stretchr/testify/require"
10 "github.com/anacrolix/torrent/metainfo"
13 // Two different torrents opened from the same storage. Closing one should not
14 // break the piece completion on the other.
15 func testIssue95(t *testing.T, c ClientImpl) {
17 Files: []metainfo.FileInfo{{Path: []string{"a"}}},
18 Pieces: make([]byte, 20),
20 t1, err := c.OpenTorrent(i1, metainfo.HashBytes([]byte("a")))
21 require.NoError(t, err)
24 Files: []metainfo.FileInfo{{Path: []string{"a"}}},
25 Pieces: make([]byte, 20),
27 t2, err := c.OpenTorrent(i2, metainfo.HashBytes([]byte("b")))
28 require.NoError(t, err)
30 t2p := t2.Piece(i2.Piece(0))
31 assert.NoError(t, t1.Close())
32 assert.NotPanics(t, func() { t2p.Completion() })
35 func TestIssue95File(t *testing.T) {
42 func TestIssue95MMap(t *testing.T) {
49 func TestIssue95ResourcePieces(t *testing.T) {
50 testIssue95(t, NewResourcePieces(resource.OSFileProvider{}))