Add a test for double Close of torrent.torrent

This commit is contained in:
Matt Joiner 2014-08-28 08:03:55 +10:00
parent 7dd932bd5a
commit 89be570636
1 changed files with 19 additions and 1 deletions

View File

@ -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()
}