Skip to content

Commit

Permalink
Go Generate & lint fixing (smartcontractkit#7116)
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR authored Aug 1, 2022
1 parent d728376 commit 1edc37b
Show file tree
Hide file tree
Showing 50 changed files with 149 additions and 134 deletions.
3 changes: 2 additions & 1 deletion core/bridges/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"database/sql"

"github.com/pkg/errors"
"github.com/smartcontractkit/sqlx"

"github.com/smartcontractkit/chainlink/core/auth"
"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/services/pg"
"github.com/smartcontractkit/sqlx"
)

//go:generate mockery --name ORM --output ./mocks --case=underscore
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/chain_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func (cll *chainSet) Index(offset, limit int) ([]types.DBChain, int, error) {

func (cll *chainSet) Default() (Chain, error) {
cll.chainsMu.RLock()
len := len(cll.chains)
length := len(cll.chains)
cll.chainsMu.RUnlock()
if len == 0 {
if length == 0 {
return nil, errors.Wrap(ErrNoChains, "cannot get default EVM chain; no EVM chains are available")
}
if cll.defaultID == nil {
Expand Down
1 change: 0 additions & 1 deletion core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func (c *chainScopedConfig) Configure(config evmtypes.ChainCfg) {
c.persistMu.Lock()
defer c.persistMu.Unlock()
c.persistedCfg = config
return
}

func (c *chainScopedConfig) PersistedConfig() evmtypes.ChainCfg {
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/forwarders/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink/core/utils"
)

Expand Down
44 changes: 22 additions & 22 deletions core/chains/evm/log/mocks/orm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/chains/evm/log/registrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *registrations) handlersWithGreaterConfs(confs uint32) (handlersWithGrea
// maps modified are only used for checks
func (r *registrations) checkAddSubscriber(sub *subscriber) error {
if sub.opts.MinIncomingConfirmations <= 0 {
return errors.Errorf("LogBroadcaster requires that MinIncomingConfirmations must be at least 1 (got %v). Logs must have been confirmed in at least 1 block, it does not support reading logs from the mempool before they have been mined.", sub.opts.MinIncomingConfirmations)
return errors.Errorf("LogBroadcaster requires that MinIncomingConfirmations must be at least 1 (got %v). Logs must have been confirmed in at least 1 block, it does not support reading logs from the mempool before they have been mined", sub.opts.MinIncomingConfirmations)
}

jobID := sub.listener.JobID()
Expand Down
10 changes: 5 additions & 5 deletions core/chains/evm/txmgr/nonce_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"sync"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/smartcontractkit/sqlx"
"go.uber.org/multierr"

evmclient "github.com/smartcontractkit/chainlink/core/chains/evm/client"
"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/core/services/pg"
"github.com/smartcontractkit/sqlx"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"go.uber.org/multierr"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/txmgr/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/smartcontractkit/sqlx"

"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/services/pg"
"github.com/smartcontractkit/sqlx"
)

//go:generate mockery --name ORM --output ./mocks/ --case=underscore
Expand Down
5 changes: 3 additions & 2 deletions core/chains/evm/txmgr/reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"time"

"github.com/pkg/errors"
"github.com/smartcontractkit/sqlx"
"go.uber.org/atomic"

"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/services/pg"
"github.com/smartcontractkit/chainlink/core/utils"
"github.com/smartcontractkit/sqlx"
"go.uber.org/atomic"
)

//go:generate mockery --name ReaperConfig --output ./mocks/ --case=underscore
Expand Down
6 changes: 3 additions & 3 deletions core/chains/evm/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ func (b *Txm) Start(ctx context.Context) (merr error) {

eb := NewEthBroadcaster(b.db, b.ethClient, b.config, b.keyStore, b.eventBroadcaster, keyStates, b.gasEstimator, b.resumeCallback, b.logger, b.checkerFactory)
ec := NewEthConfirmer(b.db, b.ethClient, b.config, b.keyStore, keyStates, b.gasEstimator, b.resumeCallback, b.logger)
if err := eb.Start(ctx); err != nil {
if err = eb.Start(ctx); err != nil {
return errors.Wrap(err, "Txm: EthBroadcaster failed to start")
}
if err := ec.Start(); err != nil {
if err = ec.Start(); err != nil {
return errors.Wrap(err, "Txm: EthConfirmer failed to start")
}

if err := b.gasEstimator.Start(ctx); err != nil {
if err = b.gasEstimator.Start(ctx); err != nil {
return errors.Wrap(err, "Txm: Estimator failed to start")
}

Expand Down
5 changes: 0 additions & 5 deletions core/chains/solana/soltxm/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (c *pendingTxContext) Remove(sig solana.Signature) {
c.cancelBy[sig]() // cancel context
delete(c.cancelBy, sig)
delete(c.timestamp, sig)
return
}

func (c *pendingTxContext) ListAll() []solana.Signature {
Expand All @@ -99,12 +98,10 @@ func (c *pendingTxContext) Expired(sig solana.Signature, lifespan time.Duration)

func (c *pendingTxContext) OnSuccess(sig solana.Signature) {
c.Remove(sig)
return
}

func (c *pendingTxContext) OnError(sig solana.Signature, _ int) {
c.Remove(sig)
return
}

var _ PendingTxContext = &pendingTxContextWithProm{}
Expand Down Expand Up @@ -135,7 +132,6 @@ func (c *pendingTxContextWithProm) Add(sig solana.Signature, cancel context.Canc

func (c *pendingTxContextWithProm) Remove(sig solana.Signature) {
c.pendingTx.Remove(sig)
return
}

func (c *pendingTxContextWithProm) ListAll() []solana.Signature {
Expand All @@ -152,7 +148,6 @@ func (c *pendingTxContextWithProm) Expired(sig solana.Signature, lifespan time.D
func (c *pendingTxContextWithProm) OnSuccess(sig solana.Signature) {
promSolTxmSuccessTxs.WithLabelValues(c.chainID).Add(1)
c.pendingTx.OnSuccess(sig)
return
}

func (c *pendingTxContextWithProm) OnError(sig solana.Signature, errType int) {
Expand Down
21 changes: 9 additions & 12 deletions core/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/urfave/cli"

"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/sessions"
"github.com/smartcontractkit/chainlink/core/static"
)

Expand Down Expand Up @@ -70,19 +69,17 @@ func NewApp(client *Client) *cli.App {
}
clientOpts := ClientOpts{RemoteNodeURL: *remoteNodeURL, InsecureSkipVerify: insecureSkipVerify}
cookieAuth := NewSessionCookieAuthenticator(clientOpts, DiskCookieStore{Config: client.Config}, client.Logger)
sr := sessions.SessionRequest{}
sessionRequestBuilder := NewFileSessionRequestBuilder(client.Logger)
{
credentialsFile := c.String("admin-credentials-file")
if envCredentialsFile := os.Getenv("ADMIN_CREDENTIALS_FILE"); envCredentialsFile != "" {
credentialsFile = envCredentialsFile
}
var err error
sr, err = sessionRequestBuilder.Build(credentialsFile)
if err != nil && !errors.Is(errors.Cause(err), ErrNoCredentialFile) && !os.IsNotExist(err) {
return errors.Wrapf(err, "failed to load API credentials from file %s", credentialsFile)
}

credentialsFile := c.String("admin-credentials-file")
if envCredentialsFile := os.Getenv("ADMIN_CREDENTIALS_FILE"); envCredentialsFile != "" {
credentialsFile = envCredentialsFile
}
sr, err := sessionRequestBuilder.Build(credentialsFile)
if err != nil && !errors.Is(errors.Cause(err), ErrNoCredentialFile) && !os.IsNotExist(err) {
return errors.Wrapf(err, "failed to load API credentials from file %s", credentialsFile)
}

client.HTTP = NewAuthenticatedHTTPClient(client.Logger, clientOpts, cookieAuth, sr)
client.CookieAuthenticator = cookieAuth
client.FileSessionRequestBuilder = sessionRequestBuilder
Expand Down
18 changes: 9 additions & 9 deletions core/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (n ChainlinkAppFactory) NewApplication(cfg config.GeneralConfig, db *sqlx.D

if cfg.TerraEnabled() {
terraLggr := appLggr.Named("Terra")
if err := terra.SetupNodes(db, cfg, terraLggr); err != nil {
if err = terra.SetupNodes(db, cfg, terraLggr); err != nil {
return nil, errors.Wrap(err, "failed to setup Terra nodes")
}
chains.Terra, err = terra.NewChainSet(terra.ChainSetOpts{
Expand All @@ -184,7 +184,7 @@ func (n ChainlinkAppFactory) NewApplication(cfg config.GeneralConfig, db *sqlx.D

if cfg.SolanaEnabled() {
solLggr := appLggr.Named("Solana")
if err := solana.SetupNodes(db, cfg, solLggr); err != nil {
if err = solana.SetupNodes(db, cfg, solLggr); err != nil {
return nil, errors.Wrap(err, "failed to setup Solana nodes")
}
chains.Solana, err = solana.NewChainSet(solana.ChainSetOpts{
Expand All @@ -202,7 +202,7 @@ func (n ChainlinkAppFactory) NewApplication(cfg config.GeneralConfig, db *sqlx.D

if cfg.StarkNetEnabled() {
starkLggr := appLggr.Named("StarkNet")
if err := starknet.SetupNodes(db, cfg, starkLggr); err != nil {
if err = starknet.SetupNodes(db, cfg, starkLggr); err != nil {
return nil, errors.Wrap(err, "failed to setup StarkNet nodes")
}
chains.StarkNet, err = starknet.NewChainSet(starknet.ChainSetOpts{
Expand Down Expand Up @@ -695,9 +695,9 @@ func (t *promptingAPIInitializer) Initialize(orm sessions.ORM) (sessions.User, e
email := t.prompter.Prompt("Enter API Email: ")
pwd := t.prompter.PasswordPrompt("Enter API Password: ")
// On a fresh DB, create an admin user
user, err := sessions.NewUser(email, pwd, sessions.UserRoleAdmin)
if err != nil {
t.lggr.Errorf("Error creating API user: ", err, "err")
user, err2 := sessions.NewUser(email, pwd, sessions.UserRoleAdmin)
if err2 != nil {
t.lggr.Errorw("Error creating API user", "err", err2)
continue
}
if err = orm.CreateUser(&user); err != nil {
Expand Down Expand Up @@ -747,9 +747,9 @@ func (f fileAPIInitializer) Initialize(orm sessions.ORM) (sessions.User, error)

// If there are no users in the database, create initial admin user from session request from file creds
if len(dbUsers) == 0 {
user, err := sessions.NewUser(request.Email, request.Password, sessions.UserRoleAdmin)
if err != nil {
return user, errors.Wrap(err, "failed to instantiate new user")
user, err2 := sessions.NewUser(request.Email, request.Password, sessions.UserRoleAdmin)
if err2 != nil {
return user, errors.Wrap(err2, "failed to instantiate new user")
}
return user, orm.CreateUser(&user)
}
Expand Down
2 changes: 1 addition & 1 deletion core/cmd/ocr2vrf_configure_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (cli *Client) ConfigureOCR2VRFNode(c *clipkg.Context) (*SetupOCR2VRFNodePay
ethKeys, _ := app.GetKeyStore().Eth().GetAll()
transmitterID := ethKeys[0].Address.String()
peerID := p2p[0].PeerID().Raw()
if c.Bool("isBootstrapper") == false {
if !c.Bool("isBootstrapper") {
peerID = c.String("bootstrapperPeerID")
}

Expand Down
2 changes: 1 addition & 1 deletion core/cmd/remote_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (cli *Client) Profile(c *clipkg.Context) error {
seconds := c.Uint("seconds")
baseDir := c.String("output_dir")
if seconds >= uint(cli.Config.HTTPServerWriteTimeout().Seconds()) {
return cli.errorOut(errors.New("profile duration should be less than server write timeout."))
return cli.errorOut(errors.New("profile duration should be less than server write timeout"))
}

genDir := filepath.Join(baseDir, fmt.Sprintf("debuginfo-%s", time.Now().Format(time.RFC3339)))
Expand Down
4 changes: 2 additions & 2 deletions core/cmd/remote_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ func TestClient_Profile_InvalidSecondsParam(t *testing.T) {

err = client.Profile(cli.NewContext(nil, set, nil))
require.Error(t, err)
assert.Contains(t, err.Error(), "profile duration should be less than server write timeout.")

assert.Contains(t, err.Error(), "profile duration should be less than server write timeout")
}

func TestClient_Profile(t *testing.T) {
Expand All @@ -476,6 +475,7 @@ func TestClient_Profile(t *testing.T) {
err = client.Profile(cli.NewContext(nil, set, nil))
require.NoError(t, err)
}

func TestClient_SetDefaultGasPrice(t *testing.T) {
t.Parallel()

Expand Down
Loading

0 comments on commit 1edc37b

Please sign in to comment.