Skip to content

Commit

Permalink
address linters
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann committed Apr 11, 2024
1 parent e8268eb commit 2f4b051
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var depositCmd = &cobra.Command{
Long: `Deposit the minimum needed deposit for a given governance proposal.
If no proposal ID is given by the user, the latest proposal is queried and deposited for.`,
Args: cobra.RangeArgs(0, 1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
bin, err := utils.NewEvmosTestingBinary()
if err != nil {
bin.Logger.Error().Msgf("error creating binary: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var upgradeCmd = &cobra.Command{
Long: `Prepare an upgrade of a node by submitting a governance proposal,
voting for it using all keys of in the keyring and having it pass.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
bin, err := utils.NewEvmosTestingBinary()
if err != nil {
bin.Logger.Error().Msgf("error creating binary: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var voteCmd = &cobra.Command{
Long: `Vote for a governance proposal with all keys in the keyring.
If no proposal ID is passed, the latest proposal on chain is queried and used.`,
Args: cobra.RangeArgs(0, 1),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
bin, err := utils.NewEvmosTestingBinary()
if err != nil {
bin.Logger.Error().Msgf("error creating binary: %v", err)
Expand Down
1 change: 0 additions & 1 deletion gov/deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestParseMinDepositFromResponse(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetProposalIDFromSubmitEvents(events []sdk.StringEvent) (int, error) {
}
}

return 0, fmt.Errorf("proposal submission event not found")
return 0, errors.New("proposal submission event not found")
}

// QueryLatestProposalID queries the latest proposal ID.
Expand Down Expand Up @@ -103,7 +103,7 @@ func SubmitUpgradeProposal(bin *utils.Binary, targetVersion string, upgradeHeigh
}

if len(events) == 0 {
return 0, fmt.Errorf("no events found in transaction to submit proposal")
return 0, errors.New("no events found in transaction to submit proposal")
}

return GetProposalIDFromSubmitEvents(events)
Expand Down
2 changes: 1 addition & 1 deletion gov/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func TestGetProposalID(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

propID, err := gov.GetProposalIDFromSubmitEvents(tc.events)
if tc.expError {
require.Error(t, err, "expected error parsing proposal ID")
Expand Down
2 changes: 1 addition & 1 deletion utils/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Binary struct {
func NewBinary(home, appd string, logger zerolog.Logger) (*Binary, error) {
// check if home directory exists
if _, err := os.Stat(home); os.IsNotExist(err) {
return nil, errors.Wrap(err, fmt.Sprintf("home directory does not exist: %s", home))
return nil, errors.Wrap(err, "home directory does not exist: "+home)
}

// check if binary is installed
Expand Down
3 changes: 2 additions & 1 deletion utils/delegations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func TestParseDelegationsFromResponse(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

delegations, err := utils.ParseDelegationsFromResponse(cdc, tc.out)
if tc.expError {
require.Error(t, err, "expected error parsing delegations")
Expand All @@ -49,6 +49,7 @@ func TestParseDelegationsFromResponse(t *testing.T) {
for _, delegation := range delegations {
vals = append(vals, delegation.ValidatorAddress)
}

require.Equal(t, tc.expVals, vals, "expected different validators")
}
})
Expand Down
3 changes: 2 additions & 1 deletion utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"encoding/json"
"errors"
"fmt"

cryptokeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down Expand Up @@ -42,7 +43,7 @@ func FilterAccountsWithDelegations(bin *Binary) ([]Account, error) {
var stakingAccs []Account

if len(bin.Accounts) == 0 {
return nil, fmt.Errorf("no accounts found")
return nil, errors.New("no accounts found")
}

for _, acc := range bin.Accounts {
Expand Down
3 changes: 2 additions & 1 deletion utils/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func TestParseKeysFromOut(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

accounts, err := utils.ParseAccountsFromOut(tc.out)
if tc.expError {
require.Error(t, err, "expected error parsing accounts")
Expand All @@ -46,6 +46,7 @@ func TestParseKeysFromOut(t *testing.T) {
for _, account := range accounts {
keys = append(keys, account.Name)
}

require.Equal(t, tc.expKeys, keys, "expected different keys")
}
})
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func GetTxEvents(bin *Binary, out string) ([]sdk.StringEvent, error) {
nAttempts = 10
)

for i := 0; i < nAttempts; i++ {
for range nAttempts {
txOut, err = ExecuteBinaryCmd(bin, BinaryCmdArgs{
Subcommand: []string{"q", "tx", txHash, "--output=json"},
Quiet: true,
Expand Down
4 changes: 2 additions & 2 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func TestGetTxHashFromResponse(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

hash, err := utils.GetTxHashFromTxResponse(cdc, tc.out)
if tc.expError {
require.Error(t, err, "expected error getting tx hash")
Expand Down Expand Up @@ -92,9 +92,9 @@ func TestGetEventsFromTxResponse(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

events, err := utils.GetEventsFromTxResponse(cdc, tc.out)
if tc.expError {
require.Error(t, err, "expected error getting tx events")
Expand Down

0 comments on commit 2f4b051

Please sign in to comment.