From d1112e35df30a69e1b46d237c9e0ad9c5d22415a Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 24 Nov 2021 21:58:07 +0100 Subject: [PATCH] hashmail_test: fix race condition in test setup --- hashmail_server_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hashmail_server_test.go b/hashmail_server_test.go index fd2ee21..3f56f10 100644 --- a/hashmail_server_test.go +++ b/hashmail_server_test.go @@ -4,15 +4,15 @@ import ( "context" "crypto/rand" "fmt" + "github.com/lightningnetwork/lnd/build" + "github.com/lightningnetwork/lnd/signal" "math" "net/http" "testing" "time" "github.com/lightninglabs/lightning-node-connect/hashmailrpc" - "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/lntest/wait" - "github.com/lightningnetwork/lnd/signal" "github.com/stretchr/testify/require" "google.golang.org/grpc" ) @@ -27,6 +27,12 @@ var ( apertureStartTimeout = 3 * time.Second ) +func init() { + logWriter := build.NewRotatingLogWriter() + SetupLoggers(logWriter, signal.Interceptor{}) + _ = build.ParseAndSetDebugLevels("trace,PRXY=warn", logWriter) +} + func TestHashMailServerReturnStream(t *testing.T) { ctxb := context.Background() @@ -145,13 +151,6 @@ func TestHashMailServerLargeMessage(t *testing.T) { } func setupAperture(t *testing.T) { - logWriter := build.NewRotatingLogWriter() - - SetupLoggers(logWriter, signal.Interceptor{}) - - err := build.ParseAndSetDebugLevels("trace,PRXY=warn", logWriter) - require.NoError(t, err) - apertureCfg := &Config{ Insecure: true, ListenAddr: testApertureAddress, @@ -176,7 +175,7 @@ func setupAperture(t *testing.T) { default: } - err = wait.NoError(func() error { + err := wait.NoError(func() error { apertureAddr := fmt.Sprintf("http://%s/dummy", testApertureAddress)