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.
This commit is contained in:
parent
e3728da478
commit
12ec999252
@ -269,6 +269,8 @@ func TestWriteMessageChunking(t *testing.T) {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
bytesWritten, err := localConn.Write(largeMessage)
|
bytesWritten, err := localConn.Write(largeMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to write message: %v", err)
|
t.Fatalf("unable to write message: %v", err)
|
||||||
@ -280,7 +282,6 @@ func TestWriteMessageChunking(t *testing.T) {
|
|||||||
t.Fatalf("bytes not fully written!")
|
t.Fatalf("bytes not fully written!")
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Done()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Attempt to read the entirety of the message generated above.
|
// Attempt to read the entirety of the message generated above.
|
||||||
|
Loading…
Reference in New Issue
Block a user