-
-
Notifications
You must be signed in to change notification settings - Fork 690
Expand file tree
/
Copy pathissue211_test.go
More file actions
41 lines (34 loc) · 930 Bytes
/
Copy pathissue211_test.go
File metadata and controls
41 lines (34 loc) · 930 Bytes
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"
qt "github.com/go-quicktest/qt"
"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)
cfg.DialForPeerConns = false
cfg.AcceptPeerConnections = false
cl, err := NewClient(cfg)
qt.Assert(t, qt.IsNil(err))
defer cl.Close()
td, mi := testutil.GreetingTestTorrent()
mms := storage.NewMMap(td)
defer mms.Close()
tt, new := cl.AddTorrentOpt(AddTorrentOpts{
Storage: mms,
InfoHash: mi.HashInfoBytes(),
InfoBytes: mi.InfoBytes,
})
qt.Check(t, qt.IsTrue(new))
r := tt.NewReader()
go tt.Drop()
io.Copy(io.Discard, r)
}