Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint tests, too #1960

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
tests: false
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

Expand All @@ -8,6 +8,7 @@ linters:
enable:
- depguard
- dogsled
- errcheck
- exportloopref
- goconst
- gocritic
Expand Down
1 change: 0 additions & 1 deletion app/upgrades/v8/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ func TestFixBankMetadata(t *testing.T) {
malformedDenom := "uatomu"
_, foundMalformed := app.AppKeepers.BankKeeper.GetDenomMetaData(ctx, malformedDenom)
require.False(t, foundMalformed)

}
16 changes: 8 additions & 8 deletions tests/e2e/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (

var (
encodingConfig params.EncodingConfig
cdc codec.Codec //nolint:unused // this is called during e2e tests
txConfig client.TxConfig //nolint:unused // this is called during e2e tests
cdc codec.Codec
txConfig client.TxConfig
)

func init() {
Expand All @@ -36,17 +36,17 @@ func init() {
txConfig = encodingConfig.TxConfig
}

type chain struct { //nolint:unused // this is called during e2e tests
type chain struct {
dataDir string
id string
validators []*validator
accounts []*account
accounts []*account //nolint:unused
// initial accounts in genesis
genesisAccounts []*account
genesisVestingAccounts map[string]sdk.AccAddress
}

func newChain() (*chain, error) { //nolint:unused // this is called during e2e tests
func newChain() (*chain, error) {
tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-")
if err != nil {
return nil, err
Expand All @@ -58,11 +58,11 @@ func newChain() (*chain, error) { //nolint:unused // this is called during e2e t
}, nil
}

func (c *chain) configDir() string { //nolint:unused // this is called during e2e tests
func (c *chain) configDir() string {
return fmt.Sprintf("%s/%s", c.dataDir, c.id)
}

func (c *chain) createAndInitValidators(count int) error { //nolint:unused // this is called during e2e tests
func (c *chain) createAndInitValidators(count int) error {
for i := 0; i < count; i++ {
node := c.createValidator(i)

Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []stri
return nil
}

func (c *chain) createValidator(index int) *validator { //nolint:unused // this is called during e2e tests
func (c *chain) createValidator(index int) *validator {
return &validator{
chain: c,
index: index,
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/e2e_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func (s *IntegrationTestSuite) testDistribution() {

chainEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))

validatorB := s.chainA.validators[1]
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:unused
package e2e

import (
Expand Down Expand Up @@ -290,7 +291,7 @@ type txBankSend struct {

func (s *IntegrationTestSuite) execBankSendBatch(
c *chain,
valIdx int,
valIdx int, //nolint:unparam
txs ...txBankSend,
) int {
sucessBankSendCount := 0
Expand All @@ -309,7 +310,7 @@ func (s *IntegrationTestSuite) execBankSendBatch(
return sucessBankSendCount
}

func (s *IntegrationTestSuite) execWithdrawAllRewards(c *chain, valIdx int, payee, fees string, expectErr bool) {
func (s *IntegrationTestSuite) execWithdrawAllRewards(c *chain, valIdx int, payee, fees string, expectErr bool) { //nolint:unparam
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

Expand Down Expand Up @@ -423,7 +424,7 @@ func (s *IntegrationTestSuite) executeKeysList(c *chain, valIdx int, home string
})
}

func (s *IntegrationTestSuite) executeDelegate(c *chain, valIdx int, amount, valOperAddress, delegatorAddr, home, delegateFees string) {
func (s *IntegrationTestSuite) executeDelegate(c *chain, valIdx int, amount, valOperAddress, delegatorAddr, home, delegateFees string) { //nolint:unparam
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_globalfee_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
)

func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, proposalCounter int, submitter string, fees string) {
func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, proposalCounter int, submitter string, fees string) { //nolint:unparam
s.writeGovParamChangeProposalGlobalFees(s.chainA, newGlobalfee)
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
submitGovFlags := []string{"param-change", configFile(proposalGlobalFeeFilename)}
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package e2e

import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"strconv"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"

distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -123,13 +124,13 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {
)
}

func (s *IntegrationTestSuite) runGovProcess(chainAAPIEndpoint, sender string, proposalId int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string) {
func (s *IntegrationTestSuite) runGovProcess(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string) {
s.T().Logf("Submitting Gov Proposal: %s", proposalType)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, "submit-proposal", submitFlags, govtypes.StatusDepositPeriod)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, "submit-proposal", submitFlags, govtypes.StatusDepositPeriod)
s.T().Logf("Depositing Gov Proposal: %s", proposalType)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, "deposit", depositFlags, govtypes.StatusVotingPeriod)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, "deposit", depositFlags, govtypes.StatusVotingPeriod)
s.T().Logf("Voting Gov Proposal: %s", proposalType)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalId, voteCommand, voteFlags, govtypes.StatusPassed)
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, voteCommand, voteFlags, govtypes.StatusPassed)
}

func (s *IntegrationTestSuite) verifyChainHaltedAtUpgradeHeight(c *chain, valIdx, upgradeHeight int) {
Expand Down Expand Up @@ -173,13 +174,13 @@ func (s *IntegrationTestSuite) verifyChainPassesUpgradeHeight(c *chain, valIdx,
)
}

func (s *IntegrationTestSuite) submitGovCommand(chainAAPIEndpoint, sender string, proposalId int, govCommand string, proposalFlags []string, expectedSuccessStatus govtypes.ProposalStatus) {
func (s *IntegrationTestSuite) submitGovCommand(chainAAPIEndpoint, sender string, proposalID int, govCommand string, proposalFlags []string, expectedSuccessStatus govtypes.ProposalStatus) {
s.Run(fmt.Sprintf("Running tx gov %s", govCommand), func() {
s.runGovExec(s.chainA, 0, sender, govCommand, proposalFlags, standardFees.String())

s.Require().Eventually(
func() bool {
proposal, err := queryGovProposal(chainAAPIEndpoint, proposalId)
proposal, err := queryGovProposal(chainAAPIEndpoint, proposalID)
s.Require().NoError(err)

return proposal.GetProposal().Status == expectedSuccessStatus
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() {
endpoint := fmt.Sprintf("http://%s/state", s.hermesResource.GetHostPort("3031/tcp"))
s.Require().Eventually(
func() bool {
resp, err := http.Get(endpoint)
resp, err := http.Get(endpoint) //nolint:gosec // this is a test
if err != nil {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (s *IntegrationTestSuite) runValidators(c *chain, portOffset int) {
Repository: "cosmos/gaiad-e2e",
}

s.Require().NoError(exec.Command("chmod", "-R", "0777", val.configDir()).Run())
s.Require().NoError(exec.Command("chmod", "-R", "0777", val.configDir()).Run()) //nolint:gosec // this is a test

// expose the first validator for debugging and communication
if val.index == 0 {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_vesting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (s *IntegrationTestSuite) testContinuousVestingAccount(api string) {
})
}

func (s *IntegrationTestSuite) testPeriodicVestingAccount(api string) {
func (s *IntegrationTestSuite) testPeriodicVestingAccount(api string) { //nolint:unused
s.Run("test periodic vesting genesis account", func() {
var (
valIdx = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
)

func getGenDoc(path string) (*tmtypes.GenesisDoc, error) { //nolint:unused // this is called during e2e tests
func getGenDoc(path string) (*tmtypes.GenesisDoc, error) {
serverCtx := server.NewDefaultContext()
config := serverCtx.Config
config.SetRoot(path)
Expand All @@ -43,7 +43,7 @@ func getGenDoc(path string) (*tmtypes.GenesisDoc, error) { //nolint:unused // th
return doc, nil
}

func modifyGenesis(path, moniker, amountStr string, addrAll []sdk.AccAddress, globfees string, denom string) error { //nolint:unused // this is called during e2e tests
func modifyGenesis(path, moniker, amountStr string, addrAll []sdk.AccAddress, globfees string, denom string) error {
serverCtx := server.NewDefaultContext()
config := serverCtx.Config
config.SetRoot(path)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
)

func httpGet(endpoint string) ([]byte, error) { //nolint:unused // this is called during e2e tests
func httpGet(endpoint string) ([]byte, error) {
resp, err := http.Get(endpoint) //nolint:gosec // this is only used during tests
if err != nil {
return nil, fmt.Errorf("failed to execute HTTP request: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// copyFile copy file from src to dst
func copyFile(src, dst string) (int64, error) { //nolint:unused // this is called during e2e tests
func copyFile(src, dst string) (int64, error) { //nolint:unparam
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
Expand All @@ -34,7 +34,7 @@ func copyFile(src, dst string) (int64, error) { //nolint:unused // this is calle
}

// writeFile write a byte slice into a file path
func writeFile(path string, body []byte) error { //nolint:unused // this is called during e2e tests
func writeFile(path string, body []byte) error {
_, err := os.Create(path)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// createMnemonic creates a random string mnemonic
func createMnemonic() (string, error) { //nolint:unused // this is called during e2e tests
func createMnemonic() (string, error) {
entropySeed, err := bip39.NewEntropy(256)
if err != nil {
return "", err
Expand Down
26 changes: 13 additions & 13 deletions tests/e2e/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
globalfee "github.com/cosmos/gaia/v8/x/globalfee/types"
)

func queryGaiaTx(endpoint, txHash string) error { //nolint:unused // this is called during e2e tests
func queryGaiaTx(endpoint, txHash string) error {
resp, err := http.Get(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", endpoint, txHash))
if err != nil {
return fmt.Errorf("failed to execute HTTP request: %w", err)
Expand All @@ -46,7 +46,7 @@ func queryGaiaTx(endpoint, txHash string) error { //nolint:unused // this is cal
}

// if coin is zero, return empty coin.
func getSpecificBalance(endpoint, addr, denom string) (amt sdk.Coin, err error) { //nolint:unused // this is called during e2e tests
func getSpecificBalance(endpoint, addr, denom string) (amt sdk.Coin, err error) {
balances, err := queryGaiaAllBalances(endpoint, addr)
if err != nil {
return amt, err
Expand All @@ -60,7 +60,7 @@ func getSpecificBalance(endpoint, addr, denom string) (amt sdk.Coin, err error)
return amt, nil
}

func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { //nolint:unused // this is called during e2e tests
func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) {
body, err := httpGet(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", endpoint, addr))
if err != nil {
return nil, fmt.Errorf("failed to execute HTTP request: %w", err)
Expand All @@ -74,7 +74,7 @@ func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { //nolint:u
return balancesResp.Balances, nil
}

func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { //nolint:unused // this is called during e2e tests
func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) {
body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/minimum_gas_prices", endpoint))
if err != nil {
return nil, fmt.Errorf("failed to execute HTTP request: %w", err)
Expand All @@ -88,7 +88,7 @@ func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { //nolint:u
return fees.MinimumGasPrices, nil
}

func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { //nolint:unused // this is called during e2e tests
func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) {
var res stakingtypes.QueryDelegationResponse

body, err := httpGet(fmt.Sprintf("%s/cosmos/staking/v1beta1/validators/%s/delegations/%s", endpoint, validatorAddr, delegatorAddr))
Expand All @@ -102,7 +102,7 @@ func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string
return res, nil
}

func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (disttypes.QueryDelegatorWithdrawAddressResponse, error) { //nolint:unused // this is called during e2e tests
func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (disttypes.QueryDelegatorWithdrawAddressResponse, error) {
var res disttypes.QueryDelegatorWithdrawAddressResponse

body, err := httpGet(fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/withdraw_address", endpoint, delegatorAddr))
Expand All @@ -116,7 +116,7 @@ func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (dis
return res, nil
}

func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalResponse, error) { //nolint:unused // this is called during e2e tests
func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalResponse, error) {
var govProposalResp govtypes.QueryProposalResponse

path := fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals/%d", endpoint, proposalID)
Expand All @@ -132,7 +132,7 @@ func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalRe
return govProposalResp, nil
}

func queryAccount(endpoint, address string) (acc authtypes.AccountI, err error) { //nolint:unused // this is called during e2e tests
func queryAccount(endpoint, address string) (acc authtypes.AccountI, err error) {
var res authtypes.QueryAccountResponse
resp, err := http.Get(fmt.Sprintf("%s/cosmos/auth/v1beta1/accounts/%s", endpoint, address))
if err != nil {
Expand All @@ -150,7 +150,7 @@ func queryAccount(endpoint, address string) (acc authtypes.AccountI, err error)
return acc, cdc.UnpackAny(res.Account, &acc)
}

func queryDelayedVestingAccount(endpoint, address string) (authvesting.DelayedVestingAccount, error) { //nolint:unused // this is called during e2e tests
func queryDelayedVestingAccount(endpoint, address string) (authvesting.DelayedVestingAccount, error) {
baseAcc, err := queryAccount(endpoint, address)
if err != nil {
return authvesting.DelayedVestingAccount{}, err
Expand All @@ -163,7 +163,7 @@ func queryDelayedVestingAccount(endpoint, address string) (authvesting.DelayedVe
return *acc, nil
}

func queryContinuousVestingAccount(endpoint, address string) (authvesting.ContinuousVestingAccount, error) { //nolint:unused // this is called during e2e tests
func queryContinuousVestingAccount(endpoint, address string) (authvesting.ContinuousVestingAccount, error) {
baseAcc, err := queryAccount(endpoint, address)
if err != nil {
return authvesting.ContinuousVestingAccount{}, err
Expand Down Expand Up @@ -202,7 +202,7 @@ func queryPeriodicVestingAccount(endpoint, address string) (authvesting.Periodic
return *acc, nil
}

func queryValidator(endpoint, address string) (stakingtypes.Validator, error) { //nolint:unused // this is called during e2e tests
func queryValidator(endpoint, address string) (stakingtypes.Validator, error) {
var res stakingtypes.QueryValidatorResponse

body, err := httpGet(fmt.Sprintf("%s/cosmos/staking/v1beta1/validators/%s", endpoint, address))
Expand All @@ -216,7 +216,7 @@ func queryValidator(endpoint, address string) (stakingtypes.Validator, error) {
return res.Validator, nil
}

func queryValidators(endpoint string) (stakingtypes.Validators, error) { //nolint:unused // this is called during e2e tests
func queryValidators(endpoint string) (stakingtypes.Validators, error) {
var res stakingtypes.QueryValidatorsResponse
body, err := httpGet(fmt.Sprintf("%s/cosmos/staking/v1beta1/validators", endpoint))
if err != nil {
Expand All @@ -242,7 +242,7 @@ func queryEvidence(endpoint, hash string) (evidencetypes.QueryEvidenceResponse,
return res, nil
}

func queryAllEvidence(endpoint string) (evidencetypes.QueryAllEvidenceResponse, error) { //nolint:unused // this is called during e2e tests
func queryAllEvidence(endpoint string) (evidencetypes.QueryAllEvidenceResponse, error) {
var res evidencetypes.QueryAllEvidenceResponse
body, err := httpGet(fmt.Sprintf("%s/cosmos/evidence/v1beta1/evidence", endpoint))
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)

//nolint:unused // this is called during e2e tests
func decodeTx(txBytes []byte) (*sdktx.Tx, error) {
var raw sdktx.TxRaw

Expand Down Expand Up @@ -45,7 +44,6 @@ func decodeTx(txBytes []byte) (*sdktx.Tx, error) {
}, nil
}

//nolint:unused // this is called during e2e tests
func concatFlags(originalCollection []string, commandFlags []string, generalFlags []string) []string {
originalCollection = append(originalCollection, commandFlags...)
originalCollection = append(originalCollection, generalFlags...)
Expand Down
Loading