From 3fa671b671bfb2b10b3a6cef0c5b3d0eb02f4026 Mon Sep 17 00:00:00 2001 From: Joe Huang Date: Tue, 21 Jan 2025 21:05:34 -0600 Subject: [PATCH] fix lint --- core/capabilities/ccip/ccipevm/helpers.go | 9 +++++---- core/capabilities/ccip/ccipevm/helpers_test.go | 4 ++-- core/capabilities/ccip/ccipsolana/helpers.go | 1 + core/capabilities/ccip/ccipsolana/helpers_test.go | 5 +++-- core/capabilities/ccip/common/extraargscodec.go | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/capabilities/ccip/ccipevm/helpers.go b/core/capabilities/ccip/ccipevm/helpers.go index a1373032102..8079b934b12 100644 --- a/core/capabilities/ccip/ccipevm/helpers.go +++ b/core/capabilities/ccip/ccipevm/helpers.go @@ -55,13 +55,14 @@ func DecodeExtraArgsToMap(extraArgs []byte) (map[string]any, error) { } var method string - if bytes.Equal(extraArgs[:4], evmExtraArgsV1Tag) { + switch string(extraArgs[:4]) { + case string(evmExtraArgsV1Tag): method = evmV1DecodeName - } else if bytes.Equal(extraArgs[:4], evmExtraArgsV2Tag) { + case string(evmExtraArgsV2Tag): method = evmV2DecodeName - } else if bytes.Equal(extraArgs[:4], svmExtraArgsV1Tag) { + case string(svmExtraArgsV1Tag): method = svmV1DecodeName - } else { + default: return nil, fmt.Errorf("unknown extra args tag: %x", extraArgs) } diff --git a/core/capabilities/ccip/ccipevm/helpers_test.go b/core/capabilities/ccip/ccipevm/helpers_test.go index 25078852e3a..dc7593a5213 100644 --- a/core/capabilities/ccip/ccipevm/helpers_test.go +++ b/core/capabilities/ccip/ccipevm/helpers_test.go @@ -48,7 +48,7 @@ func Test_decodeExtraArgs(t *testing.T) { m, err := DecodeExtraArgsToMap(encoded) require.NoError(t, err) - require.Equal(t, 1, len(m)) + require.Len(t, m, 1) }) t.Run("decode extra args into map evm v2", func(t *testing.T) { @@ -60,7 +60,7 @@ func Test_decodeExtraArgs(t *testing.T) { m, err := DecodeExtraArgsToMap(encoded) require.NoError(t, err) - require.Equal(t, 2, len(m)) + require.Len(t, m, 2) }) t.Run("decode extra args into map svm", func(t *testing.T) { diff --git a/core/capabilities/ccip/ccipsolana/helpers.go b/core/capabilities/ccip/ccipsolana/helpers.go index 1d3d976dfda..d1896fe0035 100644 --- a/core/capabilities/ccip/ccipsolana/helpers.go +++ b/core/capabilities/ccip/ccipsolana/helpers.go @@ -5,6 +5,7 @@ import ( "reflect" agbinary "github.com/gagliardetto/binary" + "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router" ) diff --git a/core/capabilities/ccip/ccipsolana/helpers_test.go b/core/capabilities/ccip/ccipsolana/helpers_test.go index fd701f0c72f..ae765e87406 100644 --- a/core/capabilities/ccip/ccipsolana/helpers_test.go +++ b/core/capabilities/ccip/ccipsolana/helpers_test.go @@ -6,9 +6,10 @@ import ( agbinary "github.com/gagliardetto/binary" "github.com/gagliardetto/solana-go" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-ccip/chains/solana/contracts/tests/config" "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router" - "github.com/stretchr/testify/require" ) func Test_decodeExtraArgs(t *testing.T) { @@ -29,6 +30,6 @@ func Test_decodeExtraArgs(t *testing.T) { require.NoError(t, err) output, err := DecodeExtraArgsToMap(buf.Bytes()) require.NoError(t, err) - require.Equal(t, 3, len(output)) + require.Len(t, output, 3) }) } diff --git a/core/capabilities/ccip/common/extraargscodec.go b/core/capabilities/ccip/common/extraargscodec.go index 4914fc9b924..dd168084a2d 100644 --- a/core/capabilities/ccip/common/extraargscodec.go +++ b/core/capabilities/ccip/common/extraargscodec.go @@ -4,6 +4,7 @@ import ( "fmt" chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana"