Skip to content

Commit

Permalink
use string type for ip parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-pure committed Mar 25, 2021
1 parent ac98f51 commit b6e78b1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion channel/channel_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestChannel(t *testing.T) {
}

func listen(ctx context.Context, attacher channel.Attacher, self, other id.Signatory) int {
ip := net.IPv4(127, 0, 0, 1)
ip := "127.0.0.1"
listener, port, err := tcp.ListenerWithAssignedPort(ctx, ip)
Expect(err).ToNot(HaveOccurred())
go func() {
Expand Down
2 changes: 1 addition & 1 deletion handshake/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func listenOnAssignedPort(ctx context.Context) <-chan int {
privKey := id.NewPrivKey()
h := handshake.ECIES(privKey)

ip := net.IPv4(127, 0, 0, 1)
ip := "127.0.0.1"
listener, port, err := tcp.ListenerWithAssignedPort(ctx, ip)
Expect(err).ToNot(HaveOccurred())
portCh <- port
Expand Down
4 changes: 2 additions & 2 deletions handshake/once_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Handshake", func() {
handshakeDone2 := make(chan struct{}, 1)
serverHandshakeDone := make(chan struct{}, 2)

ip := net.IPv4(127, 0, 0, 1)
ip := "127.0.0.1"
portCh1 := make(chan int, 1)
portCh2 := make(chan int, 1)

Expand Down Expand Up @@ -139,7 +139,7 @@ var _ = Describe("Handshake", func() {
handshakeDone2 := make(chan struct{}, 1)
serverHandshakeDone := make(chan struct{}, 2)

ip := net.IPv4(127, 0, 0, 1)
ip := "127.0.0.1"
portCh := make(chan int, 1)

var connectionKillCount int64 = 0
Expand Down
4 changes: 2 additions & 2 deletions tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func ListenWithListener(ctx context.Context, listener net.Listener, handle func(

// ListenerWithAssignedPort creates a new listener on a random port assigned by
// the OS. On success, both the listener and port are returned.
func ListenerWithAssignedPort(ctx context.Context, ip net.IP) (net.Listener, int, error) {
listener, err := new(net.ListenConfig).Listen(ctx, "tcp", fmt.Sprintf("%v:%v", ip.String(), 0))
func ListenerWithAssignedPort(ctx context.Context, ip string) (net.Listener, int, error) {
listener, err := new(net.ListenConfig).Listen(ctx, "tcp", fmt.Sprintf("%v:%v", ip, 0))
if err != nil {
return nil, 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion tcp/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("TCP", func() {
}
var listener net.Listener
var err error
ip := net.IPv4(127, 0, 0, 1)
ip := "127.0.0.1"
listener, port, err = tcp.ListenerWithAssignedPort(ctx, ip)
Expect(err).ToNot(HaveOccurred())
go func() {
Expand Down

0 comments on commit b6e78b1

Please sign in to comment.