From 1be74b5329e5d4aa5cfb72cdbe9965a235b73055 Mon Sep 17 00:00:00 2001 From: Minhyuk Kim Date: Thu, 31 Oct 2024 10:42:01 -0600 Subject: [PATCH] Clean up tests --- op-node/p2p/gossip_test.go | 20 ++++++-------------- op-service/signer/cli_test.go | 7 ------- op-service/signer/client.go | 3 +-- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/op-node/p2p/gossip_test.go b/op-node/p2p/gossip_test.go index b2c9aabcaaaf..9f047f4b5ba8 100644 --- a/op-node/p2p/gossip_test.go +++ b/op-node/p2p/gossip_test.go @@ -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" @@ -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" @@ -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{ { @@ -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)} @@ -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" @@ -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 { diff --git a/op-service/signer/cli_test.go b/op-service/signer/cli_test.go index 46485592a3eb..3453258c6ca1 100644 --- a/op-service/signer/cli_test.go +++ b/op-service/signer/cli_test.go @@ -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", diff --git a/op-service/signer/client.go b/op-service/signer/client.go index 2bcf3e35b812..acd753ecef7a 100644 --- a/op-service/signer/client.go +++ b/op-service/signer/client.go @@ -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 }