client_test.go | 18 ++++++++++++++++++ diff --git a/client_test.go b/client_test.go index be387f78712d907d79c6eda9f04a25d88167685f..fb797b2bb9607e1f30602d028a6f202b14495bac 100644 --- a/client_test.go +++ b/client_test.go @@ -15,6 +15,7 @@ "time" _ "github.com/anacrolix/envpprof" "github.com/anacrolix/missinggo" + . "github.com/anacrolix/missinggo" "github.com/anacrolix/utp" "github.com/bradfitz/iter" "github.com/stretchr/testify/assert" @@ -587,3 +588,20 @@ require.True(t, new) // Obtained from the metainfo cache. require.NotNil(t, tt.Info()) } + +func TestTorrentDroppedBeforeGotInfo(t *testing.T) { + dir, mi := testutil.GreetingTestTorrent() + os.RemoveAll(dir) + cl, _ := NewClient(&TestingConfig) + defer cl.Close() + var ts TorrentSpec + CopyExact(&ts.InfoHash, mi.Info.Hash) + tt, _, _ := cl.AddTorrentSpec(&ts) + tt.Drop() + assert.EqualValues(t, 0, len(cl.Torrents())) + select { + case <-tt.GotInfo(): + t.FailNow() + default: + } +}