Skip to content

Commit

Permalink
fix golint
Browse files Browse the repository at this point in the history
fix lint

gofumpt

continue fix lint

continue fix lint

continue fix lint

continue fix lint

continue fix lint

golint

golint
  • Loading branch information
anhductn2001 committed May 15, 2023
1 parent ed87820 commit f495d1e
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 136 deletions.
6 changes: 2 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
wasmkeeper "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
wasmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -243,7 +242,6 @@ type BanksyApp struct {
ICQKeeper icqkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
WasmClientKeeper wasmkeeper.Keeper
Wasm08Keeper wasm08.Keeper // TODO: use this name ?
// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -381,7 +379,7 @@ func NewBanksyApp(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

app.WasmClientKeeper = wasmkeeper.NewKeeper(appCodec, app.keys[wasmtypes.StoreKey])
app.Wasm08Keeper = wasm08.NewKeeper(appCodec, app.keys[wasmtypes.StoreKey])
// Create Transfer Keepers
app.TransferMiddlewareKeeper = transfermiddlewarekeeper.NewKeeper(
keys[transfermiddlewaretypes.StoreKey],
Expand Down Expand Up @@ -506,7 +504,7 @@ func NewBanksyApp(
transferModule,
icqModule,
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
wasm.NewAppModule(app.WasmClientKeeper),
wasm.NewAppModule(app.Wasm08Keeper),
routerModule,
transfermiddlewareModule,
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
Expand Down
7 changes: 3 additions & 4 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmrand "github.com/cometbft/cometbft/libs/rand"
abcitypes1 "github.com/cometbft/cometbft/proto/tendermint/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -25,8 +24,8 @@ const (

// DefaultConsensusParams defines the default Tendermint consensus params used
// in feeapp testing.
var DefaultConsensusParams = &abcitypes1.ConsensusParams{
Block: &abcitypes1.BlockParams{
var DefaultConsensusParams = &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
MaxBytes: 200000,
MaxGas: 2000000,
},
Expand All @@ -44,7 +43,7 @@ var DefaultConsensusParams = &abcitypes1.ConsensusParams{

type EmptyAppOptions struct{}

func (EmptyAppOptions) Get(o string) interface{} { return nil }
func (EmptyAppOptions) Get(_ string) interface{} { return nil }

func NewContextForApp(app banksy.BanksyApp) sdk.Context {
ctx := app.BaseApp.NewContext(false, tmproto.Header{
Expand Down
23 changes: 12 additions & 11 deletions app/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand All @@ -18,7 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
Expand Down Expand Up @@ -375,7 +376,7 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa
// NextValidatorsHash
tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1))
if !ok {
return nil, sdkerrors.Wrapf(ibctmtypes.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight)
return nil, errors.Wrapf(ibctmtypes.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight)
}
}
// inject trusted fields into last header
Expand Down Expand Up @@ -428,7 +429,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,
AppHash: chain.CurrentHeader.AppHash,
LastResultsHash: tmhash.Sum([]byte("last_results_hash")),
EvidenceHash: tmhash.Sum([]byte("evidence_hash")),
ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck
ProposerAddress: tmValSet.Proposer.Address,
}
hhash := tmHeader.Hash()
blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set")))
Expand Down Expand Up @@ -504,11 +505,11 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope
_, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID))
if !ok {
// create capability using the IBC capability keeper
cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID))
capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID))
require.NoError(chain.t, err)

// claim capability using the scopedKeeper
err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, host.PortPath(portID))
err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, host.PortPath(portID))
require.NoError(chain.t, err)
}

Expand All @@ -520,10 +521,10 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope
// GetPortCapability returns the port capability for the given portID. The capability must
// exist, otherwise testing will fail.
func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability {
cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID))
capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID))
require.True(chain.t, ok)

return cap
return capability
}

// CreateChannelCapability binds and claims a capability for the given portID and channelID
Expand All @@ -534,9 +535,9 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc
// check if the portId is already binded, if not bind it
_, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName)
if !ok {
cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName)
capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName)
require.NoError(chain.t, err)
err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName)
err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, capName)
require.NoError(chain.t, err)
}

Expand All @@ -548,10 +549,10 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc
// GetChannelCapability returns the channel capability for the given portID and channelID.
// The capability must exist, otherwise testing will fail.
func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability {
cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID))
capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID))
require.True(chain.t, ok)

