diff --git a/CHANGELOG.md b/CHANGELOG.md index d81c95d029a..ebf85888868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking ### Improvements - +* (cleanup) [\#1335](https://github.com/cosmos/ibc-go/pull/1335/) `gofumpt -w -l .` to standardize the code layout more strictly than `go fmt ./...` * (transfer) [\#1342](https://github.com/cosmos/ibc-go/pull/1342) `DenomTrace` grpc now takes in either an `ibc denom` or a `hash` instead of only accepting a `hash`. * (modules/core/keeper) [\#1284](https://github.com/cosmos/ibc-go/pull/1284) Add sanity check for the keepers passed into `ibckeeper.NewKeeper`. `ibckeeper.NewKeeper` now panics if any of the keepers passed in is empty. * (middleware) [\#1022](https://github.com/cosmos/ibc-go/pull/1022) Add `GetAppVersion` to the ICS4Wrapper interface. This function should be used by IBC applications to obtain their own version since the version set in the channel structure may be wrapped many times by middleware. diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index dd7849efca9..adaffcb83f9 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -120,9 +120,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { } func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { - var ( - channel *channeltypes.Channel - ) + var channel *channeltypes.Channel testCases := []struct { name string @@ -273,9 +271,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { } func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string @@ -336,10 +332,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { } else { suite.Require().Error(err) } - }) } - } // Test initiating a ChanOpenConfirm using the controller chain instead of the host chain @@ -389,7 +383,6 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ) suite.Require().Error(err) - } // OnChanCloseInit on controller (chainA) @@ -414,16 +407,13 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { } func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -454,13 +444,11 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { } else { suite.Require().Error(err) } - }) } } func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { - testCases := []struct { name string malleate func() @@ -509,9 +497,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { } func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { msg string @@ -580,9 +566,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { } func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { msg string diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index 03eeef69f1f..282b6e2e77a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -10,7 +10,7 @@ import ( ) // RegisterInterchainAccount is the entry point to registering an interchain account. -// It generates a new port identifier using the owner address. It will bind to the +// It generates a new port identifier using the owner address. It will bind to the // port identifier and call 04-channel 'ChanOpenInit'. An error is returned if the port // identifier is already in use. Gaining access to interchain accounts whose channels // have closed cannot be done with this function. A regular MsgChanOpenInit must be used. diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go index 7a41608d38f..1c34e2efbf1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -41,7 +41,6 @@ func (suite *KeeperTestSuite) TestInitGenesis() { expParams := types.NewParams(false) params := suite.chainA.GetSimApp().ICAControllerKeeper.GetParams(suite.chainA.GetContext()) suite.Require().Equal(expParams, params) - } func (suite *KeeperTestSuite) TestExportGenesis() { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index 26a90878abf..6b84fb554ca 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -119,6 +119,5 @@ func (k Keeper) OnChanCloseConfirm( portID, channelID string, ) error { - return nil } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index 61c8a092a81..f2104e2032d 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -22,7 +22,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { malleate func() expPass bool }{ - { "success", func() { @@ -242,7 +241,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { } else { suite.Require().Error(err) } - }) } } @@ -402,16 +400,13 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() { } func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -441,7 +436,6 @@ func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { } else { suite.Require().Error(err) } - }) } } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go index 86099b954bd..5973d2abcd3 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper.go @@ -39,7 +39,6 @@ func NewKeeper( ics4Wrapper icatypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { - // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index bb4d17b8232..2a1f9894087 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -183,9 +183,7 @@ func (suite *KeeperTestSuite) TestSendTx() { } func (suite *KeeperTestSuite) TestOnTimeoutPacket() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { msg string diff --git a/modules/apps/27-interchain-accounts/controller/types/params.go b/modules/apps/27-interchain-accounts/controller/types/params.go index eb9c413bec0..d7b9cc83874 100644 --- a/modules/apps/27-interchain-accounts/controller/types/params.go +++ b/modules/apps/27-interchain-accounts/controller/types/params.go @@ -11,10 +11,8 @@ const ( DefaultControllerEnabled = true ) -var ( - // KeyControllerEnabled is the store key for ControllerEnabled Params - KeyControllerEnabled = []byte("ControllerEnabled") -) +// KeyControllerEnabled is the store key for ControllerEnabled Params +var KeyControllerEnabled = []byte("ControllerEnabled") // ParamKeyTable type declaration for parameters func ParamKeyTable() paramtypes.KeyTable { diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index 3fa45384104..db220f86026 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -147,7 +147,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -165,7 +164,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { ) (string, error) { return "", fmt.Errorf("mock ica auth fails") } - }, true, }, { @@ -222,10 +220,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { suite.Require().Error(err) suite.Require().Equal("", version) } - }) } - } // Test initiating a ChanOpenAck using the host chain instead of the controller chain @@ -268,7 +264,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -285,7 +280,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { ) error { return fmt.Errorf("mock ica auth fails") } - }, true, }, } @@ -322,10 +316,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { } else { suite.Require().Error(err) } - }) } - } // OnChanCloseInit on host (chainB) @@ -350,16 +342,13 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { } func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -390,15 +379,12 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { } else { suite.Require().Error(err) } - }) } } func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { - var ( - packetData []byte - ) + var packetData []byte testCases := []struct { name string malleate func() @@ -502,14 +488,11 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { } else { suite.Require().False(ack.Success()) } - }) } - } func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { - testCases := []struct { name string malleate func() @@ -563,7 +546,6 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { } func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { - testCases := []struct { name string malleate func() diff --git a/modules/apps/27-interchain-accounts/host/keeper/account_test.go b/modules/apps/27-interchain-accounts/host/keeper/account_test.go index df1966277e4..5e64189058e 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/account_test.go @@ -13,7 +13,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() { path := NewICAPath(suite.chainA, suite.chainB) suite.coordinator.SetupConnections(path) - //RegisterInterchainAccount + // RegisterInterchainAccount err := SetupICAPath(path, TestOwnerAddress) suite.Require().NoError(err) diff --git a/modules/apps/27-interchain-accounts/host/keeper/events.go b/modules/apps/27-interchain-accounts/host/keeper/events.go index 5926781d5c2..65c75f02618 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/events.go +++ b/modules/apps/27-interchain-accounts/host/keeper/events.go @@ -2,9 +2,9 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/ibc-go/v3/modules/core/exported" + icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + "github.com/cosmos/ibc-go/v3/modules/core/exported" ) // EmitWriteErrorAcknowledgementEvent emits an event signalling an error acknowledgement and including the error details diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake.go b/modules/apps/27-interchain-accounts/host/keeper/handshake.go index 11a7c7a378e..6d15bb0568c 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake.go @@ -110,6 +110,5 @@ func (k Keeper) OnChanCloseConfirm( portID, channelID string, ) error { - return nil } diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 0cac2912ccb..ee0ca72f14b 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -22,7 +22,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { malleate func() expPass bool }{ - { "success", func() { @@ -228,16 +227,13 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { } func (suite *KeeperTestSuite) TestOnChanOpenConfirm() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -279,22 +275,18 @@ func (suite *KeeperTestSuite) TestOnChanOpenConfirm() { } else { suite.Require().Error(err) } - }) } } func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { - var ( - path *ibctesting.Path - ) + var path *ibctesting.Path testCases := []struct { name string malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -320,7 +312,6 @@ func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { } else { suite.Require().Error(err) } - }) } } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index ea3f8205c87..8f2f345da1b 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -39,7 +39,6 @@ func NewKeeper( channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter, ) Keeper { - // ensure ibc interchain accounts module account is set if addr := accountKeeper.GetModuleAddress(icatypes.ModuleName); addr == nil { panic("the Interchain Accounts module account has not been set") diff --git a/modules/apps/27-interchain-accounts/host/types/ack_test.go b/modules/apps/27-interchain-accounts/host/types/ack_test.go index bc4e2d07afc..6d2e6d1a95a 100644 --- a/modules/apps/27-interchain-accounts/host/types/ack_test.go +++ b/modules/apps/27-interchain-accounts/host/types/ack_test.go @@ -97,5 +97,4 @@ func (suite *TypesTestSuite) TestAcknowledgementError() { suite.Require().Equal(ack, ackSameABCICode) suite.Require().NotEqual(ack, ackDifferentABCICode) - } diff --git a/modules/apps/27-interchain-accounts/module_test.go b/modules/apps/27-interchain-accounts/module_test.go index 59517ab40e4..ff44eed4ff0 100644 --- a/modules/apps/27-interchain-accounts/module_test.go +++ b/modules/apps/27-interchain-accounts/module_test.go @@ -125,8 +125,6 @@ func (suite *InterchainAccountsTestSuite) TestInitModule() { suite.Require().True(app.IBCKeeper.PortKeeper.IsBound(ctx, types.PortID)) } - }) } - } diff --git a/modules/apps/27-interchain-accounts/types/account.go b/modules/apps/27-interchain-accounts/types/account.go index 9cd3fe4d327..38d7c4c5fe5 100644 --- a/modules/apps/27-interchain-accounts/types/account.go +++ b/modules/apps/27-interchain-accounts/types/account.go @@ -106,7 +106,6 @@ func (ia InterchainAccount) MarshalYAML() ([]byte, error) { Sequence: ia.Sequence, AccountOwner: ia.AccountOwner, }) - if err != nil { return nil, err } @@ -128,7 +127,6 @@ func (ia InterchainAccount) MarshalJSON() ([]byte, error) { Sequence: ia.Sequence, AccountOwner: ia.AccountOwner, }) - if err != nil { return nil, err } diff --git a/modules/apps/27-interchain-accounts/types/codec.go b/modules/apps/27-interchain-accounts/types/codec.go index a5a0922cabd..033c264f9e7 100644 --- a/modules/apps/27-interchain-accounts/types/codec.go +++ b/modules/apps/27-interchain-accounts/types/codec.go @@ -8,14 +8,12 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -var ( - // ModuleCdc references the global interchain accounts module codec. Note, the codec - // should ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to interchain accounts and - // defined at the application level. - ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) -) +// ModuleCdc references the global interchain accounts module codec. Note, the codec +// should ONLY be used in certain instances of tests and for JSON encoding. +// +// The actual codec used for serialization should be provided to interchain accounts and +// defined at the application level. +var ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) // RegisterInterfaces registers the concrete InterchainAccount implementation against the associated // x/auth AccountI and GenesisAccount interfaces diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index e027fda9346..b18b018332a 100644 --- a/modules/apps/27-interchain-accounts/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/types/codec_test.go @@ -148,5 +148,4 @@ func (suite *TypesTestSuite) TestDeserializeAndSerializeCosmosTxWithAmino() { bz, err := types.DeserializeCosmosTx(marshaler, []byte{0x10, 0}) suite.Require().Error(err) suite.Require().Empty(bz) - } diff --git a/modules/apps/27-interchain-accounts/types/genesis_test.go b/modules/apps/27-interchain-accounts/types/genesis_test.go index 7e6ffdc280b..bbdbc8d14d5 100644 --- a/modules/apps/27-interchain-accounts/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/types/genesis_test.go @@ -8,9 +8,7 @@ import ( ) func (suite *TypesTestSuite) TestValidateGenesisState() { - var ( - genesisState types.GenesisState - ) + var genesisState types.GenesisState testCases := []struct { name string @@ -63,9 +61,7 @@ func (suite *TypesTestSuite) TestValidateGenesisState() { } func (suite *TypesTestSuite) TestValidateControllerGenesisState() { - var ( - genesisState types.ControllerGenesisState - ) + var genesisState types.ControllerGenesisState testCases := []struct { name string @@ -188,9 +184,7 @@ func (suite *TypesTestSuite) TestValidateControllerGenesisState() { } func (suite *TypesTestSuite) TestValidateHostGenesisState() { - var ( - genesisState types.HostGenesisState - ) + var genesisState types.HostGenesisState testCases := []struct { name string diff --git a/modules/apps/27-interchain-accounts/types/metadata_test.go b/modules/apps/27-interchain-accounts/types/metadata_test.go index 05a1b457c38..3bda2549c07 100644 --- a/modules/apps/27-interchain-accounts/types/metadata_test.go +++ b/modules/apps/27-interchain-accounts/types/metadata_test.go @@ -7,7 +7,6 @@ import ( // use TestVersion as metadata being compared against func (suite *TypesTestSuite) TestIsPreviousMetadataEqual() { - var ( metadata types.Metadata previousVersion string @@ -127,7 +126,6 @@ func (suite *TypesTestSuite) TestIsPreviousMetadataEqual() { } func (suite *TypesTestSuite) TestValidateControllerMetadata() { - var metadata types.Metadata testCases := []struct { @@ -269,7 +267,6 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { } func (suite *TypesTestSuite) TestValidateHostMetadata() { - var metadata types.Metadata testCases := []struct { diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index 840ca529851..52e7797d987 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -33,7 +33,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { "type unspecified", types.InterchainAccountPacketData{ Type: types.UNSPECIFIED, - Data: []byte("data"), + Data: []byte("data"), Memo: "memo", }, false, diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index 092b7441453..ccf05b61b23 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -274,7 +274,7 @@ func GetCmdCounterpartyAddress() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) - + return cmd } diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index da58e1ae627..17a961d0074 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -495,7 +495,6 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { } else { suite.Require().Error(err) } - }) } } diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index d698d84e795..130ac18e1b3 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -101,7 +101,6 @@ func (k Keeper) distributePacketFeeOnAcknowledgement(ctx sdk.Context, refundAddr // refund timeout fee for unused timeout k.distributeFee(ctx, refundAddr, refundAddr, packetFee.Fee.TimeoutFee) - } // DistributePacketsFeesOnTimeout pays all the timeout fees for a given packetID while refunding the acknowledgement & receive fees to the refund account. diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 4ac6e2ed03f..9b67934c647 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -467,7 +467,6 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { // all fees in escrow should be deleted for this channel suite.Require().Empty(suite.chainA.GetSimApp().IBCFeeKeeper.GetIdentifiedPacketFeesForChannel(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) } - }) } } diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 10da5bc5595..9b95753f25c 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -35,7 +35,6 @@ func (k Keeper) IncentivizedPackets(goCtx context.Context, req *types.QueryIncen identifiedPackets = append(identifiedPackets, types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees)) return nil }) - if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } @@ -89,7 +88,6 @@ func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types. return nil }) - if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } @@ -101,7 +99,6 @@ func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types. // TotalRecvFees implements the Query/TotalRecvFees gRPC method func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) @@ -217,7 +214,6 @@ func (k Keeper) FeeEnabledChannels(goCtx context.Context, req *types.QueryFeeEna return nil }) - if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index d665c655ccf..5850a3be3ba 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -80,9 +80,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { } func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { - var ( - req *types.QueryIncentivizedPacketRequest - ) + var req *types.QueryIncentivizedPacketRequest testCases := []struct { name string @@ -235,9 +233,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { } func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { - var ( - req *types.QueryTotalRecvFeesRequest - ) + var req *types.QueryTotalRecvFeesRequest testCases := []struct { name string @@ -296,9 +292,7 @@ func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { } func (suite *KeeperTestSuite) TestQueryTotalAckFees() { - var ( - req *types.QueryTotalAckFeesRequest - ) + var req *types.QueryTotalAckFeesRequest testCases := []struct { name string @@ -357,9 +351,7 @@ func (suite *KeeperTestSuite) TestQueryTotalAckFees() { } func (suite *KeeperTestSuite) TestQueryTotalTimeoutFees() { - var ( - req *types.QueryTotalTimeoutFeesRequest - ) + var req *types.QueryTotalTimeoutFeesRequest testCases := []struct { name string @@ -418,9 +410,7 @@ func (suite *KeeperTestSuite) TestQueryTotalTimeoutFees() { } func (suite *KeeperTestSuite) TestQueryCounterpartyAddress() { - var ( - req *types.QueryCounterpartyAddressRequest - ) + var req *types.QueryCounterpartyAddressRequest testCases := []struct { name string @@ -590,9 +580,7 @@ func (suite *KeeperTestSuite) TestQueryFeeEnabledChannels() { } func (suite *KeeperTestSuite) TestQueryFeeEnabledChannel() { - var ( - req *types.QueryFeeEnabledChannelRequest - ) + var req *types.QueryFeeEnabledChannelRequest testCases := []struct { name string diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index c7e31ad3d1a..a4b5a153c33 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -36,7 +36,6 @@ func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ) Keeper { - return Keeper{ cdc: cdc, storeKey: key, diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 2b02e5b857b..4be71154a6b 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -35,9 +35,7 @@ func TestFeeTotal(t *testing.T) { } func TestPacketFeeValidation(t *testing.T) { - var ( - packetFee types.PacketFee - ) + var packetFee types.PacketFee testCases := []struct { name string diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index 1bd229b57a3..7cc0b4c9543 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -11,9 +11,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) -var ( - validPacketID = channeltypes.NewPacketId(ibctesting.MockFeePort, ibctesting.FirstChannelID, 1) -) +var validPacketID = channeltypes.NewPacketId(ibctesting.MockFeePort, ibctesting.FirstChannelID, 1) func TestKeyCounterpartyRelayer(t *testing.T) { var ( @@ -69,7 +67,6 @@ func TestParseKeyFeeEnabled(t *testing.T) { } func TestParseKeyFeesInEscrow(t *testing.T) { - testCases := []struct { name string key string @@ -105,7 +102,6 @@ func TestParseKeyFeesInEscrow(t *testing.T) { } func TestParseKeyForwardRelayerAddress(t *testing.T) { - testCases := []struct { name string key string @@ -141,9 +137,7 @@ func TestParseKeyForwardRelayerAddress(t *testing.T) { } func TestParseKeyCounterpartyRelayer(t *testing.T) { - var ( - relayerAddress = "relayer_address" - ) + relayerAddress := "relayer_address" testCases := []struct { name string diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 7b224b5a66c..185e66dd758 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -13,9 +13,7 @@ import ( ) func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { - var ( - msg *types.MsgRegisterCounterpartyAddress - ) + var msg *types.MsgRegisterCounterpartyAddress testCases := []struct { name string @@ -86,9 +84,7 @@ func TestRegisterCountepartyAddressGetSigners(t *testing.T) { } func TestMsgPayPacketFeeValidation(t *testing.T) { - var ( - msg *types.MsgPayPacketFee - ) + var msg *types.MsgPayPacketFee testCases := []struct { name string @@ -174,9 +170,7 @@ func TestMsgPayPacketFeeGetSignBytes(t *testing.T) { } func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { - var ( - msg *types.MsgPayPacketFeeAsync - ) + var msg *types.MsgPayPacketFeeAsync testCases := []struct { name string diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 95779ad2e8e..b11444b945e 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -25,7 +25,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -98,7 +97,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { suite.Require().Error(err) suite.Require().Equal(version, "") } - }) } } @@ -117,7 +115,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -191,7 +188,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { suite.Require().Error(err) suite.Require().Equal("", version) } - }) } } @@ -204,7 +200,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { malleate func() expPass bool }{ - { "success", func() {}, true, }, @@ -241,7 +236,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { } else { suite.Require().Error(err) } - }) } } diff --git a/modules/apps/transfer/keeper/grpc_query.go b/modules/apps/transfer/keeper/grpc_query.go index 5e7c5e7d295..25bbbe3d75b 100644 --- a/modules/apps/transfer/keeper/grpc_query.go +++ b/modules/apps/transfer/keeper/grpc_query.go @@ -24,7 +24,6 @@ func (q Keeper) DenomTrace(c context.Context, req *types.QueryDenomTraceRequest) } hash, err := types.ParseHexHash(strings.TrimPrefix(req.Hash, "ibc/")) - if err != nil { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", hash.String(), err)) } @@ -63,7 +62,6 @@ func (q Keeper) DenomTraces(c context.Context, req *types.QueryDenomTracesReques traces = append(traces, result) return nil }) - if err != nil { return nil, err } diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index 963abd21577..085891e265b 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -156,7 +156,6 @@ func (suite *KeeperTestSuite) TestQueryParams() { } func (suite *KeeperTestSuite) TestQueryDenomHash() { - reqTrace := types.DenomTrace{ Path: "transfer/channelToA/transfer/channelToB", BaseDenom: "uatom", diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index d3f32d95df7..b8681baa47b 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -34,7 +34,6 @@ func NewKeeper( ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, ) Keeper { - // ensure ibc transfer module account is set if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic("the IBC transfer module account has not been set") diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index d4d338bf73a..59e4869e54e 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { panic(fmt.Errorf("Failed to read model-based test files: %w", err)) } for _, file_info := range files { - var tlaTestCases = []TlaOnRecvPacketTestCase{} + tlaTestCases := []TlaOnRecvPacketTestCase{} if !strings.HasSuffix(file_info.Name(), ".json") { continue } diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 3c3a5aa6690..cb4b8c59fd5 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -58,7 +58,6 @@ func (k Keeper) SendTransfer( timeoutHeight clienttypes.Height, timeoutTimestamp uint64, ) error { - if !k.GetSendEnabled(ctx) { return types.ErrSendDisabled } diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index ce34f316669..3ad851b587e 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -28,25 +28,32 @@ func (suite *KeeperTestSuite) TestSendTransfer() { sendFromSource bool expPass bool }{ - {"successful transfer from source chain", + { + "successful transfer from source chain", func() { suite.coordinator.CreateTransferChannels(path) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, true}, - {"successful transfer with coin from counterparty chain", + }, true, true, + }, + { + "successful transfer with coin from counterparty chain", func() { // send coin from chainA back to chainB suite.coordinator.CreateTransferChannels(path) amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom, sdk.NewInt(100)) - }, false, true}, - {"source channel not found", + }, false, true, + }, + { + "source channel not found", func() { // channel references wrong ID suite.coordinator.CreateTransferChannels(path) path.EndpointA.ChannelID = ibctesting.InvalidID amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, - {"next seq send not found", + }, true, false, + }, + { + "next seq send not found", func() { path.EndpointA.ChannelID = "channel-0" path.EndpointB.ChannelID = "channel-0" @@ -58,22 +65,28 @@ func (suite *KeeperTestSuite) TestSendTransfer() { ) suite.chainA.CreateChannelCapability(suite.chainA.GetSimApp().ScopedIBCMockKeeper, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, // createOutgoingPacket tests // - source chain - {"send coin failed", + { + "send coin failed", func() { suite.coordinator.CreateTransferChannels(path) amount = sdk.NewCoin("randomdenom", sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, // - receiving chain - {"send from module account failed", + { + "send from module account failed", func() { suite.coordinator.CreateTransferChannels(path) amount = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, " randomdenom", sdk.NewInt(100)) - }, false, false}, - {"channel capability not found", + }, false, false, + }, + { + "channel capability not found", func() { suite.coordinator.CreateTransferChannels(path) cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) @@ -81,7 +94,8 @@ func (suite *KeeperTestSuite) TestSendTransfer() { // Release channel capability suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - }, true, false}, + }, true, false, + }, } for _, tc := range testCases { @@ -264,18 +278,22 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) }, false, true}, - {"unsuccessful refund from source", failedAck, + { + "unsuccessful refund from source", failedAck, func() { trace = types.ParseDenomTrace(sdk.DefaultBondDenom) - }, false, false}, - {"successful refund from with coin from external chain", failedAck, + }, false, false, + }, + { + "successful refund from with coin from external chain", failedAck, func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, false, true}, + }, false, true, + }, } for _, tc := range testCases { @@ -330,36 +348,46 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { malleate func() expPass bool }{ - {"successful timeout from sender as source chain", + { + "successful timeout from sender as source chain", func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(sdk.DefaultBondDenom) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, true}, - {"successful timeout from external chain", + }, true, + }, + { + "successful timeout from external chain", func() { escrow := types.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) coin := sdk.NewCoin(trace.IBCDenom(), amount) suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) - }, true}, - {"no balance for coin denom", + }, true, + }, + { + "no balance for coin denom", func() { trace = types.ParseDenomTrace("bitcoin") - }, false}, - {"unescrow failed", + }, false, + }, + { + "unescrow failed", func() { trace = types.ParseDenomTrace(sdk.DefaultBondDenom) - }, false}, - {"mint failed", + }, false, + }, + { + "mint failed", func() { trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) amount = sdk.OneInt() sender = "invalid address" - }, false}, + }, false, + }, } for _, tc := range testCases { diff --git a/modules/apps/transfer/simulation/genesis_test.go b/modules/apps/transfer/simulation/genesis_test.go index c869d1c7b25..f2aa439b3ae 100644 --- a/modules/apps/transfer/simulation/genesis_test.go +++ b/modules/apps/transfer/simulation/genesis_test.go @@ -43,7 +43,6 @@ func TestRandomizedGenState(t *testing.T) { require.True(t, ibcTransferGenesis.Params.SendEnabled) require.True(t, ibcTransferGenesis.Params.ReceiveEnabled) require.Len(t, ibcTransferGenesis.DenomTraces, 0) - } // TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. diff --git a/modules/apps/transfer/types/ack_test.go b/modules/apps/transfer/types/ack_test.go index 4f4c3a874d7..ffc09da981e 100644 --- a/modules/apps/transfer/types/ack_test.go +++ b/modules/apps/transfer/types/ack_test.go @@ -97,5 +97,4 @@ func (suite *TypesTestSuite) TestAcknowledgementError() { suite.Require().Equal(ack, ackSameABCICode) suite.Require().NotEqual(ack, ackDifferentABCICode) - } diff --git a/modules/apps/transfer/types/coin.go b/modules/apps/transfer/types/coin.go index a3491e2bf09..d6329541103 100644 --- a/modules/apps/transfer/types/coin.go +++ b/modules/apps/transfer/types/coin.go @@ -27,7 +27,6 @@ func ReceiverChainIsSource(sourcePort, sourceChannel, denom string) bool { voucherPrefix := GetDenomPrefix(sourcePort, sourceChannel) return strings.HasPrefix(denom, voucherPrefix) - } // GetDenomPrefix returns the receiving denomination prefix diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index d8085ac719f..0360952e75a 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -146,7 +146,8 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H // UpgradeClient upgrades the client to a new client state if this new client was committed to // by the old client at the specified upgrade height func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState, - proofUpgradeClient, proofUpgradeConsState []byte) error { + proofUpgradeClient, proofUpgradeConsState []byte, +) error { clientState, found := k.GetClientState(ctx, clientID) if !found { return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID) diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index cc36b8a4edb..cde30cbb0fe 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -418,7 +418,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { suite.Require().Error(err, "verify upgrade passed on invalid case: %s", tc.name) } } - } func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { @@ -698,8 +697,6 @@ func (suite *KeeperTestSuite) TestUpdateClientEventEmission() { suite.Require().NoError(err) suite.Require().Equal(header, emittedHeader) } - } suite.Require().True(contains) - } diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index d4a2eca5a4f..555994e0a88 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -83,7 +83,6 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ clientStates = append(clientStates, identifiedClient) return nil }) - if err != nil { return nil, err } @@ -177,7 +176,6 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat consensusStates = append(consensusStates, types.NewConsensusStateWithHeight(height, consensusState)) return true, nil }) - if err != nil { return nil, err } diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 5e393c33a97..7506291f4ae 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -28,19 +28,22 @@ func (suite *KeeperTestSuite) TestQueryClientState() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, false, }, - {"invalid clientID", + { + "invalid clientID", func() { req = &types.QueryClientStateRequest{} }, false, }, - {"client not found", + { + "client not found", func() { req = &types.QueryClientStateRequest{ ClientId: testClientID, @@ -100,7 +103,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, @@ -190,7 +194,8 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, @@ -396,9 +401,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { } func (suite *KeeperTestSuite) TestQueryClientStatus() { - var ( - req *types.QueryClientStatusRequest - ) + var req *types.QueryClientStatusRequest testCases := []struct { msg string @@ -406,19 +409,22 @@ func (suite *KeeperTestSuite) TestQueryClientStatus() { expPass bool expStatus string }{ - {"req is nil", + { + "req is nil", func() { req = nil }, false, "", }, - {"invalid clientID", + { + "invalid clientID", func() { req = &types.QueryClientStatusRequest{} }, false, "", }, - {"client not found", + { + "client not found", func() { req = &types.QueryClientStatusRequest{ ClientId: ibctesting.InvalidID, @@ -503,7 +509,8 @@ func (suite *KeeperTestSuite) TestQueryUpgradedConsensusStates() { malleate func() expPass bool }{ - {"req is nil", + { + "req is nil", func() { req = nil }, diff --git a/modules/core/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index bec5aa0a78a..277354f9e9b 100644 --- a/modules/core/02-client/keeper/proposal_test.go +++ b/modules/core/02-client/keeper/proposal_test.go @@ -154,7 +154,6 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { } }) } - } func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { @@ -206,7 +205,7 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { suite.Run(tc.name, func() { suite.SetupTest() // reset - oldPlan.Height = 0 //reset + oldPlan.Height = 0 // reset path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) @@ -276,5 +275,4 @@ func (suite *KeeperTestSuite) TestHandleUpgradeProposal() { } }) } - } diff --git a/modules/core/02-client/legacy/v100/genesis.go b/modules/core/02-client/legacy/v100/genesis.go index fa052ade3f8..014dd3870c0 100644 --- a/modules/core/02-client/legacy/v100/genesis.go +++ b/modules/core/02-client/legacy/v100/genesis.go @@ -123,13 +123,11 @@ func MigrateGenesis(cdc codec.BinaryCodec, clientGenState *types.GenesisState, g Key: ibctmtypes.IterationKey(height), Value: host.ConsensusStateKey(height), }) - } } } } - } // if we have metadata for unexipred consensus states, add it to consensusMetadata diff --git a/modules/core/02-client/legacy/v100/genesis_test.go b/modules/core/02-client/legacy/v100/genesis_test.go index 4835ce98213..c4daa6c9bfc 100644 --- a/modules/core/02-client/legacy/v100/genesis_test.go +++ b/modules/core/02-client/legacy/v100/genesis_test.go @@ -254,7 +254,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(height, consensusState.Height) } } - } for _, client := range migrated.ClientsMetadata { if client.ClientId == path1.EndpointA.ClientID { @@ -275,7 +274,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(height, consensusState.Height) } } - } for _, client := range migrated.ClientsMetadata { if client.ClientId == path2.EndpointA.ClientID { @@ -285,7 +283,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisTendermint() { suite.Require().NotEqual(ibctmtypes.IterationKey(height), metadata.Key) } } - } } bz, err := clientCtx.JSONCodec.MarshalJSON(&expectedClientGenState) diff --git a/modules/core/02-client/proposal_handler_test.go b/modules/core/02-client/proposal_handler_test.go index 4ef2798d633..b83455b39c2 100644 --- a/modules/core/02-client/proposal_handler_test.go +++ b/modules/core/02-client/proposal_handler_test.go @@ -84,5 +84,4 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() { } }) } - } diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 9f41843c064..cefe567619c 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -10,9 +10,7 @@ import ( ) func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() { - var ( - cswh types.ConsensusStateWithHeight - ) + var cswh types.ConsensusStateWithHeight testCases := []struct { name string diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 85b53e5ad84..bb706d87fd1 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -18,7 +18,6 @@ type caseAny struct { } func (suite *TypesTestSuite) TestPackClientState() { - testCases := []struct { name string clientState exported.ClientState diff --git a/modules/core/02-client/types/encoding_test.go b/modules/core/02-client/types/encoding_test.go index 9bd619260ea..75ee99e6c85 100644 --- a/modules/core/02-client/types/encoding_test.go +++ b/modules/core/02-client/types/encoding_test.go @@ -6,7 +6,6 @@ import ( ) func (suite *TypesTestSuite) TestMarshalHeader() { - cdc := suite.chainA.App.AppCodec() h := &ibctmtypes.Header{ TrustedHeight: types.NewHeight(4, 100), @@ -26,5 +25,4 @@ func (suite *TypesTestSuite) TestMarshalHeader() { invalidHeader, err := types.UnmarshalHeader(cdc, []byte("invalid bytes")) suite.Require().Error(err) suite.Require().Nil(invalidHeader) - } diff --git a/modules/core/02-client/types/genesis.go b/modules/core/02-client/types/genesis.go index a272404054f..ccf797e0d49 100644 --- a/modules/core/02-client/types/genesis.go +++ b/modules/core/02-client/types/genesis.go @@ -196,7 +196,6 @@ func (gs GenesisState) Validate() error { if err := gm.Validate(); err != nil { return fmt.Errorf("invalid client metadata %v clientID %s index %d: %w", gm, clientMetadata.ClientId, i, err) } - } } diff --git a/modules/core/02-client/types/height_test.go b/modules/core/02-client/types/height_test.go index c31bbaabf21..16415c3d61e 100644 --- a/modules/core/02-client/types/height_test.go +++ b/modules/core/02-client/types/height_test.go @@ -126,7 +126,6 @@ func TestParseChainID(t *testing.T) { revision := types.ParseChainID(tc.chainID) require.Equal(t, tc.revision, revision, "chainID %s returns incorrect revision", tc.chainID) } - } func TestSetRevisionNumber(t *testing.T) { diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index d80fe8b0592..e329a58ab49 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -34,7 +34,6 @@ var ( func NewMsgCreateClient( clientState exported.ClientState, consensusState exported.ConsensusState, signer string, ) (*MsgCreateClient, error) { - anyClientState, err := PackClientState(clientState) if err != nil { return nil, err @@ -154,7 +153,8 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err // NewMsgUpgradeClient creates a new MsgUpgradeClient instance // nolint: interfacer func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, consState exported.ConsensusState, - proofUpgradeClient, proofUpgradeConsState []byte, signer string) (*MsgUpgradeClient, error) { + proofUpgradeClient, proofUpgradeConsState []byte, signer string, +) (*MsgUpgradeClient, error) { anyClient, err := PackClientState(clientState) if err != nil { return nil, err diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index ce5ecd159cb..ec0b87ac0bb 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -211,7 +211,6 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() { "tendermint client", func() { msg, err = types.NewMsgUpdateClient("tendermint", suite.chainA.CurrentTMClientHeader(), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) - }, }, } @@ -496,7 +495,6 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) - }, }, } diff --git a/modules/core/02-client/types/proposal_test.go b/modules/core/02-client/types/proposal_test.go index a32dcdac4e8..d1a6f52cf71 100644 --- a/modules/core/02-client/types/proposal_test.go +++ b/modules/core/02-client/types/proposal_test.go @@ -117,7 +117,6 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() { "fails validate abstract - empty title", func() { proposal, err = types.NewUpgradeProposal("", ibctesting.Description, plan, cs) suite.Require().NoError(err) - }, false, }, { @@ -199,7 +198,6 @@ func (suite *TypesTestSuite) TestMarshalUpgradeProposal() { // unpack client state _, err = types.UnpackClientState(newUp.UpgradedClientState) suite.Require().NoError(err) - } func (suite *TypesTestSuite) TestUpgradeString() { diff --git a/modules/core/03-connection/client/utils/utils.go b/modules/core/03-connection/client/utils/utils.go index 3bd54a44541..aaadcf9feae 100644 --- a/modules/core/03-connection/client/utils/utils.go +++ b/modules/core/03-connection/client/utils/utils.go @@ -105,7 +105,6 @@ func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*typ func QueryConnectionClientState( clientCtx client.Context, connectionID string, prove bool, ) (*types.QueryConnectionClientStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryConnectionClientStateRequest{ ConnectionId: connectionID, @@ -140,7 +139,6 @@ func QueryConnectionClientState( func QueryConnectionConsensusState( clientCtx client.Context, connectionID string, height clienttypes.Height, prove bool, ) (*types.QueryConnectionConsensusStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryConnectionConsensusStateRequest{ ConnectionId: connectionID, diff --git a/modules/core/03-connection/keeper/events.go b/modules/core/03-connection/keeper/events.go index 6b1636ea71e..a8dcd1251a7 100644 --- a/modules/core/03-connection/keeper/events.go +++ b/modules/core/03-connection/keeper/events.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" ) diff --git a/modules/core/03-connection/keeper/grpc_query.go b/modules/core/03-connection/keeper/grpc_query.go index 77d8bc98c84..89e9b978e0b 100644 --- a/modules/core/03-connection/keeper/grpc_query.go +++ b/modules/core/03-connection/keeper/grpc_query.go @@ -68,7 +68,6 @@ func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsReques connections = append(connections, &identifiedConnection) return nil }) - if err != nil { return nil, err } @@ -137,7 +136,6 @@ func (q Keeper) ConnectionClientState(c context.Context, req *types.QueryConnect height := clienttypes.GetSelfHeight(ctx) return types.NewQueryConnectionClientStateResponse(identifiedClientState, nil, height), nil - } // ConnectionConsensusState implements the Query/ConnectionConsensusState gRPC method diff --git a/modules/core/03-connection/keeper/grpc_query_test.go b/modules/core/03-connection/keeper/grpc_query_test.go index a2542fe62b2..fe97dd09b85 100644 --- a/modules/core/03-connection/keeper/grpc_query_test.go +++ b/modules/core/03-connection/keeper/grpc_query_test.go @@ -30,13 +30,15 @@ func (suite *KeeperTestSuite) TestQueryConnection() { }, false, }, - {"invalid connectionID", + { + "invalid connectionID", func() { req = &types.QueryConnectionRequest{} }, false, }, - {"connection not found", + { + "connection not found", func() { req = &types.QueryConnectionRequest{ ConnectionId: ibctesting.InvalidID, @@ -186,13 +188,15 @@ func (suite *KeeperTestSuite) TestQueryClientConnections() { }, false, }, - {"invalid connectionID", + { + "invalid connectionID", func() { req = &types.QueryClientConnectionsRequest{} }, false, }, - {"connection not found", + { + "connection not found", func() { req = &types.QueryClientConnectionsRequest{ ClientId: ibctesting.InvalidID, diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index 6f5dfbce1d9..8707b72d401 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -370,7 +370,6 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { tmClient.ChainId = "wrongchainid" suite.chainB.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainB.GetContext(), path.EndpointB.ClientID, tmClient) - }, false}, {"consensus height >= latest height", func() { err := path.EndpointA.ConnOpenInit() @@ -554,7 +553,6 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { err = path.EndpointB.ConnOpenTry() suite.Require().NoError(err) - }, false}, } diff --git a/modules/core/03-connection/keeper/keeper_test.go b/modules/core/03-connection/keeper/keeper_test.go index b4dfa839028..3d63ed468ba 100644 --- a/modules/core/03-connection/keeper/keeper_test.go +++ b/modules/core/03-connection/keeper/keeper_test.go @@ -45,7 +45,6 @@ func (suite *KeeperTestSuite) TestSetAndGetConnection() { } func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { - path := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(path) diff --git a/modules/core/03-connection/types/codec.go b/modules/core/03-connection/types/codec.go index 8f65884aadf..96ae3cba865 100644 --- a/modules/core/03-connection/types/codec.go +++ b/modules/core/03-connection/types/codec.go @@ -38,11 +38,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -var ( - // SubModuleCdc references the global x/ibc/core/03-connection module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to x/ibc/core/03-connection and - // defined at the application level. - SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) -) +// SubModuleCdc references the global x/ibc/core/03-connection module codec. Note, the codec should +// ONLY be used in certain instances of tests and for JSON encoding. +// +// The actual codec used for serialization should be provided to x/ibc/core/03-connection and +// defined at the application level. +var SubModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) diff --git a/modules/core/03-connection/types/genesis_test.go b/modules/core/03-connection/types/genesis_test.go index db2192385b7..31906350531 100644 --- a/modules/core/03-connection/types/genesis_test.go +++ b/modules/core/03-connection/types/genesis_test.go @@ -11,7 +11,6 @@ import ( ) func TestValidateGenesis(t *testing.T) { - testCases := []struct { name string genState types.GenesisState diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index 9cf741bb2c0..b6f4544b98f 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -68,7 +68,6 @@ func (suite *MsgTestSuite) SetupTest() { suite.Require().NoError(err) suite.proof = proof - } func TestMsgTestSuite(t *testing.T) { @@ -81,7 +80,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { // will be used in protocol. var version *types.Version - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenInit expPass bool @@ -124,7 +123,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenTry expPass bool @@ -176,7 +175,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { ) connectionID := "connection-0" - var testCases = []struct { + testCases := []struct { name string msg *types.MsgConnectionOpenAck expPass bool @@ -215,7 +214,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, signer), } - var testCases = []struct { + testCases := []struct { msg *types.MsgConnectionOpenConfirm expPass bool errMsg string diff --git a/modules/core/03-connection/types/version_test.go b/modules/core/03-connection/types/version_test.go index 3fa637cc4de..404f4f8ca56 100644 --- a/modules/core/03-connection/types/version_test.go +++ b/modules/core/03-connection/types/version_test.go @@ -141,7 +141,6 @@ func TestVerifyProposedVersion(t *testing.T) { require.Error(t, err, "test case %d: %s", i, tc.name) } } - } func TestVerifySupportedFeature(t *testing.T) { diff --git a/modules/core/04-channel/client/utils/utils.go b/modules/core/04-channel/client/utils/utils.go index de40903e6fb..4124fe9b2b4 100644 --- a/modules/core/04-channel/client/utils/utils.go +++ b/modules/core/04-channel/client/utils/utils.go @@ -64,7 +64,6 @@ func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*type func QueryChannelClientState( clientCtx client.Context, portID, channelID string, prove bool, ) (*types.QueryChannelClientStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryChannelClientStateRequest{ PortId: portID, @@ -99,7 +98,6 @@ func QueryChannelClientState( func QueryChannelConsensusState( clientCtx client.Context, portID, channelID string, height clienttypes.Height, prove bool, ) (*types.QueryChannelConsensusStateResponse, error) { - queryClient := types.NewQueryClient(clientCtx) req := &types.QueryChannelConsensusStateRequest{ PortId: portID, diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index 6bd8418a564..6d4b150ada9 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -69,7 +69,6 @@ func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*t channels = append(channels, &identifiedChannel) return nil }) - if err != nil { return nil, err } @@ -118,7 +117,6 @@ func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection channels = append(channels, &identifiedChannel) return nil }) - if err != nil { return nil, err } @@ -252,7 +250,6 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi commitments = append(commitments, &commitment) return nil }) - if err != nil { return nil, err } @@ -361,7 +358,6 @@ func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket return nil }) - if err != nil { return nil, err } @@ -401,7 +397,7 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP ctx := sdk.UnwrapSDKContext(c) - var unreceivedSequences = []uint64{} + unreceivedSequences := []uint64{} for i, seq := range req.PacketCommitmentSequences { if seq == 0 { @@ -450,7 +446,7 @@ func (q Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcks ctx := sdk.UnwrapSDKContext(c) - var unreceivedSequences = []uint64{} + unreceivedSequences := []uint64{} for i, seq := range req.PacketAckSequences { if seq == 0 { diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index cc899e99444..64c81f2105d 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -51,7 +51,8 @@ func (suite *KeeperTestSuite) TestQueryChannel() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryChannelRequest{ PortId: "test-port-id", @@ -628,7 +629,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketCommitmentRequest{ PortId: "test-port-id", @@ -638,7 +640,8 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryPacketCommitmentRequest{ PortId: "test-port-id", @@ -819,7 +822,8 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketReceiptRequest{ PortId: "test-port-id", @@ -923,7 +927,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, false, }, - {"invalid sequence", + { + "invalid sequence", func() { req = &types.QueryPacketAcknowledgementRequest{ PortId: "test-port-id", @@ -933,7 +938,8 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryPacketAcknowledgementRequest{ PortId: "test-port-id", @@ -1400,7 +1406,8 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { }, false, }, - {"channel not found", + { + "channel not found", func() { req = &types.QueryNextSequenceReceiveRequest{ PortId: "test-port-id", diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index db6cce545c9..4d05df46533 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -220,7 +220,6 @@ func (suite *KeeperTestSuite) TestSendPacket() { } }) } - } // TestRecvPacket test RecvPacket on chainB. Since packet commitment verification will always @@ -487,7 +486,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } }) } - } func (suite *KeeperTestSuite) TestWriteAcknowledgement() { diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index a7151c4c0ff..ae3a816ef16 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -430,5 +430,4 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { } }) } - } diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index 28b8b3cd0dd..68a96c9b0c3 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -72,7 +72,6 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { } }) } - } func (suite *MerkleTestSuite) TestVerifyNonMembership() { @@ -136,7 +135,6 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { } }) } - } func TestApplyPrefix(t *testing.T) { diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 3a6cc5cb23b..12b259498ea 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -52,12 +52,12 @@ func NewKeeper( // panic if any of the keepers passed in is empty if reflect.ValueOf(stakingKeeper).IsZero() { panic(fmt.Errorf("cannot initialize IBC keeper: empty staking keeper")) - } - + } + if reflect.ValueOf(upgradeKeeper).IsZero() { panic(fmt.Errorf("cannot initialize IBC keeper: empty upgrade keeper")) - } - + } + if reflect.DeepEqual(capabilitykeeper.ScopedKeeper{}, scopedKeeper) { panic(fmt.Errorf("cannot initialize IBC keeper: empty scoped keeper")) } diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index d40d1ab34c5..8e8c1138374 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -83,20 +83,17 @@ func (suite *KeeperTestSuite) TestNewKeeper() { emptyStakingKeeper := stakingkeeper.Keeper{} stakingKeeper = emptyStakingKeeper - }, false}, {"failure: empty mock staking keeper", func() { // use a different implementation of clienttypes.StakingKeeper emptyMockStakingKeeper := MockStakingKeeper{} stakingKeeper = emptyMockStakingKeeper - }, false}, {"failure: empty upgrade keeper", func() { emptyUpgradeKeeper := upgradekeeper.Keeper{} upgradeKeeper = emptyUpgradeKeeper - }, false}, {"failure: empty scoped keeper", func() { emptyScopedKeeper := capabilitykeeper.ScopedKeeper{} @@ -116,7 +113,6 @@ func (suite *KeeperTestSuite) TestNewKeeper() { suite.SetupTest() suite.Run(tc.name, func() { - stakingKeeper = suite.chainA.GetSimApp().StakingKeeper upgradeKeeper = suite.chainA.GetSimApp().UpgradeKeeper scopedKeeper = suite.chainA.GetSimApp().ScopedIBCKeeper @@ -132,7 +128,6 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeper, ) } - }) } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index a4aeb496f6f..c090d7187d7 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -16,9 +16,11 @@ import ( coretypes "github.com/cosmos/ibc-go/v3/modules/core/types" ) -var _ clienttypes.MsgServer = Keeper{} -var _ connectiontypes.MsgServer = Keeper{} -var _ channeltypes.MsgServer = Keeper{} +var ( + _ clienttypes.MsgServer = Keeper{} + _ connectiontypes.MsgServer = Keeper{} + _ channeltypes.MsgServer = Keeper{} +) // CreateClient defines a rpc handler method for MsgCreateClient. func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 7e01241be81..3cb0dc4fca0 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -415,7 +415,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { path.EndpointA.UpdateClient() packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) - }, true}, {"channel does not exist", func() { // any non-nil value of packet is valid @@ -645,7 +644,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { { name: "successful upgrade", setup: func() { - upgradedClient = ibctmtypes.NewClientState(newChainId, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // Call ZeroCustomFields on upgraded clients to clear any client-chosen parameters in test-case upgradedClient upgradedClient = upgradedClient.ZeroCustomFields() @@ -686,7 +684,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { { name: "VerifyUpgrade fails", setup: func() { - upgradedClient = ibctmtypes.NewClientState(newChainId, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // Call ZeroCustomFields on upgraded clients to clear any client-chosen parameters in test-case upgradedClient upgradedClient = upgradedClient.ZeroCustomFields() diff --git a/modules/light-clients/06-solomachine/types/client_state_test.go b/modules/light-clients/06-solomachine/types/client_state_test.go index 09ea9693119..16b62b2722b 100644 --- a/modules/light-clients/06-solomachine/types/client_state_test.go +++ b/modules/light-clients/06-solomachine/types/client_state_test.go @@ -82,7 +82,6 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() { tc := tc suite.Run(tc.name, func() { - err := tc.clientState.Validate() if tc.expPass { @@ -238,7 +237,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { tc := tc suite.Run(tc.name, func() { - var expSeq uint64 if tc.clientState.ConsensusState != nil { expSeq = tc.clientState.Sequence + 1 @@ -359,7 +357,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { tc := tc suite.Run(tc.name, func() { - var expSeq uint64 if tc.clientState.ConsensusState != nil { expSeq = tc.clientState.Sequence + 1 diff --git a/modules/light-clients/06-solomachine/types/codec_test.go b/modules/light-clients/06-solomachine/types/codec_test.go index 1a0e3e0086f..0ed8760daa3 100644 --- a/modules/light-clients/06-solomachine/types/codec_test.go +++ b/modules/light-clients/06-solomachine/types/codec_test.go @@ -55,7 +55,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { path := solomachine.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) data, err = types.ConsensusStateDataBytes(cdc, path, solomachine.ConsensusState()) suite.Require().NoError(err) - }, true, }, { @@ -73,7 +72,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { data, err = types.ConnectionStateDataBytes(cdc, path, conn) suite.Require().NoError(err) - }, true, }, { @@ -104,7 +102,6 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { data, err = types.ConnectionStateDataBytes(cdc, path, conn) suite.Require().NoError(err) - }, false, }, { @@ -186,5 +183,4 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { }) } } - } diff --git a/modules/light-clients/06-solomachine/types/consensus_state_test.go b/modules/light-clients/06-solomachine/types/consensus_state_test.go index 33e200c5461..2bb1ab5a456 100644 --- a/modules/light-clients/06-solomachine/types/consensus_state_test.go +++ b/modules/light-clients/06-solomachine/types/consensus_state_test.go @@ -61,7 +61,6 @@ func (suite *SoloMachineTestSuite) TestConsensusStateValidateBasic() { tc := tc suite.Run(tc.name, func() { - err := tc.consensusState.ValidateBasic() if tc.expPass { diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go b/modules/light-clients/06-solomachine/types/misbehaviour_handle.go index d5a1d57cb57..fb3dc573c3e 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_handle.go @@ -21,7 +21,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( clientStore sdk.KVStore, misbehaviour exported.Misbehaviour, ) (exported.ClientState, error) { - soloMisbehaviour, ok := misbehaviour.(*Misbehaviour) if !ok { return nil, sdkerrors.Wrapf( @@ -51,7 +50,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // over the provided data and that the data is valid. The data is valid if it can be // unmarshaled into the specified data type. func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misbehaviour *Misbehaviour, sigAndData *SignatureAndData) error { - // do not check misbehaviour timestamp since we want to allow processing of past misbehaviour // ensure data can be unmarshaled to the specified data type @@ -85,5 +83,4 @@ func verifySignatureAndData(cdc codec.BinaryCodec, clientState ClientState, misb } return nil - } diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go b/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go index db58b710772..7aa19617a76 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_handle_test.go @@ -227,7 +227,6 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() { m.SignatureTwo.Data = msg misbehaviour = m - }, false, }, diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_test.go b/modules/light-clients/06-solomachine/types/misbehaviour_test.go index 813a8520ee7..c304fc576ed 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_test.go +++ b/modules/light-clients/06-solomachine/types/misbehaviour_test.go @@ -113,7 +113,6 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() { tc := tc suite.Run(tc.name, func() { - misbehaviour := solomachine.CreateMisbehaviour() tc.malleateMisbehaviour(misbehaviour) diff --git a/modules/light-clients/06-solomachine/types/proof.go b/modules/light-clients/06-solomachine/types/proof.go index f884a26d745..75a58cc3101 100644 --- a/modules/light-clients/06-solomachine/types/proof.go +++ b/modules/light-clients/06-solomachine/types/proof.go @@ -55,7 +55,8 @@ func MisbehaviourSignBytes( sequence, timestamp uint64, diversifier string, dataType DataType, - data []byte) ([]byte, error) { + data []byte, +) ([]byte, error) { signBytes := &SignBytes{ Sequence: sequence, Timestamp: timestamp, diff --git a/modules/light-clients/06-solomachine/types/proposal_handle.go b/modules/light-clients/06-solomachine/types/proposal_handle.go index a28bc27c398..c7d29faedc9 100644 --- a/modules/light-clients/06-solomachine/types/proposal_handle.go +++ b/modules/light-clients/06-solomachine/types/proposal_handle.go @@ -22,7 +22,6 @@ func (cs ClientState) CheckSubstituteAndUpdateState( ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore, _ sdk.KVStore, substituteClient exported.ClientState, ) (exported.ClientState, error) { - if !cs.AllowUpdateAfterProposal { return nil, sdkerrors.Wrapf( clienttypes.ErrUpdateClientFailed, diff --git a/modules/light-clients/06-solomachine/types/update_test.go b/modules/light-clients/06-solomachine/types/update_test.go index f13d5f198d1..ae3caa44a5c 100644 --- a/modules/light-clients/06-solomachine/types/update_test.go +++ b/modules/light-clients/06-solomachine/types/update_test.go @@ -122,7 +122,6 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { clientState = cs header = h - }, false, }, diff --git a/modules/light-clients/07-tendermint/types/client_state_test.go b/modules/light-clients/07-tendermint/types/client_state_test.go index cf52d2996b5..f45bd2fc6d6 100644 --- a/modules/light-clients/07-tendermint/types/client_state_test.go +++ b/modules/light-clients/07-tendermint/types/client_state_test.go @@ -27,9 +27,7 @@ const ( fiftyOneCharChainID = "123456789012345678901234567890123456789012345678901" ) -var ( - invalidProof = []byte("invalid proof") -) +var invalidProof = []byte("invalid proof") func (suite *TendermintTestSuite) TestStatus() { var ( @@ -166,7 +164,6 @@ func (suite *TendermintTestSuite) TestValidate() { } func (suite *TendermintTestSuite) TestInitialize() { - testCases := []struct { name string consensusState exported.ConsensusState diff --git a/modules/light-clients/07-tendermint/types/consensus_state_test.go b/modules/light-clients/07-tendermint/types/consensus_state_test.go index f45a4a5d24d..2d3be714799 100644 --- a/modules/light-clients/07-tendermint/types/consensus_state_test.go +++ b/modules/light-clients/07-tendermint/types/consensus_state_test.go @@ -14,49 +14,61 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { consensusState *types.ConsensusState expectPass bool }{ - {"success", + { + "success", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, - true}, - {"success with sentinel", + true, + }, + { + "success with sentinel", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte(types.SentinelRoot)), NextValidatorsHash: suite.valsHash, }, - true}, - {"root is nil", + true, + }, + { + "root is nil", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, - false}, - {"root is empty", + false, + }, + { + "root is empty", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, - false}, - {"nextvalshash is invalid", + false, + }, + { + "nextvalshash is invalid", &types.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: []byte("hi"), }, - false}, + false, + }, - {"timestamp is zero", + { + "timestamp is zero", &types.ConsensusState{ Timestamp: time.Time{}, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, - false}, + false, + }, } for i, tc := range testCases { diff --git a/modules/light-clients/07-tendermint/types/header_test.go b/modules/light-clients/07-tendermint/types/header_test.go index f57776c092f..8383a1a0be3 100644 --- a/modules/light-clients/07-tendermint/types/header_test.go +++ b/modules/light-clients/07-tendermint/types/header_test.go @@ -21,9 +21,7 @@ func (suite *TendermintTestSuite) TestGetTime() { } func (suite *TendermintTestSuite) TestHeaderValidateBasic() { - var ( - header *types.Header - ) + var header *types.Header testCases := []struct { name string malleate func() diff --git a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go b/modules/light-clients/07-tendermint/types/misbehaviour_handle.go index 4c8224bde09..67f4fccdd98 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/types/misbehaviour_handle.go @@ -101,7 +101,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( func checkMisbehaviourHeader( clientState *ClientState, consState *ConsensusState, header *Header, currentTimestamp time.Time, ) error { - tmTrustedValset, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { return sdkerrors.Wrap(err, "trusted validator set is not tendermint validator set type") diff --git a/modules/light-clients/07-tendermint/types/proposal_handle_test.go b/modules/light-clients/07-tendermint/types/proposal_handle_test.go index 822ec16e014..fa8bc7798de 100644 --- a/modules/light-clients/07-tendermint/types/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/types/proposal_handle_test.go @@ -9,9 +9,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) -var ( - frozenHeight = clienttypes.NewHeight(0, 1) -) +var frozenHeight = clienttypes.NewHeight(0, 1) func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { var ( @@ -43,7 +41,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset subjectPath := ibctesting.NewPath(suite.chainA, suite.chainB) substitutePath = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -217,7 +214,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { // a client are each tested to ensure that unexpiry headers cannot update // a client when a unfreezing header is required. suite.Run(tc.name, func() { - // start by testing unexpiring the client suite.SetupTest() // reset @@ -303,7 +299,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { suite.Require().Error(err) suite.Require().Nil(updatedClient) } - }) } } @@ -365,7 +360,6 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { tc.malleate() suite.Require().Equal(tc.expPass, types.IsMatchingClientState(*subjectClientState, *substituteClientState)) - }) } } diff --git a/modules/light-clients/07-tendermint/types/store.go b/modules/light-clients/07-tendermint/types/store.go index 785ed77ba97..5cf7f5d8657 100644 --- a/modules/light-clients/07-tendermint/types/store.go +++ b/modules/light-clients/07-tendermint/types/store.go @@ -96,7 +96,6 @@ func IterateConsensusMetadata(store sdk.KVStore, cb func(key, val []byte) bool) if len(keySplit) != 3 { // ignore all consensus state keys continue - } if keySplit[2] != "processedTime" && keySplit[2] != "processedHeight" { diff --git a/modules/light-clients/07-tendermint/types/upgrade_test.go b/modules/light-clients/07-tendermint/types/upgrade_test.go index 175ce7fc358..6ad81df3520 100644 --- a/modules/light-clients/07-tendermint/types/upgrade_test.go +++ b/modules/light-clients/07-tendermint/types/upgrade_test.go @@ -10,9 +10,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) -var ( - newChainId = "newChainId-1" -) +var newChainId = "newChainId-1" func (suite *TendermintTestSuite) TestVerifyUpgrade() { var ( diff --git a/modules/light-clients/09-localhost/types/client_state_test.go b/modules/light-clients/09-localhost/types/client_state_test.go index a54cc8efe9a..04b57fcbbf0 100644 --- a/modules/light-clients/09-localhost/types/client_state_test.go +++ b/modules/light-clients/09-localhost/types/client_state_test.go @@ -150,7 +150,6 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() { } }) } - } func (suite *LocalhostTestSuite) TestVerifyClientConsensusState() { @@ -291,7 +290,6 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set(host.ChannelKey(testPortID, testChannelID), []byte("channel")) - }, channel: ch1, expPass: false, @@ -303,7 +301,6 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { bz, err := suite.cdc.Marshal(&ch2) suite.Require().NoError(err) suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz) - }, channel: ch1, expPass: false, diff --git a/modules/light-clients/09-localhost/types/localhost_test.go b/modules/light-clients/09-localhost/types/localhost_test.go index ee8507c4efc..cb80d5ba424 100644 --- a/modules/light-clients/09-localhost/types/localhost_test.go +++ b/modules/light-clients/09-localhost/types/localhost_test.go @@ -17,9 +17,7 @@ const ( height = 4 ) -var ( - clientHeight = clienttypes.NewHeight(0, 10) -) +var clientHeight = clienttypes.NewHeight(0, 10) type LocalhostTestSuite struct { suite.Suite diff --git a/testing/coordinator.go b/testing/coordinator.go index 4c0ebc78463..dde3eb56b1a 100644 --- a/testing/coordinator.go +++ b/testing/coordinator.go @@ -181,7 +181,6 @@ func GetChainID(index int) string { // CONTRACT: the passed in list of indexes must not contain duplicates func (coord *Coordinator) CommitBlock(chains ...*TestChain) { for _, chain := range chains { - chain.NextBlock() } coord.IncrementTime() diff --git a/testing/events.go b/testing/events.go index 7828b42619f..8beaa0a2beb 100644 --- a/testing/events.go +++ b/testing/events.go @@ -64,7 +64,6 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { if ev.Type == channeltypes.EventTypeSendPacket { packet := channeltypes.Packet{} for _, attr := range ev.Attributes { - switch string(attr.Key) { case channeltypes.AttributeKeyData: packet.Data = attr.Value diff --git a/testing/mock/ibc_module_test.go b/testing/mock/ibc_module_test.go index d3efe9f142c..b36d58d2004 100644 --- a/testing/mock/ibc_module_test.go +++ b/testing/mock/ibc_module_test.go @@ -2,7 +2,7 @@ package mock_test import ( "testing" - + "github.com/stretchr/testify/require" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" diff --git a/testing/simapp/ante_handler.go b/testing/simapp/ante_handler.go index 04ffad13e2a..5d32e9199bb 100644 --- a/testing/simapp/ante_handler.go +++ b/testing/simapp/ante_handler.go @@ -28,7 +28,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") } - var sigGasConsumer = options.SigGasConsumer + sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { sigGasConsumer = ante.DefaultSigVerificationGasConsumer } diff --git a/testing/simapp/app.go b/testing/simapp/app.go index f707ba6087b..b09cf6dffb7 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -473,7 +473,7 @@ func NewSimApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. diff --git a/testing/simapp/params/amino.go b/testing/simapp/params/amino.go index 440c29f817e..0d43dd1eb8f 100644 --- a/testing/simapp/params/amino.go +++ b/testing/simapp/params/amino.go @@ -1,3 +1,4 @@ +//go:build test_amino // +build test_amino package params diff --git a/testing/simapp/params/proto.go b/testing/simapp/params/proto.go index 04aa524b900..a752d107907 100644 --- a/testing/simapp/params/proto.go +++ b/testing/simapp/params/proto.go @@ -1,3 +1,4 @@ +//go:build !test_amino // +build !test_amino package params diff --git a/testing/simapp/sim_test.go b/testing/simapp/sim_test.go index bbc8f4a8c0c..12c96755aca 100644 --- a/testing/simapp/sim_test.go +++ b/testing/simapp/sim_test.go @@ -163,11 +163,13 @@ func TestAppImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, - {app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], + { + app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], [][]byte{ stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, stakingtypes.HistoricalInfoKey, - }}, // ordering may change but it doesn't matter + }, + }, // ordering may change but it doesn't matter {app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}}, {app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}}, {app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}}, diff --git a/testing/simapp/simd/cmd/genaccounts_test.go b/testing/simapp/simd/cmd/genaccounts_test.go index 0cdf365bf93..c7c2f92682c 100644 --- a/testing/simapp/simd/cmd/genaccounts_test.go +++ b/testing/simapp/simd/cmd/genaccounts_test.go @@ -73,7 +73,8 @@ func TestAddGenesisAccountCmd(t *testing.T) { cmd.SetArgs([]string{ tc.addr, tc.denom, - fmt.Sprintf("--%s=home", flags.FlagHome)}) + fmt.Sprintf("--%s=home", flags.FlagHome), + }) if tc.expectErr { require.Error(t, cmd.ExecuteContext(ctx)) diff --git a/testing/simapp/simd/cmd/root.go b/testing/simapp/simd/cmd/root.go index e690093709e..e130cb16a32 100644 --- a/testing/simapp/simd/cmd/root.go +++ b/testing/simapp/simd/cmd/root.go @@ -279,8 +279,8 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a // and exports state. func (a appCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { - + appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { var simApp *simapp.SimApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { diff --git a/testing/simapp/simd/cmd/testnet.go b/testing/simapp/simd/cmd/testnet.go index 019f534183b..657393fa915 100644 --- a/testing/simapp/simd/cmd/testnet.go +++ b/testing/simapp/simd/cmd/testnet.go @@ -93,7 +93,7 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 // Initialize the testnet func InitTestnet( @@ -112,7 +112,6 @@ func InitTestnet( algoStr string, numValidators int, ) error { - if chainID == "" { chainID = "chain-" + tmrand.NewRand().Str(6) } @@ -269,7 +268,6 @@ func initGenFiles( genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.JSONCodec) // set the accounts in the genesis state @@ -316,7 +314,6 @@ func collectGenFiles( nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { - var appState json.RawMessage genTime := tmtime.Now() @@ -385,12 +382,12 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = tmos.WriteFile(file, contents, 0644) + err = tmos.WriteFile(file, contents, 0o644) if err != nil { return err } diff --git a/testing/simapp/state.go b/testing/simapp/state.go index 86f20e2b115..c0a9e2ea1ec 100644 --- a/testing/simapp/state.go +++ b/testing/simapp/state.go @@ -28,7 +28,6 @@ import ( func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config, ) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) { - if FlagGenesisTimeValue == 0 { genesisTimestamp = simtypes.RandTimestamp(r) } else { diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 1df1714d8a7..8f76c8507ab 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -240,7 +240,6 @@ 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, ) (sdk.GasInfo, *sdk.Result, error) { - tx, err := helpers.GenTx( txCfg, msgs, diff --git a/testing/simapp/utils.go b/testing/simapp/utils.go index 9abfc060b94..51788f5a322 100644 --- a/testing/simapp/utils.go +++ b/testing/simapp/utils.go @@ -84,7 +84,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0600); err != nil { + if err := ioutil.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0o600); err != nil { return err } } @@ -96,7 +96,7 @@ func CheckExportSimulation( return err } - if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0600); err != nil { + if err := ioutil.WriteFile(config.ExportParamsPath, paramsBz, 0o600); err != nil { return err } }