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