Skip to content

Commit

Permalink
golangci-lint: fix issues (#14384)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Sep 10, 2024
1 parent 5c37f41 commit 7ec7f55
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ func TestCCIPReader_Nonces(t *testing.T) {
s.sb.Commit()

for sourceChain, addrs := range nonces {

var addrQuery []string
for addr := range addrs {
addrQuery = append(addrQuery, addr.String())
Expand Down
11 changes: 5 additions & 6 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,11 @@ func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.Cap

value := big.NewInt(0)
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 capabilities.CapabilityResponse{}, fmt.Errorf("failed to submit transaction: %w", err)
}
} else {
if !commontypes.ErrSettingTransactionGasLimitNotSupported.Is(err) {
return capabilities.CapabilityResponse{}, fmt.Errorf("failed to submit transaction: %w", err)
}
meta.GasLimit = nil
if err := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil {
return capabilities.CapabilityResponse{}, fmt.Errorf("failed to submit transaction: %w", err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/gas/fee_history_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (f *FeeHistoryEstimator) RefreshDynamicPrice() error {
maxPriorityFeePerGas := assets.NewWeiI(0)
priorityFeeThresholdWei := assets.NewWeiI(0)
if f.config.BlockHistorySize > 0 {
var nonZeroRewardsLen int64 = 0
var nonZeroRewardsLen int64
priorityFee := big.NewInt(0)
priorityFeeThreshold := big.NewInt(0)
for _, reward := range feeHistory.Reward {
Expand All @@ -263,7 +263,7 @@ func (f *FeeHistoryEstimator) RefreshDynamicPrice() error {
// We'll calculate the average of non-zero priority fees
if reward[0].Cmp(big.NewInt(0)) > 0 {
priorityFee = priorityFee.Add(priorityFee, reward[0])
nonZeroRewardsLen += 1
nonZeroRewardsLen++
}
// We take the max value for the bumping threshold
if reward[1].Cmp(big.NewInt(0)) > 0 {
Expand Down
2 changes: 0 additions & 2 deletions core/services/llo/evm/report_codec_premium_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"github.com/smartcontractkit/chainlink-data-streams/llo"
)

const ethMainnetChainSelector uint64 = 5009297550715157269

func newValidPremiumLegacyReport() llo.Report {
return llo.Report{
ConfigDigest: types.ConfigDigest{1, 2, 3},
Expand Down
59 changes: 0 additions & 59 deletions core/services/ocr2/plugins/llo/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,49 +330,6 @@ transmitterID = "%x"
))
}

func addOCRJobs(
t *testing.T,
streams []Stream,
serverPubKey ed25519.PublicKey,
serverURL string,
configuratorAddress common.Address,
bootstrapPeerID string,
bootstrapNodePort int,
nodes []Node,
configStoreAddress common.Address,
clientPubKeys []ed25519.PublicKey,
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 {
bmBridge := createBridge(t, fmt.Sprintf("benchmarkprice-%d-%d", strm.id, j), i, strm.baseBenchmarkPrice, node.App.BridgeORM())
jobID := addSingleDecimalStreamJob(
t,
node,
strm.id,
bmBridge,
)
streamJobIDs = append(streamJobIDs, jobID)
}
addLLOJob(
t,
node,
configuratorAddress,
bootstrapPeerID,
bootstrapNodePort,
clientPubKeys[i],
"feed-1",
pluginConfig,
relayType,
relayConfig,
)
}
return streamJobIDs
}

func createBridge(t *testing.T, name string, i int, p decimal.Decimal, borm bridges.ORM) (bridgeName string) {
ctx := testutils.Context(t)
bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
Expand All @@ -397,22 +354,6 @@ func createBridge(t *testing.T, name string, i int, p decimal.Decimal, borm brid
return bridgeName
}

func createErroringBridge(t *testing.T, name string, i int, borm bridges.ORM) (bridgeName string) {
ctx := testutils.Context(t)
bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusInternalServerError)
}))
t.Cleanup(bridge.Close)
u, _ := url.Parse(bridge.URL)
bridgeName = fmt.Sprintf("bridge-%s-%d", name, i)
require.NoError(t, borm.CreateBridgeType(ctx, &bridges.BridgeType{
Name: bridges.BridgeName(bridgeName),
URL: models.WebURL(*u),
}))

return bridgeName
}

func addOCRJobsEVMPremiumLegacy(
t *testing.T,
streams []Stream,
Expand Down
16 changes: 1 addition & 15 deletions core/services/ocr2/plugins/llo/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,26 @@ type Stream struct {
baseBenchmarkPrice decimal.Decimal
baseBid decimal.Decimal
baseAsk decimal.Decimal
strmType string
}

const (
btcStreamID = 51
ethStreamID = 52
linkStreamID = 53
dogeStreamID = 54
quoteStreamID1 = 55
quoteStreamID2 = 56
)

var (
quoteStreamFeedID1 = common.HexToHash(`0x0003111111111111111111111111111111111111111111111111111111111111`)
quoteStreamFeedID2 = common.HexToHash(`0x0003222222222222222222222222222222222222222222222222222222222222`)

btcStream = Stream{
id: 51,
baseBenchmarkPrice: decimal.NewFromFloat32(56_114.41),
}
ethStream = Stream{
ethStream = Stream{
id: 52,
baseBenchmarkPrice: decimal.NewFromFloat32(2_976.39),
}
linkStream = Stream{
id: 53,
baseBenchmarkPrice: decimal.NewFromFloat32(13.25),
}
dogeStream = Stream{
id: 54,
baseBenchmarkPrice: decimal.NewFromFloat32(0.10960935),
}
quoteStream1 = Stream{
id: 55,
baseBenchmarkPrice: decimal.NewFromFloat32(1000.1212),
Expand All @@ -146,8 +134,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package llo_test

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -13,7 +12,6 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -368,17 +366,3 @@ func Test_ChannelDefinitionCache_Integration(t *testing.T) {
assert.Equal(t, uint32(5), pd.Version)
})
}

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)
}

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)
}
func (p *mockLogPoller) LatestBlock(ctx context.Context) (logpoller.LogPollerBlock, error) {
block, err := p.LatestBlockFn(ctx)
return logpoller.LogPollerBlock{BlockNumber: block}, err
}
2 changes: 1 addition & 1 deletion core/services/relay/evm/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"

chainselectors "github.com/smartcontractkit/chain-selectors"
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/smartcontractkit/chainlink/v2/core/capabilities/targets"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
Expand Down

0 comments on commit 7ec7f55

Please sign in to comment.