return cap
return capability
}

func (chain *TestChain) TransferMiddleware() routerKeeper.Keeper {
Expand Down
26 changes: 16 additions & 10 deletions app/ibctesting/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,22 @@ func (coord *Coordinator) CommitNBlocks(chain *TestChain, n uint64) {
// ConnOpenInitOnBothChains initializes a connection on both endpoints with the state INIT
// using the OpenInit handshake call.
func (coord *Coordinator) ConnOpenInitOnBothChains(path *Path) error {
if err := path.EndpointA.ConnOpenInit(); err != nil {
err := path.EndpointA.ConnOpenInit()
if err != nil {
return err
}

if err := path.EndpointB.ConnOpenInit(); err != nil {
err = path.EndpointB.ConnOpenInit()
if err != nil {
return err
}

if err := path.EndpointA.UpdateClient(); err != nil {
err = path.EndpointA.UpdateClient()
if err != nil {
return err
}

if err := path.EndpointB.UpdateClient(); err != nil {
err = path.EndpointB.UpdateClient()
if err != nil {
return err
}

Expand All @@ -229,19 +232,22 @@ func (coord *Coordinator) ChanOpenInitOnBothChains(path *Path) error {
// NOTE: only creation of a capability for a transfer or mock port is supported
// Other applications must bind to the port in InitGenesis or modify this code.

if err := path.EndpointA.ChanOpenInit(); err != nil {
err := path.EndpointA.ChanOpenInit()
if err != nil {
return err
}

if err := path.EndpointB.ChanOpenInit(); err != nil {
err = path.EndpointB.ChanOpenInit()
if err != nil {
return err
}

if err := path.EndpointA.UpdateClient(); err != nil {
err = path.EndpointA.UpdateClient()
if err != nil {
return err
}

if err := path.EndpointB.UpdateClient(); err != nil {
err = path.EndpointB.UpdateClient()
if err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions app/ibctesting/event_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"strconv"
"strings"

abci "github.com/cometbft/cometbft/abci/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
abci "github.com/cometbft/cometbft/abci/types"
)

func getSendPackets(evts []abci.Event) []channeltypes.Packet {
Expand Down Expand Up @@ -59,8 +59,8 @@ func parsePacketFromEvent(evt abci.Event) channeltypes.Packet {
// return the value for the attribute with the given name
func getField(evt abci.Event, key string) string {
for _, attr := range evt.Attributes {
if string(attr.Key) == key {
return string(attr.Value)
if attr.Key == key {
return attr.Value
}
}
return ""
Expand Down
7 changes: 4 additions & 3 deletions app/ibctesting/simapp/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package simapp

import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -19,13 +20,13 @@ type HandlerOptions struct {
// NewAnteHandler creates a new ante handler
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, errors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, errors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for AnteHandler")
return nil, errors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for AnteHandler")
}

anteDecorators := []sdk.AnteDecorator{
Expand Down
15 changes: 7 additions & 8 deletions app/ibctesting/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import (
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
Expand Down Expand Up @@ -892,7 +891,7 @@ func (app *SimApp) RegisterNodeService(clientCtx client.Context) {
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
if err != nil {
panic(err)
Expand Down Expand Up @@ -935,14 +934,14 @@ func BlockedAddresses() map[string]bool {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable())
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable())
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable())
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable())
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable())
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable())
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
Expand Down
6 changes: 3 additions & 3 deletions app/ibctesting/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
}

// Setup initializes a new SimApp. A Nop logger is set in SimApp.
func Setup(isCheckTx bool) *SimApp {
func Setup(_ bool) *SimApp {
privVal := mock.NewPV()
pubKey, _ := privVal.GetPubKey()

Expand Down Expand Up @@ -209,8 +209,8 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba
//
// CONTRACT: BeginBlock must be called before this function.
func SignAndDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, _ tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, _, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := simtestutil.GenSignedMockTx(
rand.New(rand.NewSource(time.Now().UnixNano())),
Expand Down
2 changes: 1 addition & 1 deletion app/ibctesting/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ var (
MockFailPacketData = mock.MockFailPacketData
MockRecvCanaryCapabilityName = mock.MockRecvCanaryCapabilityName

prefix = commitmenttypes.NewMerklePrefix([]byte("ibc"))
_ = commitmenttypes.NewMerklePrefix([]byte("ibc"))
)
Loading

0 comments on commit f495d1e

Please sign in to comment.