]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add a test for double Close of torrent.torrent
authorMatt Joiner <anacrolix@gmail.com>
Wed, 27 Aug 2014 22:03:55 +0000 (08:03 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 27 Aug 2014 22:03:55 +0000 (08:03 +1000)
torrent_test.go

index 0eff12cdbde2bf44208dae28f29d8f582cb0ede9..18306ecf747ebda9cc8dea2a34efb143d3c7ab98 100644 (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()
+}