Skip to content

Commit 9c1ac84

Browse files
committed
polish
1 parent c45885f commit 9c1ac84

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

mod/nodes/test/links_test.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package nodes
33
import (
44
"context"
55
"os"
6-
"sync"
76
"testing"
7+
"time"
88

99
"github.com/cryptopunkscc/astrald/astral"
1010
"github.com/cryptopunkscc/astrald/astral/log"
@@ -23,27 +23,20 @@ func Test_ConnectAccept(t *testing.T) {
2323
&Endpoint{address: "1"},
2424
&Endpoint{address: "2"},
2525
)
26-
27-
ctx := context.Background()
28-
wg := sync.WaitGroup{}
29-
wg.Add(2)
30-
go func() {
31-
t.Log("verify connect")
26+
t.Run("connect", func(t *testing.T) {
27+
t.Parallel()
28+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
29+
defer cancel()
3230
assert.NoError(t, m1.Connect(ctx, n2.Identity(), outConn))
3331
assert.True(t, m1.IsLinked(n2.Identity()))
34-
35-
t.Log("done 1")
36-
wg.Done()
37-
}()
38-
go func() {
39-
t.Log("verify accept")
32+
})
33+
t.Run("accept", func(t *testing.T) {
34+
t.Parallel()
35+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
36+
defer cancel()
4037
assert.NoError(t, m2.Accept(ctx, inConn))
4138
assert.True(t, m2.IsLinked(n1.Identity()))
42-
43-
t.Log("done 2")
44-
wg.Done()
45-
}()
46-
wg.Wait()
39+
})
4740
}
4841

4942
func newTestModule(t *testing.T) (astral.Node, *nodes.Module) {

0 commit comments

Comments
 (0)