8 "github.com/anacrolix/torrent/internal/testutil"
9 "github.com/anacrolix/torrent/storage"
10 "github.com/stretchr/testify/assert"
11 "github.com/stretchr/testify/require"
12 "golang.org/x/time/rate"
15 func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
16 cfg := TestingConfig()
17 // Ensure the data is present when the torrent is added, and not obtained
18 // over the network as the test runs.
19 cfg.DownloadRateLimiter = rate.NewLimiter(0, 0)
20 cl, err := NewClient(cfg)
21 require.NoError(t, err)
24 td, mi := testutil.GreetingTestTorrent()
25 tt, new, err := cl.AddTorrentSpec(&TorrentSpec{
26 Storage: storage.NewMMap(td),
27 InfoHash: mi.HashInfoBytes(),
28 InfoBytes: mi.InfoBytes,
30 require.NoError(t, err)
35 io.Copy(ioutil.Discard, r)