Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mininny committed Dec 3, 2024
1 parent 750bc4e commit 1be74b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
20 changes: 6 additions & 14 deletions op-node/p2p/gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/golang/snappy"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
opsigner "github.com/ethereum-optimism/optimism/op-service/signer"
Expand All @@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"

pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/libp2p/go-libp2p/core/peer"
Expand Down Expand Up @@ -125,7 +126,7 @@ func TestVerifyBlockSignatureWithRemoteSigner(t *testing.T) {
remoteSigner := &mockRemoteSigner{secrets}
server := oprpc.NewServer(
"127.0.0.1",
8545,
0,
"test",
oprpc.WithAPIs([]rpc.API{
{
Expand All @@ -149,10 +150,11 @@ func TestVerifyBlockSignatureWithRemoteSigner(t *testing.T) {
msg := []byte("any msg")

signerCfg := opsigner.NewCLIConfig()
signerCfg.Endpoint = "http://127.0.0.1:8545"
signerCfg.Endpoint = fmt.Sprintf("http://%s", server.Endpoint())
signerCfg.TLSConfig.TLSKey = ""
signerCfg.TLSConfig.TLSCert = ""
signerCfg.TLSConfig.TLSCaCert = ""
signerCfg.TLSConfig.Enabled = false

t.Run("Valid", func(t *testing.T) {
runCfg := &testutils.MockRuntimeConfig{P2PSeqAddress: crypto.PubkeyToAddress(secrets.PublicKey)}
Expand Down Expand Up @@ -196,7 +198,7 @@ func TestVerifyBlockSignatureWithRemoteSigner(t *testing.T) {

t.Run("RemoteSignerNoTLS", func(t *testing.T) {
signerCfg := opsigner.NewCLIConfig()
signerCfg.Endpoint = "http://127.0.0.1:8545"
signerCfg.Endpoint = fmt.Sprintf("http://%s", server.Endpoint())
signerCfg.TLSConfig.TLSKey = "invalid"
signerCfg.TLSConfig.TLSCert = "invalid"
signerCfg.TLSConfig.TLSCaCert = "invalid"
Expand All @@ -215,16 +217,6 @@ func TestVerifyBlockSignatureWithRemoteSigner(t *testing.T) {
_, err := NewRemoteSigner(logger, signerCfg)
require.Error(t, err)
})

t.Run("RemoteSignerInvalidEndpoint", func(t *testing.T) {
signerCfg := opsigner.NewCLIConfig()
signerCfg.Endpoint = "Invalid"
signerCfg.TLSConfig.TLSKey = ""
signerCfg.TLSConfig.TLSCert = ""
signerCfg.TLSConfig.TLSCaCert = ""
_, err := NewRemoteSigner(logger, signerCfg)
require.Error(t, err)
})
}

type MarshalSSZ interface {
Expand Down
7 changes: 0 additions & 7 deletions op-service/signer/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ func TestInvalidConfig(t *testing.T) {
config.TLSConfig.Enabled = true
},
},
{
name: "MissingAddress",
expected: "signer endpoint and address must both be set or not set",
configChange: func(config *CLIConfig) {
config.Endpoint = "http://localhost"
},
},
{
name: "InvalidTLSConfig",
expected: "all tls flags must be set if at least one is set",
Expand Down
3 changes: 1 addition & 2 deletions op-service/signer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ func (s *SignerClient) SignBlockPayload(ctx context.Context, args *BlockPayloadA
return [65]byte{}, fmt.Errorf("invalid signature: %s", result.String())
}

var signature [65]byte
copy(signature[:], result)
signature := [65]byte(result)

return signature, nil
}

0 comments on commit 1be74b5

Please sign in to comment.