From 12ec9992522c07de2cbf98c40b149cf2f0da94a7 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 22 Apr 2019 16:04:37 -0700 Subject: [PATCH] brontide/noise_test: defer wait group decrement If any of the checks in the goroutine fail, the test will deadlock since the waitgroup is never released. --- brontide/noise_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brontide/noise_test.go b/brontide/noise_test.go index 55ea4659..50de346c 100644 --- a/brontide/noise_test.go +++ b/brontide/noise_test.go @@ -269,6 +269,8 @@ func TestWriteMessageChunking(t *testing.T) { var wg sync.WaitGroup wg.Add(1) go func() { + defer wg.Done() + bytesWritten, err := localConn.Write(largeMessage) if err != nil { t.Fatalf("unable to write message: %v", err) @@ -280,7 +282,6 @@ func TestWriteMessageChunking(t *testing.T) { t.Fatalf("bytes not fully written!") } - wg.Done() }() // Attempt to read the entirety of the message generated above.