]> Sergey Matveev's repositories - btrtrc.git/blobdiff - reuse_test.go
gorond test files
[btrtrc.git] / reuse_test.go
index 3adf002f6fbeb07d1edd4c2504ca2c9f8f870e4b..ba53f288766e39cd687ce73fc2b1244557ab203c 100644 (file)
@@ -9,7 +9,6 @@ import (
        "testing"
 
        "github.com/anacrolix/log"
-
        qt "github.com/frankban/quicktest"
 )
 
@@ -42,7 +41,9 @@ func TestUtpLocalPortIsReusable(t *testing.T) {
        c.Assert(err, qt.IsNil)
        defer remote.Close()
        var remoteAccepts int32
+       doneAccepting := make(chan struct{})
        go func() {
+               defer close(doneAccepting)
                for {
                        c, err := remote.Accept()
                        if err != nil {
@@ -66,5 +67,6 @@ func TestUtpLocalPortIsReusable(t *testing.T) {
        c.Assert(err, qt.IsNil)
        defer second.Close()
        remote.Close()
+       <-doneAccepting
        c.Assert(atomic.LoadInt32(&remoteAccepts), qt.Equals, int32(2))
 }