From 89be570636d990e5e06750aa5e774f480bea6172 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 28 Aug 2014 08:03:55 +1000 Subject: [PATCH] Add a test for double Close of torrent.torrent --- torrent_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/torrent_test.go b/torrent_test.go index 0eff12cd..18306ecf 100644 --- a/torrent_test.go +++ b/torrent_test.go @@ -1,8 +1,10 @@ package torrent import ( - "bitbucket.org/anacrolix/go.torrent/peer_protocol" + "sync" "testing" + + "bitbucket.org/anacrolix/go.torrent/peer_protocol" ) func r(i, b, l peer_protocol.Integer) request { @@ -40,3 +42,19 @@ func TestTorrentRequest(t *testing.T) { } } } + +func TestTorrentDoubleClose(t *testing.T) { + tt, err := newTorrent(InfoHash{}, nil) + if err != nil { + t.Fatal(err) + } + wg := sync.WaitGroup{} + for i := 0; i < 2; i++ { + wg.Add(1) + go func() { + tt.Close() + wg.Done() + }() + } + wg.Wait() +} -- 2.48.1