forked from anacrolix/torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue211_test.go
41 lines (34 loc) · 926 Bytes
/
issue211_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//go:build !wasm
// +build !wasm
package torrent
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/time/rate"
"github.com/anacrolix/torrent/internal/testutil"
"github.com/anacrolix/torrent/storage"
)
func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
cfg := TestingConfig(t)
// Ensure the data is present when the torrent is added, and not obtained
// over the network as the test runs.
cfg.DownloadRateLimiter = rate.NewLimiter(0, 0)
cl, err := NewClient(cfg)
require.NoError(t, err)
defer cl.Close()
td, mi := testutil.GreetingTestTorrent()
mms := storage.NewMMap(td)
defer mms.Close()
tt, new, err := cl.AddTorrentSpec(&TorrentSpec{
Storage: mms,
InfoHash: mi.HashInfoBytes(),
InfoBytes: mi.InfoBytes,
})
require.NoError(t, err)
assert.True(t, new)
r := tt.NewReader()
go tt.Drop()
io.Copy(io.Discard, r)
}