Skip to content

Commit

Permalink
linter fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
valerii-kabisov-cll committed Sep 30, 2024
1 parent 7ff013d commit 27ac94d
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 39 deletions.
1 change: 1 addition & 0 deletions core/capabilities/integration_tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func setupStreamDonsWithTransmissionSchedule(ctx context.Context, t *testing.T,
return consumer, feedIDs, sink
}

// nolint:revive
func createDons(ctx context.Context, t *testing.T, lggr logger.Logger, reportsSink *reportsSink,
workflowDon donInfo,
triggerDon donInfo,
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func success() <-chan capabilities.CapabilityResponse {
return callback
}

// nolint:revive
func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.CapabilityRequest) (<-chan capabilities.CapabilityResponse, error) {
// Bind to the contract address on the write path.
// Bind() requires a connection to the node's RPCs and
Expand Down Expand Up @@ -283,8 +284,8 @@ func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.Cap
if err := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil {
if commontypes.ErrSettingTransactionGasLimitNotSupported.Is(err) {
meta.GasLimit = nil
if err := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil {
return nil, fmt.Errorf("failed to submit transaction: %w", err)
if err2 := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil {
return nil, fmt.Errorf("failed to submit transaction: %w", err2)
}
} else {
return nil, fmt.Errorf("failed to submit transaction: %w", err)
Expand Down
14 changes: 7 additions & 7 deletions core/capabilities/targets/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func TestWriteTarget(t *testing.T) {
})

t.Run("passes gas limit set on config to the chain writer", func(t *testing.T) {
configGasLimit, err := values.NewMap(map[string]any{
configGasLimit, err2 := values.NewMap(map[string]any{
"Address": forwarderAddr,
"GasLimit": 500000,
})
require.NoError(t, err)
require.NoError(t, err2)
req := capabilities.CapabilityRequest{
Metadata: validMetadata,
Config: configGasLimit,
Expand All @@ -130,16 +130,16 @@ func TestWriteTarget(t *testing.T) {
meta := types.TxMeta{WorkflowExecutionID: &req.Metadata.WorkflowExecutionID, GasLimit: big.NewInt(500000)}
cw.On("SubmitTransaction", mock.Anything, "forwarder", "report", mock.Anything, mock.Anything, forwarderAddr, &meta, mock.Anything).Return(types.ErrSettingTransactionGasLimitNotSupported)

_, err2 := writeTarget.Execute(ctx, req)
_, err2 = writeTarget.Execute(ctx, req)
require.Error(t, err2)
})

t.Run("retries without gas limit when ChainWriter's SubmitTransaction returns error due to gas limit not supported", func(t *testing.T) {
configGasLimit, err := values.NewMap(map[string]any{
configGasLimit, err2 := values.NewMap(map[string]any{
"Address": forwarderAddr,
"GasLimit": 500000,
})
require.NoError(t, err)
require.NoError(t, err2)
req := capabilities.CapabilityRequest{
Metadata: validMetadata,
Config: configGasLimit,
Expand All @@ -151,7 +151,7 @@ func TestWriteTarget(t *testing.T) {
meta = types.TxMeta{WorkflowExecutionID: &req.Metadata.WorkflowExecutionID}
cw.On("SubmitTransaction", mock.Anything, "forwarder", "report", mock.Anything, mock.Anything, forwarderAddr, &meta, mock.Anything).Return(nil)

configGasLimit, err = values.NewMap(map[string]any{
configGasLimit, _ = values.NewMap(map[string]any{
"Address": forwarderAddr,
})
req = capabilities.CapabilityRequest{
Expand All @@ -160,7 +160,7 @@ func TestWriteTarget(t *testing.T) {
Inputs: validInputs,
}

_, err2 := writeTarget.Execute(ctx, req)
_, err2 = writeTarget.Execute(ctx, req)
require.Error(t, err2)
})

Expand Down
1 change: 0 additions & 1 deletion core/chains/evm/client/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func TestRPCClient_SubscribeNewHead(t *testing.T) {
}()
wg.Wait()
}

})
t.Run("Concurrent Unsubscribe and onNewHead calls do not lead to a deadlock", func(t *testing.T) {
const numberOfAttempts = 1000 // need a large number to increase the odds of reproducing the issue
Expand Down
2 changes: 1 addition & 1 deletion core/services/llo/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (d *dataSource) Observe(ctx context.Context, streamValues llo.StreamValues,

if opts.VerboseLogging() {
successes := make([]streams.StreamID, 0, len(streamValues))
for strmID, _ := range streamValues {
for strmID := range streamValues {
successes = append(successes, strmID)
}
sort.Slice(successes, func(i, j int) bool { return successes[i] < successes[j] })
Expand Down
6 changes: 2 additions & 4 deletions core/services/llo/evm/report_codec_premium_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ func (r *ReportFormatEVMPremiumLegacyOpts) Decode(opts []byte) error {
// special case if opts are unspecified, just use the zero options rather than erroring
return nil
}
if err := json.Unmarshal(opts, r); err != nil {
return err
}
return nil
return json.Unmarshal(opts, r)
}

func (r ReportCodecPremiumLegacy) Encode(report llo.Report, cd llotypes.ChannelDefinition) ([]byte, error) {
Expand Down Expand Up @@ -103,6 +100,7 @@ func (r ReportCodecPremiumLegacy) Decode(b []byte) (*reporttypes.Report, error)
}

// Pack assembles the report values into a payload for verifying on-chain
// nolint:revive
func (r ReportCodecPremiumLegacy) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []types.AttributedOnchainSignature) ([]byte, error) {
var rs [][32]byte
var ss [][32]byte
Expand Down
1 change: 1 addition & 0 deletions core/services/llo/evm/report_codec_premium_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/smartcontractkit/chainlink-data-streams/llo"
)

// nolint:unused
const ethMainnetChainSelector uint64 = 5009297550715157269

func newValidPremiumLegacyReport() llo.Report {
Expand Down
6 changes: 3 additions & 3 deletions core/services/llo/onchain_channel_definition_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"maps"
"math/big"
"net/http"
Expand Down Expand Up @@ -151,7 +150,7 @@ func (c *channelDefinitionCache) Start(ctx context.Context) error {
} else if pd != nil {
c.definitions = pd.Definitions
c.initialBlockNum = pd.BlockNum + 1
c.definitionsVersion = uint32(pd.Version)
c.definitionsVersion = pd.Version
} else {
// ensure non-nil map ready for assignment later
c.definitions = make(llotypes.ChannelDefinitions)
Expand Down Expand Up @@ -385,7 +384,7 @@ func (c *channelDefinitionCache) fetchChannelDefinitions(ctx context.Context, ur
// logs with potentially huge messages
body := http.MaxBytesReader(nil, reader, 1024)
defer body.Close()
bodyBytes, err := ioutil.ReadAll(body)
bodyBytes, err := io.ReadAll(body)
if err != nil {
return nil, fmt.Errorf("got error from %s: (status code: %d, error reading response body: %w, response body: %s)", url, statusCode, err, bodyBytes)
}
Expand Down Expand Up @@ -453,6 +452,7 @@ func (c *channelDefinitionCache) persist(ctx context.Context) (memoryVersion, pe

// Checks persisted version and tries to save if necessary on a periodic timer
// Simple backup in case database persistence fails
// nolint:revive
func (c *channelDefinitionCache) failedPersistLoop() {
defer c.wg.Done()

Expand Down
4 changes: 2 additions & 2 deletions core/services/llo/onchain_channel_definition_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func Test_ChannelDefinitionCache(t *testing.T) {
}

t.Run("nil ctx returns error", func(t *testing.T) {
_, err := cdc.fetchChannelDefinitions(nil, "notvalid://foos", [32]byte{})
_, err := cdc.fetchChannelDefinitions(context.Background(), "notvalid://foos", [32]byte{})
assert.EqualError(t, err, "failed to create http.Request; net/http: nil Context")
})

Expand Down Expand Up @@ -363,7 +363,7 @@ func Test_ChannelDefinitionCache(t *testing.T) {

cd, err := cdc.fetchChannelDefinitions(ctx, "http://example.com/definitions.json", common.HexToHash("0x367bbc75f7b6c9fc66a98ea99f837ea7ac4a3c2d6a9ee284de018bd02c41b52d"))
assert.NoError(t, err)
assert.Equal(t, llotypes.ChannelDefinitions(llotypes.ChannelDefinitions{0x2a: llotypes.ChannelDefinition{ReportFormat: 0x1, Streams: []llotypes.Stream{llotypes.Stream{StreamID: 0x34, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x35, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x37, Aggregator: 0x3}}, Opts: llotypes.ChannelOpts{0x7b, 0x22, 0x62, 0x61, 0x73, 0x65, 0x55, 0x53, 0x44, 0x46, 0x65, 0x65, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x22, 0x3a, 0x33, 0x36, 0x30, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x64, 0x49, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30, 0x33, 0x36, 0x62, 0x34, 0x61, 0x61, 0x37, 0x65, 0x35, 0x37, 0x63, 0x61, 0x37, 0x62, 0x36, 0x38, 0x61, 0x65, 0x31, 0x62, 0x66, 0x34, 0x35, 0x36, 0x35, 0x33, 0x66, 0x35, 0x36, 0x62, 0x36, 0x35, 0x36, 0x66, 0x64, 0x33, 0x61, 0x61, 0x33, 0x33, 0x35, 0x65, 0x66, 0x37, 0x66, 0x61, 0x65, 0x36, 0x39, 0x36, 0x62, 0x36, 0x36, 0x33, 0x66, 0x31, 0x62, 0x38, 0x34, 0x37, 0x32, 0x22, 0x2c, 0x22, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d}}}), cd)
assert.Equal(t, llotypes.ChannelDefinitions{0x2a: llotypes.ChannelDefinition{ReportFormat: 0x1, Streams: []llotypes.Stream{llotypes.Stream{StreamID: 0x34, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x35, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x37, Aggregator: 0x3}}, Opts: llotypes.ChannelOpts{0x7b, 0x22, 0x62, 0x61, 0x73, 0x65, 0x55, 0x53, 0x44, 0x46, 0x65, 0x65, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x22, 0x3a, 0x33, 0x36, 0x30, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x64, 0x49, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30, 0x33, 0x36, 0x62, 0x34, 0x61, 0x61, 0x37, 0x65, 0x35, 0x37, 0x63, 0x61, 0x37, 0x62, 0x36, 0x38, 0x61, 0x65, 0x31, 0x62, 0x66, 0x34, 0x35, 0x36, 0x35, 0x33, 0x66, 0x35, 0x36, 0x62, 0x36, 0x35, 0x36, 0x66, 0x64, 0x33, 0x61, 0x61, 0x33, 0x33, 0x35, 0x65, 0x66, 0x37, 0x66, 0x61, 0x65, 0x36, 0x39, 0x36, 0x62, 0x36, 0x36, 0x33, 0x66, 0x31, 0x62, 0x38, 0x34, 0x37, 0x32, 0x22, 0x2c, 0x22, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d}}}, cd)
})
})

Expand Down
3 changes: 0 additions & 3 deletions core/services/ocr2/plugins/ccip/prices/da_price_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ type DAGasPriceEstimator struct {
feeEstimatorConfig ccipdata.FeeEstimatorConfigReader
priceEncodingLength uint
daDeviationPPB int64
daOverheadGas int64
gasPerDAByte int64
daMultiplier int64
}

func NewDAGasPriceEstimator(
Expand Down
3 changes: 2 additions & 1 deletion core/services/ocr2/plugins/llo/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (s *mercuryServer) LatestReport(ctx context.Context, lrr *pb.LatestReportRe
return out, nil
}

// nolint:unused
func startMercuryServer(t *testing.T, srv *mercuryServer, pubKeys []ed25519.PublicKey) (serverURL string) {
// Set up the wsrpc server
lis, err := net.Listen("tcp", "127.0.0.1:0")
Expand Down Expand Up @@ -352,6 +353,7 @@ transmitterID = "%x"
))
}

// nolint:unused
func addOCRJobs(
t *testing.T,
streams []Stream,
Expand All @@ -366,7 +368,6 @@ func addOCRJobs(
pluginConfig,
relayType,
relayConfig string) (streamJobIDs []int32) {

// Add OCR jobs - one per feed on each node
for i, node := range nodes {
for j, strm := range streams {
Expand Down
13 changes: 2 additions & 11 deletions core/services/ocr2/plugins/llo/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
nNodes = 4 // number of nodes (not including bootstrap)
)

// nolint:unused
func setupBlockchain(t *testing.T) (*bind.TransactOpts, *backends.SimulatedBackend, *channel_verifier.ChannelVerifier, common.Address, *channel_config_store.ChannelConfigStore, common.Address) {
steve := testutils.MustNewSimTransactor(t) // config contract deployer and owner
genesisData := core.GenesisAlloc{steve.From: {Balance: assets.Ether(1000).ToInt()}}
Expand Down Expand Up @@ -77,10 +78,6 @@ type Stream struct {
}

var (
btcStream = Stream{
id: 51,
baseBenchmarkPrice: decimal.NewFromFloat32(56_114.41),
}
ethStream = Stream{
id: 52,
baseBenchmarkPrice: decimal.NewFromFloat32(2_976.39),
Expand All @@ -89,10 +86,6 @@ var (
id: 53,
baseBenchmarkPrice: decimal.NewFromFloat32(13.25),
}
dogeStream = Stream{
id: 54,
baseBenchmarkPrice: decimal.NewFromFloat32(0.10960935),
}
quoteStream = Stream{
id: 55,
baseBenchmarkPrice: decimal.NewFromFloat32(1000.1212),
Expand All @@ -113,8 +106,6 @@ func generateConfig(t *testing.T, oracles []confighelper.OracleIdentityExtra) (
reportingPluginConfig, err := rawReportingPluginConfig.Encode()
require.NoError(t, err)

offchainConfig = []byte{}

signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, err = ocr3confighelper.ContractSetConfigArgsForTests(
2*time.Second, // DeltaProgress
20*time.Second, // DeltaResend
Expand All @@ -140,6 +131,7 @@ func generateConfig(t *testing.T, oracles []confighelper.OracleIdentityExtra) (
return
}

// nolint:unused
func setConfig(t *testing.T, steve *bind.TransactOpts, backend *backends.SimulatedBackend, verifierContract *channel_verifier.ChannelVerifier, verifierAddress common.Address, nodes []Node, oracles []confighelper.OracleIdentityExtra) ocr2types.ConfigDigest {
signers, _, _, _, offchainConfigVersion, offchainConfig := generateConfig(t, oracles)

Expand Down Expand Up @@ -351,7 +343,6 @@ channelDefinitions = %q`, serverPubKey, channelDefinitions)

_, err = verifierProxy.Verify(steve, signedReport, []byte{})
require.NoError(t, err)

})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m *MockReadCloser) Read(p []byte) (int, error) {
func (m *MockReadCloser) Close() error {
m.mu.Lock()
defer m.mu.Unlock()
m.reader.Seek(0, io.SeekStart)
_, _ = m.reader.Seek(0, io.SeekStart)
return nil
}

Expand Down Expand Up @@ -369,15 +369,19 @@ func Test_ChannelDefinitionCache_Integration(t *testing.T) {
})
}

// nolint:unused
type mockLogPoller struct {
logpoller.LogPoller
LatestBlockFn func(ctx context.Context) (int64, error)
LogsWithSigsFn func(ctx context.Context, start, end int64, eventSigs []common.Hash, address common.Address) ([]logpoller.Log, error)
}

// nolint:unused
func (p *mockLogPoller) LogsWithSigs(ctx context.Context, start, end int64, eventSigs []common.Hash, address common.Address) ([]logpoller.Log, error) {
return p.LogsWithSigsFn(ctx, start, end, eventSigs, address)
}

// nolint:unused
func (p *mockLogPoller) LatestBlock(ctx context.Context) (logpoller.LogPollerBlock, error) {
block, err := p.LatestBlockFn(ctx)
return logpoller.LogPollerBlock{BlockNumber: block}, err
Expand Down
4 changes: 2 additions & 2 deletions core/services/relay/evm/mercury/verifier/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/test-go/testify/assert"
"github.com/test-go/testify/require"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury"
)
Expand Down
1 change: 0 additions & 1 deletion core/services/versioning/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func TestORM_CheckVersion_CCIP(t *testing.T) {
require.NoError(t, err)
}
})

}
}

Expand Down

0 comments on commit 27ac94d

Please sign in to comment.