From f322f8b47f4754e6e43eb4a6d430a7ecd64765f3 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Mon, 28 Dec 2020 00:48:16 +0000 Subject: [PATCH] Randomise echo test data --- internal/multiplex/mux_test.go | 5 +++-- internal/test/integration_test.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/multiplex/mux_test.go b/internal/multiplex/mux_test.go index 86dec41..e492305 100644 --- a/internal/multiplex/mux_test.go +++ b/internal/multiplex/mux_test.go @@ -65,14 +65,15 @@ func makeSessionPair(numConn int) (*Session, *Session, []*connPair) { func runEchoTest(t *testing.T, conns []net.Conn, msgLen int) { var wg sync.WaitGroup - testData := make([]byte, msgLen) - rand.Read(testData) for _, conn := range conns { wg.Add(1) go func(conn net.Conn) { defer wg.Done() + testData := make([]byte, msgLen) + rand.Read(testData) + // we cannot call t.Fatalf in concurrent contexts n, err := conn.Write(testData) if n != msgLen { diff --git a/internal/test/integration_test.go b/internal/test/integration_test.go index 22935b2..e4072e0 100644 --- a/internal/test/integration_test.go +++ b/internal/test/integration_test.go @@ -222,14 +222,15 @@ func establishSession(lcc client.LocalConnConfig, rcc client.RemoteConnConfig, a func runEchoTest(t *testing.T, conns []net.Conn, msgLen int) { var wg sync.WaitGroup - testData := make([]byte, msgLen) - rand.Read(testData) for _, conn := range conns { wg.Add(1) go func(conn net.Conn) { defer wg.Done() + testData := make([]byte, msgLen) + rand.Read(testData) + // we cannot call t.Fatalf in concurrent contexts n, err := conn.Write(testData) if n != msgLen {