Skip to content

Commit 65ed9d3

Browse files
committed
[FAB-13469] consistently use 127.0.0.1
localhost can resolve to ::1 in some network environments so avoid that by using 127.0.0.1. Also, when getting a connection fails, we shouldn't try to close it. Change-Id: I617357abb1d5d29514634b3e3ad59d93feb8429a Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent beb2035 commit 65ed9d3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cmd/common/comm/client_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/hyperledger/fabric/core/comm"
1919
"github.com/stretchr/testify/assert"
20+
"github.com/stretchr/testify/require"
2021
)
2122

2223
func TestTLSClient(t *testing.T) {
@@ -34,9 +35,9 @@ func TestTLSClient(t *testing.T) {
3435
cl, err := NewClient(conf)
3536
assert.NoError(t, err)
3637
_, port, _ := net.SplitHostPort(srv.Address())
37-
dial := cl.NewDialer(net.JoinHostPort("localhost", port))
38+
dial := cl.NewDialer(net.JoinHostPort("127.0.0.1", port))
3839
conn, err := dial()
39-
assert.NoError(t, err)
40+
require.NoError(t, err)
4041
conn.Close()
4142
}
4243

@@ -63,9 +64,9 @@ func TestNonTLSClient(t *testing.T) {
6364
cl, err := NewClient(conf)
6465
assert.NoError(t, err)
6566
_, port, _ := net.SplitHostPort(srv.Address())
66-
dial := cl.NewDialer(fmt.Sprintf("localhost:%s", port))
67+
dial := cl.NewDialer(net.JoinHostPort("127.0.0.1", port))
6768
conn, err := dial()
68-
assert.NoError(t, err)
69+
require.NoError(t, err)
6970
conn.Close()
7071
}
7172

0 commit comments

Comments
 (0)