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