X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=issue211_test.go;h=a76be07a8a2da0a6c6682e28038eb610a9d8f140;hb=HEAD;hp=8a0d8b3bf00657ee2a798d23c60229c79fb24793;hpb=10f7a8124a9e89b065ac0237118fe3e68969ae17;p=btrtrc.git diff --git a/issue211_test.go b/issue211_test.go index 8a0d8b3b..a76be07a 100644 --- a/issue211_test.go +++ b/issue211_test.go @@ -1,8 +1,10 @@ +//go:build !wasm +// +build !wasm + package torrent import ( "io" - "io/ioutil" "testing" "github.com/stretchr/testify/assert" @@ -13,8 +15,8 @@ import ( "github.com/anacrolix/torrent/storage" ) -func TestDropTorrentWhileHashing(t *testing.T) { - cfg := TestingConfig() +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) @@ -23,24 +25,17 @@ func TestDropTorrentWhileHashing(t *testing.T) { defer cl.Close() td, mi := testutil.GreetingTestTorrent() + mms := storage.NewMMap(td) + defer mms.Close() tt, new, err := cl.AddTorrentSpec(&TorrentSpec{ - Storage: storage.NewMMap(td), + Storage: mms, InfoHash: mi.HashInfoBytes(), InfoBytes: mi.InfoBytes, }) require.NoError(t, err) assert.True(t, new) - // Make sure some of the data is actually there. - sub := tt.SubscribePieceStateChanges() - for range sub.Values { - if tt.BytesCompleted() > 0 { - break - } - } - sub.Close() - r := tt.NewReader() go tt.Drop() - io.Copy(ioutil.Discard, r) + io.Copy(io.Discard, r) }