Skip to content

Commit

Permalink
Address review feedback.
Browse files Browse the repository at this point in the history
Specifically:
  1. Move the net package to util/testhelpers.
  2. Remove the concurrency test.
  3. Rename the SignerServer listner member.
  • Loading branch information
eljobe committed Jun 11, 2024
1 parent 34201ca commit 5ec9be6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 60 deletions.
9 changes: 4 additions & 5 deletions arbnode/dataposter/externalsignertest/externalsignertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/offchainlabs/nitro/arbnode/dataposter/externalsigner"

nnet "github.com/offchainlabs/nitro/net"
"github.com/offchainlabs/nitro/util/testhelpers"
)

var (
Expand All @@ -42,7 +41,7 @@ type CertAbsPaths struct {
type SignerServer struct {
*http.Server
*SignerAPI
l net.Listener
listener net.Listener
}

func basePath() (string, error) {
Expand Down Expand Up @@ -101,7 +100,7 @@ func NewServer(t *testing.T) *SignerServer {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(clientCert)

ln, err := nnet.FreeTCPPortListener()
ln, err := testhelpers.FreeTCPPortListener()
if err != nil {
t.Fatalf("Error getting a listener on a free TCP port: %v", err)
}
Expand Down Expand Up @@ -147,7 +146,7 @@ func (s *SignerServer) Start() error {
if err != nil {
return err
}
if err := s.ServeTLS(s.l, cp.ServerCert, cp.ServerKey); err != nil && !errors.Is(err, http.ErrServerClosed) {
if err := s.ServeTLS(s.listener, cp.ServerCert, cp.ServerKey); err != nil && !errors.Is(err, http.ErrServerClosed) {
return err
}
return nil
Expand Down
53 changes: 0 additions & 53 deletions net/port_test.go

This file was deleted.

3 changes: 1 addition & 2 deletions net/port.go → util/testhelpers/port.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Package net provides facilities for working with network connections.
package net
package testhelpers

import (
"net"
Expand Down
23 changes: 23 additions & 0 deletions util/testhelpers/port_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package testhelpers

import (
"net"
"testing"
)

func TestFreeTCPPortListener(t *testing.T) {
aListener, err := FreeTCPPortListener()
if err != nil {
t.Fatal(err)
}
bListener, err := FreeTCPPortListener()
if err != nil {
t.Fatal(err)
}
if aListener.Addr().(*net.TCPAddr).Port == bListener.Addr().(*net.TCPAddr).Port {
t.Errorf("FreeTCPPortListener() got same port: %v, %v", aListener, bListener)
}
if aListener.Addr().(*net.TCPAddr).Port == 0 || bListener.Addr().(*net.TCPAddr).Port == 0 {
t.Errorf("FreeTCPPortListener() got port 0")
}
}

0 comments on commit 5ec9be6

Please sign in to comment.