Skip to content

Commit

Permalink
Use nettest instead of net in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Jul 15, 2019
1 parent 6e8a7ca commit 531e474
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/therealproxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/skycoin/skycoin/src/util/logging"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/nettest"
"golang.org/x/net/proxy"
)

Expand All @@ -35,7 +36,7 @@ func TestProxy(t *testing.T) {
srv, err := NewServer("")
require.NoError(t, err)

l, err := net.Listen("tcp", "localhost:10081")
l, err := nettest.NewLocalListener("tcp")
require.NoError(t, err)

errChan := make(chan error)
Expand All @@ -45,20 +46,20 @@ func TestProxy(t *testing.T) {

time.Sleep(100 * time.Millisecond)

conn, err := net.Dial("tcp", "localhost:10081")
conn, err := net.Dial("tcp", l.Addr().String())
require.NoError(t, err)

client, err := NewClient(conn)
require.NoError(t, err)

errChan2 := make(chan error)
go func() {
errChan2 <- client.ListenAndServe("localhost:10080")
errChan2 <- client.ListenAndServe(":10080")
}()

time.Sleep(100 * time.Millisecond)

proxyDial, err := proxy.SOCKS5("tcp", "localhost:10080", nil, proxy.Direct)
proxyDial, err := proxy.SOCKS5("tcp", ":10080", nil, proxy.Direct)
require.NoError(t, err)

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 531e474

Please sign in to comment.