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, ci ClientImpl) {
16 info := metainfo.Info{
17 Files: []metainfo.FileInfo{{Path: []string{"a"}, Length: 1}},
18 Pieces: make([]byte, 20),
22 t1, err := c.OpenTorrent(&info, metainfo.HashBytes([]byte("a")))
23 require.NoError(t, err)
25 t2, err := c.OpenTorrent(&info, metainfo.HashBytes([]byte("b")))
26 require.NoError(t, err)
28 t2p := t2.Piece(info.Piece(0))
29 assert.NoError(t, t1.Close())
30 assert.NotPanics(t, func() { t2p.Completion() })
33 func TestIssue95File(t *testing.T) {
40 func TestIssue95MMap(t *testing.T) {
47 func TestIssue95ResourcePieces(t *testing.T) {
48 testIssue95(t, NewResourcePieces(resource.OSFileProvider{}))