Skip to content

Commit

Permalink
fix: use waitgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
shoriwe committed Jun 12, 2023
1 parent a1621a5 commit 3686e42
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions proxies/socks5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxies

import (
"net"
"sync"
"testing"

"github.com/shoriwe/fullproxy/v4/reverse"
Expand Down Expand Up @@ -38,7 +39,11 @@ func TestSocks5_Listener(t *testing.T) {
// Test
testMsg := []byte("HELLO")
// - Producer
var wg sync.WaitGroup
defer wg.Wait()
wg.Add(1)
go func() {
defer wg.Done()
conn, err := service.Accept()
assert.Nil(t, err)
defer conn.Close()
Expand Down Expand Up @@ -99,8 +104,12 @@ func TestSocks5_Reverse(t *testing.T) {
}
go sockProxy.Serve()
// - Producer
var wg sync.WaitGroup
defer wg.Wait()
testMsg := []byte("HELLO")
wg.Add(1)
go func() {
defer wg.Done()
conn, err := service.Accept()
assert.Nil(t, err)
defer conn.Close()
Expand Down Expand Up @@ -151,7 +160,11 @@ func TestSocks5_UsernamePassword(t *testing.T) {
go s.Serve()
// Producer
testMsg := []byte("HELLO")
var wg sync.WaitGroup
defer wg.Wait()
wg.Add(1)
go func() {
defer wg.Done()
conn, err := service.Accept()
assert.Nil(t, err)
defer conn.Close()
Expand Down

0 comments on commit 3686e42

Please sign in to comment.