]> Sergey Matveev's repositories - btrtrc.git/blob - issue211_test.go
Remove old-style build tags
[btrtrc.git] / issue211_test.go
1 //go:build !wasm
2
3 package torrent
4
5 import (
6         "io"
7         "io/ioutil"
8         "testing"
9
10         "github.com/stretchr/testify/assert"
11         "github.com/stretchr/testify/require"
12         "golang.org/x/time/rate"
13
14         "github.com/anacrolix/torrent/internal/testutil"
15         "github.com/anacrolix/torrent/storage"
16 )
17
18 func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
19         cfg := TestingConfig(t)
20         // Ensure the data is present when the torrent is added, and not obtained
21         // over the network as the test runs.
22         cfg.DownloadRateLimiter = rate.NewLimiter(0, 0)
23         cl, err := NewClient(cfg)
24         require.NoError(t, err)
25         defer cl.Close()
26
27         td, mi := testutil.GreetingTestTorrent()
28         tt, new, err := cl.AddTorrentSpec(&TorrentSpec{
29                 Storage:   storage.NewMMap(td),
30                 InfoHash:  mi.HashInfoBytes(),
31                 InfoBytes: mi.InfoBytes,
32         })
33         require.NoError(t, err)
34         assert.True(t, new)
35
36         r := tt.NewReader()
37         go tt.Drop()
38         io.Copy(ioutil.Discard, r)
39 }