From 554408d407b58b7357d6e9c0f140918128374d98 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Wed, 2 Apr 2025 01:22:17 +0300 Subject: [PATCH 01/10] chore: modernize on the whole repo --- e2e/relayer/relayer.go | 12 +++++----- e2e/testsuite/testconfig.go | 24 +++++++++---------- e2e/testsuite/testsuite.go | 6 ++--- e2e/testsuite/tx.go | 2 +- .../controller/ibc_middleware.go | 2 +- .../controller/types/params_legacy.go | 2 +- .../27-interchain-accounts/host/ibc_module.go | 2 +- .../host/keeper/keeper.go | 4 ++-- .../host/types/params_legacy.go | 4 ++-- .../apps/27-interchain-accounts/types/keys.go | 8 +++---- .../27-interchain-accounts/types/packet.go | 4 ++-- .../types/packet_test.go | 6 ++--- modules/apps/callbacks/ibc_middleware.go | 2 +- modules/apps/callbacks/ibc_middleware_test.go | 6 ++--- .../apps/callbacks/sonar-project.properties | 14 ----------- modules/apps/callbacks/testing/simapp/app.go | 5 ++-- modules/apps/callbacks/types/callbacks.go | 15 +++++------- .../apps/callbacks/types/callbacks_test.go | 6 ++--- modules/apps/callbacks/types/export_test.go | 4 ++-- .../apps/callbacks/v2/ibc_middleware_test.go | 4 ++-- modules/apps/callbacks/v2/v2_test.go | 2 +- modules/apps/transfer/ibc_module.go | 2 +- modules/apps/transfer/ibc_module_test.go | 2 +- modules/apps/transfer/keeper/keeper_test.go | 2 +- modules/apps/transfer/keeper/migrations.go | 2 +- modules/apps/transfer/types/keys.go | 2 +- modules/apps/transfer/types/packet.go | 8 +++---- modules/apps/transfer/types/packet_test.go | 12 +++++----- modules/apps/transfer/types/params_legacy.go | 2 +- .../transfer/types/transfer_authorization.go | 4 ++-- modules/apps/transfer/v2/ibc_module.go | 2 +- modules/core/02-client/abci_test.go | 2 +- modules/core/02-client/keeper/grpc_query.go | 4 ++-- modules/core/02-client/keeper/keeper.go | 2 +- modules/core/02-client/keeper/keeper_test.go | 2 +- .../02-client/migrations/v7/genesis_test.go | 4 ++-- .../02-client/migrations/v7/store_test.go | 2 +- modules/core/02-client/types/params_legacy.go | 2 +- modules/core/02-client/types/store.go | 2 +- .../core/03-connection/types/params_legacy.go | 2 +- .../core/04-channel/keeper/grpc_query_test.go | 6 ++--- .../core/04-channel/migrations/v10/store.go | 8 +++---- .../04-channel/migrations/v10/store_test.go | 2 +- modules/core/04-channel/types/keys.go | 2 +- .../04-channel/v2/keeper/grpc_query_test.go | 8 +++---- modules/core/04-channel/v2/types/merkle.go | 3 ++- modules/core/05-port/types/module.go | 2 +- modules/core/24-host/channel_keys.go | 2 +- modules/core/24-host/client_keys.go | 6 ++--- modules/core/24-host/connection_keys.go | 2 +- modules/core/24-host/packet_keys.go | 18 +++++++------- modules/core/24-host/v2/packet_keys.go | 2 +- modules/core/api/module.go | 2 +- modules/core/exported/packet.go | 2 +- modules/core/keeper/keeper.go | 2 +- modules/core/migrations/v7/genesis_test.go | 2 +- .../06-solomachine/solomachine.go | 2 +- .../migrations/migrations_test.go | 4 ++-- .../07-tendermint/proposal_handle_test.go | 2 +- .../08-wasm/blsverifier/handler.go | 2 +- .../08-wasm/keeper/msg_server_test.go | 2 +- .../08-wasm/testing/simapp/app.go | 5 ++-- .../08-wasm/testing/simapp/simd/cmd/root.go | 2 +- simapp/app.go | 5 ++-- simapp/simd/cmd/root.go | 2 +- testing/mock/ibc_module.go | 2 +- testing/mock/v2/ibc_module.go | 2 +- testing/simapp/app.go | 5 ++-- testing/utils.go | 2 +- 69 files changed, 140 insertions(+), 160 deletions(-) delete mode 100644 modules/apps/callbacks/sonar-project.properties diff --git a/e2e/relayer/relayer.go b/e2e/relayer/relayer.go index 6ce4536d754..cb02f0d3a83 100644 --- a/e2e/relayer/relayer.go +++ b/e2e/relayer/relayer.go @@ -62,12 +62,12 @@ func ApplyPacketFilter(ctx context.Context, t *testing.T, r ibc.Relayer, chainID return nil } - return modifyHermesConfigFile(ctx, h, func(config map[string]interface{}) error { - chains, ok := config["chains"].([]map[string]interface{}) + return modifyHermesConfigFile(ctx, h, func(config map[string]any) error { + chains, ok := config["chains"].([]map[string]any) if !ok { return errors.New("failed to get chains from hermes config") } - var chain map[string]interface{} + var chain map[string]any for _, c := range chains { if c["id"] == chainID { chain = c @@ -97,7 +97,7 @@ func ApplyPacketFilter(ctx context.Context, t *testing.T, r ibc.Relayer, chainID channelEndpoints = append(channelEndpoints, []string{"ica*", "*"}) // we explicitly override the full list, this allows this function to provide a complete set of channels to watch. - chain["packet_filter"] = map[string]interface{}{ + chain["packet_filter"] = map[string]any{ "policy": "allow", "list": channelEndpoints, } @@ -107,13 +107,13 @@ func ApplyPacketFilter(ctx context.Context, t *testing.T, r ibc.Relayer, chainID } // modifyHermesConfigFile reads the hermes config file, applies a modification function and returns an error if any. -func modifyHermesConfigFile(ctx context.Context, h *hermes.Relayer, modificationFn func(map[string]interface{}) error) error { +func modifyHermesConfigFile(ctx context.Context, h *hermes.Relayer, modificationFn func(map[string]any) error) error { bz, err := h.ReadFileFromHomeDir(ctx, relativeHermesConfigFilePath) if err != nil { return fmt.Errorf("failed to read hermes config file: %w", err) } - var config map[string]interface{} + var config map[string]any if err := toml.Unmarshal(bz, &config); err != nil { return errors.New("failed to unmarshal hermes config bytes") } diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index c62ba2f9e0b..5673d9ca386 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -786,13 +786,13 @@ func defaultGovv1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([] func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([]byte, error) { const appStateKey = "app_state" return func(chainConfig ibc.ChainConfig, genbz []byte) ([]byte, error) { - genesisDocMap := map[string]interface{}{} + genesisDocMap := map[string]any{} err := json.Unmarshal(genbz, &genesisDocMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal genesis bytes into genesis doc: %w", err) } - appStateMap, ok := genesisDocMap[appStateKey].(map[string]interface{}) + appStateMap, ok := genesisDocMap[appStateKey].(map[string]any) if !ok { return nil, errors.New("failed to extract to app_state") } @@ -807,7 +807,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte return nil, err } - govModuleGenesisMap := map[string]interface{}{} + govModuleGenesisMap := map[string]any{} err = json.Unmarshal(govModuleGenesisBytes, &govModuleGenesisMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err) @@ -824,7 +824,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte return nil, err } - ibcModuleGenesisMap := map[string]interface{}{} + ibcModuleGenesisMap := map[string]any{} err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err) @@ -843,7 +843,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte return nil, err } - ibcModuleGenesisMap := map[string]interface{}{} + ibcModuleGenesisMap := map[string]any{} err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err) @@ -863,7 +863,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte return nil, err } - ibcModuleGenesisMap := map[string]interface{}{} + ibcModuleGenesisMap := map[string]any{} err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err) @@ -882,7 +882,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte return nil, err } - ibcModuleGenesisMap := map[string]interface{}{} + ibcModuleGenesisMap := map[string]any{} err = json.Unmarshal(ibcGenesisBytes, &ibcModuleGenesisMap) if err != nil { return nil, fmt.Errorf("failed to unmarshal gov genesis bytes into map: %w", err) @@ -977,14 +977,14 @@ func modifyClientGenesisAppState(ibcAppState []byte) ([]byte, error) { // modifyChannelGenesisAppState takes the existing ibc app state, unmarshals it to a map and removes the `params` entry from ibc channel genesis. // It marshals and returns the ibc GenesisState JSON map as bytes. func modifyChannelGenesisAppState(ibcAppState []byte) ([]byte, error) { - var ibcGenesisMap map[string]interface{} + var ibcGenesisMap map[string]any if err := json.Unmarshal(ibcAppState, &ibcGenesisMap); err != nil { return nil, err } - var channelGenesis map[string]interface{} + var channelGenesis map[string]any // be ashamed, be very ashamed - channelGenesis, ok := ibcGenesisMap["channel_genesis"].(map[string]interface{}) + channelGenesis, ok := ibcGenesisMap["channel_genesis"].(map[string]any) if !ok { return nil, fmt.Errorf("can't convert IBC genesis map entry into type %T", &channelGenesis) } @@ -994,7 +994,7 @@ func modifyChannelGenesisAppState(ibcAppState []byte) ([]byte, error) { } func modifyChannelV2GenesisAppState(ibcAppState []byte) ([]byte, error) { - var ibcGenesisMap map[string]interface{} + var ibcGenesisMap map[string]any if err := json.Unmarshal(ibcAppState, &ibcGenesisMap); err != nil { return nil, err } @@ -1004,7 +1004,7 @@ func modifyChannelV2GenesisAppState(ibcAppState []byte) ([]byte, error) { } func modifyClientV2GenesisAppState(ibcAppState []byte) ([]byte, error) { - var ibcGenesisMap map[string]interface{} + var ibcGenesisMap map[string]any if err := json.Unmarshal(ibcAppState, &ibcGenesisMap); err != nil { return nil, err } diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 7578635e5d2..efd68462325 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -153,7 +153,7 @@ func (s *E2ETestSuite) configureGenesisDebugExport() { // if the above issue is resolved, it should be possible to lazily create relayers in each test. func (s *E2ETestSuite) initializeRelayerPool(n int) []ibc.Relayer { var relayers []ibc.Relayer - for i := 0; i < n; i++ { + for range n { relayers = append(relayers, relayer.New(s.T(), *LoadConfig().GetActiveRelayerConfig(), s.logger, s.DockerClient, s.network)) } return relayers @@ -217,7 +217,7 @@ func (s *E2ETestSuite) CreatePaths(clientOpts ibc.CreateClientOptions, channelOp ctx := context.TODO() allChains := s.GetAllChains() - for i := 0; i < len(allChains)-1; i++ { + for i := range len(allChains) - 1 { chainA, chainB := allChains[i], allChains[i+1] s.CreatePath(ctx, r, chainA, chainB, clientOpts, channelOpts, testName) } @@ -383,7 +383,7 @@ func (s *E2ETestSuite) newInterchain(relayers []ibc.Relayer, chains []ibc.Chain, // - chainA and chainB // - chainB and chainC // - chainC and chainD etc - for i := 0; i < len(chains)-1; i++ { + for i := range len(chains) - 1 { pathName := s.generatePathName() channelOpts := DefaultChannelOpts(chains) chain1, chain2 := chains[i], chains[i+1] diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index d969dfdbf0c..ebe598b5ff2 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -83,7 +83,7 @@ func (s *E2ETestSuite) retryNtimes(f func() (sdk.TxResponse, error), attempts in var resp sdk.TxResponse var err error // If the response's raw log doesn't contain any of the allowed prefixes we return, else, we retry. - for i := 0; i < attempts; i++ { + for range attempts { resp, err = f() if err != nil { return sdk.TxResponse{}, err diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go index ff5c22579d6..99a7ae2d80f 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go @@ -265,7 +265,7 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into an InterchainAccountPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { +func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) { var data icatypes.InterchainAccountPacketData err := data.UnmarshalJSON(bz) if err != nil { diff --git a/modules/apps/27-interchain-accounts/controller/types/params_legacy.go b/modules/apps/27-interchain-accounts/controller/types/params_legacy.go index 1dac915bdeb..c6c3ba61d50 100644 --- a/modules/apps/27-interchain-accounts/controller/types/params_legacy.go +++ b/modules/apps/27-interchain-accounts/controller/types/params_legacy.go @@ -27,7 +27,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -func validateEnabledTypeLegacy(i interface{}) error { +func validateEnabledTypeLegacy(i any) error { _, ok := i.(bool) if !ok { return fmt.Errorf("invalid parameter type: %T", i) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index 476752afc68..484fc1b451e 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -159,7 +159,7 @@ func (IBCModule) OnTimeoutPacket( // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into an InterchainAccountPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { +func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) { var data icatypes.InterchainAccountPacketData err := data.UnmarshalJSON(bz) if err != nil { diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper.go b/modules/apps/27-interchain-accounts/host/keeper/keeper.go index ef1ffe5eb35..466206933cb 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper.go @@ -266,7 +266,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { func newModuleQuerySafeAllowList() []string { allowList := []string{} gogoproto.GogoResolver.RangeFiles(func(fd protoreflect.FileDescriptor) bool { - for i := 0; i < fd.Services().Len(); i++ { + for i := range fd.Services().Len() { // Get the service descriptor sd := fd.Services().Get(i) @@ -281,7 +281,7 @@ func newModuleQuerySafeAllowList() []string { } } - for j := 0; j < sd.Methods().Len(); j++ { + for j := range sd.Methods().Len() { // Get the method descriptor md := sd.Methods().Get(j) diff --git a/modules/apps/27-interchain-accounts/host/types/params_legacy.go b/modules/apps/27-interchain-accounts/host/types/params_legacy.go index 8e8a95143e8..ecf879d2ff0 100644 --- a/modules/apps/27-interchain-accounts/host/types/params_legacy.go +++ b/modules/apps/27-interchain-accounts/host/types/params_legacy.go @@ -34,7 +34,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -func validateEnabledType(i interface{}) error { +func validateEnabledType(i any) error { _, ok := i.(bool) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -43,7 +43,7 @@ func validateEnabledType(i interface{}) error { return nil } -func validateAllowlistLegacy(i interface{}) error { +func validateAllowlistLegacy(i any) error { allowMsgs, ok := i.([]string) if !ok { return fmt.Errorf("invalid parameter type: %T", i) diff --git a/modules/apps/27-interchain-accounts/types/keys.go b/modules/apps/27-interchain-accounts/types/keys.go index ddd21716c61..5638761c263 100644 --- a/modules/apps/27-interchain-accounts/types/keys.go +++ b/modules/apps/27-interchain-accounts/types/keys.go @@ -49,20 +49,20 @@ var ( // KeyActiveChannel creates and returns a new key used for active channels store operations func KeyActiveChannel(portID, connectionID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", ActiveChannelKeyPrefix, portID, connectionID)) + return fmt.Appendf(nil, "%s/%s/%s", ActiveChannelKeyPrefix, portID, connectionID) } // KeyOwnerAccount creates and returns a new key used for interchain account store operations func KeyOwnerAccount(portID, connectionID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", OwnerKeyPrefix, portID, connectionID)) + return fmt.Appendf(nil, "%s/%s/%s", OwnerKeyPrefix, portID, connectionID) } // KeyPort creates and returns a new key used for port store operations func KeyPort(portID string) []byte { - return []byte(fmt.Sprintf("%s/%s", PortKeyPrefix, portID)) + return fmt.Appendf(nil, "%s/%s", PortKeyPrefix, portID) } // KeyIsMiddlewareEnabled creates and returns a new key used for signaling legacy API callback routing via ibc middleware func KeyIsMiddlewareEnabled(portID, connectionID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", IsMiddlewareEnabledPrefix, portID, connectionID)) + return fmt.Appendf(nil, "%s/%s/%s", IsMiddlewareEnabledPrefix, portID, connectionID) } diff --git a/modules/apps/27-interchain-accounts/types/packet.go b/modules/apps/27-interchain-accounts/types/packet.go index 00592760a4d..332660f5954 100644 --- a/modules/apps/27-interchain-accounts/types/packet.go +++ b/modules/apps/27-interchain-accounts/types/packet.go @@ -79,12 +79,12 @@ func (InterchainAccountPacketData) GetPacketSender(sourcePortID string) string { // GetCustomPacketData interprets the memo field of the packet data as a JSON object // and returns the value associated with the given key. // If the key is missing or the memo is not properly formatted, then nil is returned. -func (iapd InterchainAccountPacketData) GetCustomPacketData(key string) interface{} { +func (iapd InterchainAccountPacketData) GetCustomPacketData(key string) any { if len(iapd.Memo) == 0 { return nil } - jsonObject := make(map[string]interface{}) + jsonObject := make(map[string]any) err := json.Unmarshal([]byte(iapd.Memo), &jsonObject) if err != nil { return nil diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index 047179e35eb..30de76101bf 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -122,7 +122,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { testCases := []struct { name string packetData types.InterchainAccountPacketData - expCustomData interface{} + expCustomData any }{ { "success: src_callback key in memo", @@ -131,7 +131,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { Data: []byte("data"), Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, expCallbackAddr), }, - map[string]interface{}{ + map[string]any{ "address": expCallbackAddr, }, }, @@ -142,7 +142,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { Data: []byte("data"), Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, expCallbackAddr), }, - map[string]interface{}{ + map[string]any{ "address": expCallbackAddr, "gas_limit": "200000", }, diff --git a/modules/apps/callbacks/ibc_middleware.go b/modules/apps/callbacks/ibc_middleware.go index 723b5edf16b..3c5e84be64d 100644 --- a/modules/apps/callbacks/ibc_middleware.go +++ b/modules/apps/callbacks/ibc_middleware.go @@ -361,6 +361,6 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) // UnmarshalPacketData defers to the underlying app to unmarshal the packet data. // This function implements the optional PacketDataUnmarshaler interface. -func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { +func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) { return im.app.UnmarshalPacketData(ctx, portID, channelID, bz) } diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 7f970e729ac..2667537eb46 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -100,7 +100,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { malleate func() callbackType types.CallbackType expPanic bool - expValue interface{} + expValue any }{ { "success", @@ -417,7 +417,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { name string malleate func() expResult expResult - expValue interface{} + expValue any }{ { "success", @@ -869,7 +869,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() { name string malleate func() expPanic bool - expValue interface{} + expValue any }{ { "success", diff --git a/modules/apps/callbacks/sonar-project.properties b/modules/apps/callbacks/sonar-project.properties deleted file mode 100644 index 15684f17c39..00000000000 --- a/modules/apps/callbacks/sonar-project.properties +++ /dev/null @@ -1,14 +0,0 @@ -sonar.projectKey=ibc-go-callbacks -sonar.organization=cosmos - -sonar.projectName=ibc-go - Callbacks -sonar.project.monorepo.enabled=true - -sonar.sources=. -sonar.exclusions=**/*_test.go -sonar.tests=. -sonar.test.inclusions=**/*_test.go -sonar.go.coverage.reportPaths=coverage.out - -sonar.sourceEncoding=UTF-8 -sonar.scm.provider=git \ No newline at end of file diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index ac6b182ba40..73ad86251b2 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -100,6 +100,7 @@ import ( solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" + "maps" ) const appName = "SimApp" @@ -820,9 +821,7 @@ func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Conf // NOTE: This is solely to be used for testing purposes. func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } + maps.Copy(dupMaccPerms, maccPerms) return dupMaccPerms } diff --git a/modules/apps/callbacks/types/callbacks.go b/modules/apps/callbacks/types/callbacks.go index 55873e2d37a..edb7b1e7ba1 100644 --- a/modules/apps/callbacks/types/callbacks.go +++ b/modules/apps/callbacks/types/callbacks.go @@ -113,7 +113,7 @@ func GetDestCallbackData( // The addressGetter and gasLimitGetter functions are used to retrieve the callback // address and gas limit from the callback data. func GetCallbackData( - packetData interface{}, + packetData any, version, srcPortID string, remainingGas, maxGas uint64, callbackKey string, @@ -123,7 +123,7 @@ func GetCallbackData( return CallbackData{}, false, ErrNotPacketDataProvider } - callbackData, ok := packetDataProvider.GetCustomPacketData(callbackKey).(map[string]interface{}) + callbackData, ok := packetDataProvider.GetCustomPacketData(callbackKey).(map[string]any) if callbackData == nil || !ok { return CallbackData{}, false, ErrCallbackKeyNotFound } @@ -155,7 +155,7 @@ func GetCallbackData( }, true, nil } -func computeExecAndCommitGasLimit(callbackData map[string]interface{}, remainingGas, maxGas uint64) (uint64, uint64) { +func computeExecAndCommitGasLimit(callbackData map[string]any, remainingGas, maxGas uint64) (uint64, uint64) { // get the gas limit from the callback data commitGasLimit := getUserDefinedGasLimit(callbackData) @@ -166,10 +166,7 @@ func computeExecAndCommitGasLimit(callbackData map[string]interface{}, remaining // account for the remaining gas in the context being less than the desired gas limit for the callback execution // in this case, the callback execution may be retried upon failure - executionGasLimit := commitGasLimit - if remainingGas < executionGasLimit { - executionGasLimit = remainingGas - } + executionGasLimit := min(remainingGas, commitGasLimit) return executionGasLimit, commitGasLimit } @@ -182,7 +179,7 @@ func computeExecAndCommitGasLimit(callbackData map[string]interface{}, remaining // { "{callbackKey}": { ... , "gas_limit": {stringForCallback} } // // Note: the user defined gas limit must be set as a string and not a json number. -func getUserDefinedGasLimit(callbackData map[string]interface{}) uint64 { +func getUserDefinedGasLimit(callbackData map[string]any) uint64 { // the gas limit must be specified as a string and not a json number gasLimit, ok := callbackData[UserDefinedGasLimitKey].(string) if !ok { @@ -206,7 +203,7 @@ func getUserDefinedGasLimit(callbackData map[string]interface{}) uint64 { // // ADR-8 middleware should callback on the returned address if it is a PacketActor // (i.e. smart contract that accepts IBC callbacks). -func getCallbackAddress(callbackData map[string]interface{}) string { +func getCallbackAddress(callbackData map[string]any) string { callbackAddress, ok := callbackData[CallbackAddressKey].(string) if !ok { return "" diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index edf7a2c348b..0ff3139df13 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -23,7 +23,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { var ( sender = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() receiver = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - packetData interface{} + packetData any remainingGas uint64 callbackKey string version string @@ -592,7 +592,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]interface{}) + callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) s.Require().Equal(tc.expAddress, types.GetCallbackAddress(callbackData), tc.name) }) @@ -714,7 +714,7 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]interface{}) + callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) s.Require().Equal(tc.expUserGas, types.GetUserDefinedGasLimit(callbackData), tc.name) }) diff --git a/modules/apps/callbacks/types/export_test.go b/modules/apps/callbacks/types/export_test.go index 5b0a32508e3..382ff6e6231 100644 --- a/modules/apps/callbacks/types/export_test.go +++ b/modules/apps/callbacks/types/export_test.go @@ -5,11 +5,11 @@ package types */ // GetCallbackAddress is a wrapper around getCallbackAddress to allow the function to be directly called in tests. -func GetCallbackAddress(callbackData map[string]interface{}) string { +func GetCallbackAddress(callbackData map[string]any) string { return getCallbackAddress(callbackData) } // GetUserDefinedGasLimit is a wrapper around getUserDefinedGasLimit to allow the function to be directly called in tests. -func GetUserDefinedGasLimit(callbackData map[string]interface{}) uint64 { +func GetUserDefinedGasLimit(callbackData map[string]any) uint64 { return getUserDefinedGasLimit(callbackData) } diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 991fda4bf01..0087ff5937f 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -105,7 +105,7 @@ func (s *CallbacksTestSuite) TestSendPacket() { malleate func() callbackType types.CallbackType expPanic bool - expValue interface{} + expValue any }{ { "success", @@ -403,7 +403,7 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { name string malleate func() expResult expResult - expValue interface{} + expValue any }{ { "success", diff --git a/modules/apps/callbacks/v2/v2_test.go b/modules/apps/callbacks/v2/v2_test.go index 8e65987dcb9..f28a583353a 100644 --- a/modules/apps/callbacks/v2/v2_test.go +++ b/modules/apps/callbacks/v2/v2_test.go @@ -144,7 +144,7 @@ func (s *CallbacksTestSuite) AssertCallbackCounters(callbackType types.CallbackT // GetExpectedEvent returns the expected event for a callback. func GetExpectedEvent( - ctx sdk.Context, packetData interface{}, remainingGas uint64, version string, + ctx sdk.Context, packetData any, remainingGas uint64, version string, eventPortID, eventChannelID string, seq uint64, callbackType types.CallbackType, expError error, ) (abci.Event, bool) { callbackKey := types.SourceCallbackKey diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index b782b830957..54f6bcd1ed3 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -271,7 +271,7 @@ func (im IBCModule) OnTimeoutPacket( // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into a FungibleTokenPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { +func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) { ics20Version, found := im.keeper.GetICS4Wrapper().GetAppVersion(ctx, portID, channelID) if !found { return types.InternalTransferRepresentation{}, "", errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index d260fe2bc77..b521b766361 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -578,7 +578,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { receiver = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() data []byte - initialPacketData interface{} + initialPacketData any ) testCases := []struct { diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index 2659292f9da..4457af9bd5d 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -257,7 +257,7 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() { amount := sdkmath.ZeroInt() bz := cdc.MustMarshal(&sdk.IntProto{Int: amount}) - store.Set([]byte(fmt.Sprintf("wrong-prefix/%s", denom)), bz) + store.Set(fmt.Appendf(nil, "wrong-prefix/%s", denom), bz) }, false, }, diff --git a/modules/apps/transfer/keeper/migrations.go b/modules/apps/transfer/keeper/migrations.go index 4110a4ef2da..3c1c9bbd3d7 100644 --- a/modules/apps/transfer/keeper/migrations.go +++ b/modules/apps/transfer/keeper/migrations.go @@ -105,7 +105,7 @@ func (m Migrator) MigrateDenomTraceToDenom(ctx sdk.Context) error { return fmt.Errorf("length of denoms does not match length of denom traces, %d != %d", len(denoms), len(denomTraces)) } - for i := 0; i < len(denoms); i++ { + for i := range denoms { m.keeper.SetDenom(ctx, denoms[i]) m.keeper.deleteDenomTrace(ctx, denomTraces[i]) } diff --git a/modules/apps/transfer/types/keys.go b/modules/apps/transfer/types/keys.go index a0226f28cb2..5b632c9d3f8 100644 --- a/modules/apps/transfer/types/keys.go +++ b/modules/apps/transfer/types/keys.go @@ -73,5 +73,5 @@ func GetEscrowAddress(portID, channelID string) sdk.AccAddress { // TotalEscrowForDenomKey returns the store key of under which the total amount of // source chain tokens in escrow is stored. func TotalEscrowForDenomKey(denom string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyTotalEscrowPrefix, denom)) + return fmt.Appendf(nil, "%s/%s", KeyTotalEscrowPrefix, denom) } diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 760eb08b919..e829f6325c4 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -101,12 +101,12 @@ func (ftpd FungibleTokenPacketData) GetPacketSender(sourcePortID string) string // GetCustomPacketData interprets the memo field of the packet data as a JSON object // and returns the value associated with the given key. // If the key is missing or the memo is not properly formatted, then nil is returned. -func (ftpd FungibleTokenPacketData) GetCustomPacketData(key string) interface{} { +func (ftpd FungibleTokenPacketData) GetCustomPacketData(key string) any { if len(ftpd.Memo) == 0 { return nil } - jsonObject := make(map[string]interface{}) + jsonObject := make(map[string]any) err := json.Unmarshal([]byte(ftpd.Memo), &jsonObject) if err != nil { return nil @@ -160,12 +160,12 @@ func (ftpd InternalTransferRepresentation) ValidateBasic() error { // GetCustomPacketData interprets the memo field of the packet data as a JSON object // and returns the value associated with the given key. // If the key is missing or the memo is not properly formatted, then nil is returned. -func (ftpd InternalTransferRepresentation) GetCustomPacketData(key string) interface{} { +func (ftpd InternalTransferRepresentation) GetCustomPacketData(key string) any { if len(ftpd.Memo) == 0 { return nil } - jsonObject := make(map[string]interface{}) + jsonObject := make(map[string]any) err := json.Unmarshal([]byte(ftpd.Memo), &jsonObject) if err != nil { return nil diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 10853d100b8..f643bfb072d 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -70,7 +70,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { testCases := []struct { name string packetData types.FungibleTokenPacketData - expCustomData interface{} + expCustomData any }{ { "success: src_callback key in memo", @@ -81,7 +81,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { Receiver: receiver, Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, receiver), }, - map[string]interface{}{ + map[string]any{ "address": receiver, }, }, @@ -94,7 +94,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { Receiver: receiver, Memo: fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, receiver), }, - map[string]interface{}{ + map[string]any{ "address": receiver, "gas_limit": "200000", }, @@ -376,7 +376,7 @@ func TestPacketDataProvider(t *testing.T) { testCases := []struct { name string packetData types.InternalTransferRepresentation - expCustomData interface{} + expCustomData any }{ { "success: src_callback key in memo", @@ -390,7 +390,7 @@ func TestPacketDataProvider(t *testing.T) { fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, receiver), ), - map[string]interface{}{ + map[string]any{ "address": receiver, }, }, @@ -405,7 +405,7 @@ func TestPacketDataProvider(t *testing.T) { receiver, fmt.Sprintf(`{"src_callback": {"address": "%s", "gas_limit": "200000"}}`, receiver), ), - map[string]interface{}{ + map[string]any{ "address": receiver, "gas_limit": "200000", }, diff --git a/modules/apps/transfer/types/params_legacy.go b/modules/apps/transfer/types/params_legacy.go index 716043c3040..1a2886c54b0 100644 --- a/modules/apps/transfer/types/params_legacy.go +++ b/modules/apps/transfer/types/params_legacy.go @@ -32,7 +32,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -func validateEnabledTypeLegacy(i interface{}) error { +func validateEnabledTypeLegacy(i any) error { _, ok := i.(bool) if !ok { return fmt.Errorf("invalid parameter type: %T", i) diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 753a72f3950..1ddc852f7c6 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -79,7 +79,7 @@ func (a TransferAuthorization) Accept(goCtx context.Context, msg proto.Message) // NOTE: SpendLimit is an array of coins, with each one representing the remaining spend limit for an // individual denomination. if a.Allocations[index].SpendLimit.IsZero() { - a.Allocations = append(a.Allocations[:index], a.Allocations[index+1:]...) + a.Allocations = slices.Delete(a.Allocations, index, index+1) } if len(a.Allocations) == 0 { @@ -127,7 +127,7 @@ func (a TransferAuthorization) ValidateBasic() error { } found := make(map[string]bool, 0) - for i := 0; i < len(allocation.AllowList); i++ { + for i := range allocation.AllowList { if found[allocation.AllowList[i]] { return errorsmod.Wrapf(ErrInvalidAuthorization, "duplicate entry in allow list %s", allocation.AllowList[i]) } diff --git a/modules/apps/transfer/v2/ibc_module.go b/modules/apps/transfer/v2/ibc_module.go index 56f31dc5418..84a54a2c161 100644 --- a/modules/apps/transfer/v2/ibc_module.go +++ b/modules/apps/transfer/v2/ibc_module.go @@ -194,6 +194,6 @@ func (im *IBCModule) OnAcknowledgementPacket(ctx sdk.Context, sourceChannel stri // UnmarshalPacketData unmarshals the ICS20 packet data based on the version and encoding // it implements the PacketDataUnmarshaler interface -func (*IBCModule) UnmarshalPacketData(payload channeltypesv2.Payload) (interface{}, error) { +func (*IBCModule) UnmarshalPacketData(payload channeltypesv2.Payload) (any, error) { return types.UnmarshalPacketData(payload.Value, payload.Version, payload.Encoding) } diff --git a/modules/core/02-client/abci_test.go b/modules/core/02-client/abci_test.go index 959cdac37df..fb9c8c780ff 100644 --- a/modules/core/02-client/abci_test.go +++ b/modules/core/02-client/abci_test.go @@ -39,7 +39,7 @@ func TestClientTestSuite(t *testing.T) { } func (suite *ClientTestSuite) TestBeginBlocker() { - for i := 0; i < 10; i++ { + for range 10 { // increment height suite.coordinator.CommitBlock(suite.chainA, suite.chainB) diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index 40f16b5f34d..98743db1119 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -173,7 +173,7 @@ func (q *queryServer) ConsensusStates(goCtx context.Context, req *types.QueryCon ctx := sdk.UnwrapSDKContext(goCtx) var consensusStates []types.ConsensusStateWithHeight - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, fmt.Appendf(nil, "%s/", host.KeyConsensusStatePrefix))) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { // filter any metadata stored under consensus state key @@ -217,7 +217,7 @@ func (q *queryServer) ConsensusStateHeights(goCtx context.Context, req *types.Qu ctx := sdk.UnwrapSDKContext(goCtx) var consensusStateHeights []types.Height - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) + store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, fmt.Appendf(nil, "%s/", host.KeyConsensusStatePrefix))) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, _ []byte, accumulate bool) (bool, error) { // filter any metadata stored under consensus state key diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index e9475db2050..d49d56b72be 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -419,7 +419,7 @@ func (k *Keeper) GetAllClients(ctx sdk.Context) []exported.ClientState { // ClientStore returns isolated prefix store for each client so they can read/write in separate // namespace without being able to read/write other client's data func (k *Keeper) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore { - clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) + clientPrefix := fmt.Appendf(nil, "%s/%s/", host.KeyClientStorePrefix, clientID) store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) return prefix.NewStore(store, clientPrefix) } diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index e85cb8d137b..4cf07fb0242 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -192,7 +192,7 @@ func (suite *KeeperTestSuite) TestGetAllGenesisMetadata() { types.NewIdentifiedGenesisMetadata( clientA, []types.GenesisMetadata{ - types.NewGenesisMetadata([]byte(fmt.Sprintf("%s/%s", host.KeyClientState, "clientMetadata")), []byte("value")), + types.NewGenesisMetadata(fmt.Appendf(nil, "%s/%s", host.KeyClientState, "clientMetadata"), []byte("value")), types.NewGenesisMetadata(ibctm.ProcessedTimeKey(types.NewHeight(0, 1)), []byte("foo")), types.NewGenesisMetadata(ibctm.ProcessedTimeKey(types.NewHeight(0, 2)), []byte("bar")), types.NewGenesisMetadata(ibctm.ProcessedTimeKey(types.NewHeight(0, 3)), []byte("baz")), diff --git a/modules/core/02-client/migrations/v7/genesis_test.go b/modules/core/02-client/migrations/v7/genesis_test.go index 870fdb18351..bfa2130d231 100644 --- a/modules/core/02-client/migrations/v7/genesis_test.go +++ b/modules/core/02-client/migrations/v7/genesis_test.go @@ -17,7 +17,7 @@ import ( func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { // create tendermint clients - for i := 0; i < 3; i++ { + for range 3 { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() @@ -122,7 +122,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { suite.Require().NoError(err) // Indent the JSON bz correctly. - var jsonObj map[string]interface{} + var jsonObj map[string]any err = json.Unmarshal(bz, &jsonObj) suite.Require().NoError(err) expectedIndentedBz, err := json.MarshalIndent(jsonObj, "", "\t") diff --git a/modules/core/02-client/migrations/v7/store_test.go b/modules/core/02-client/migrations/v7/store_test.go index eadcd0a237f..863a81d37b3 100644 --- a/modules/core/02-client/migrations/v7/store_test.go +++ b/modules/core/02-client/migrations/v7/store_test.go @@ -150,7 +150,7 @@ func (suite *MigrationsV7TestSuite) createLocalhostClients() { clientStore.Set(host.ClientStateKey(), []byte("clientState")) - for i := 0; i < numCreations; i++ { + for i := range numCreations { clientStore.Set(host.ConsensusStateKey(types.NewHeight(1, uint64(i))), []byte("consensusState")) } } diff --git a/modules/core/02-client/types/params_legacy.go b/modules/core/02-client/types/params_legacy.go index c903b49f330..0f699bf640b 100644 --- a/modules/core/02-client/types/params_legacy.go +++ b/modules/core/02-client/types/params_legacy.go @@ -27,7 +27,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -func validateClientsLegacy(i interface{}) error { +func validateClientsLegacy(i any) error { clients, ok := i.([]string) if !ok { return fmt.Errorf("invalid parameter type: %T", i) diff --git a/modules/core/02-client/types/store.go b/modules/core/02-client/types/store.go index 9a07409fe0d..6f2a1737600 100644 --- a/modules/core/02-client/types/store.go +++ b/modules/core/02-client/types/store.go @@ -27,7 +27,7 @@ func NewStoreProvider(storeService corestore.KVStoreService) StoreProvider { // ClientStore returns isolated prefix store for each client so they can read/write in separate namespaces. func (s StoreProvider) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore { - clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) + clientPrefix := fmt.Appendf(nil, "%s/%s/", host.KeyClientStorePrefix, clientID) return prefix.NewStore(runtime.KVStoreAdapter(s.storeService.OpenKVStore(ctx)), clientPrefix) } diff --git a/modules/core/03-connection/types/params_legacy.go b/modules/core/03-connection/types/params_legacy.go index 99f32271e6d..ac022dd1978 100644 --- a/modules/core/03-connection/types/params_legacy.go +++ b/modules/core/03-connection/types/params_legacy.go @@ -27,7 +27,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -func validateParams(i interface{}) error { +func validateParams(i any) error { _, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter. expected %T, got type: %T", uint64(1), i) diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index e14c5892732..849d42f3aa2 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -858,7 +858,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = make([]*types.PacketState, 9) for i := uint64(0); i < 9; i++ { - commitment := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + commitment := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Data) expCommitments[i] = &commitment } @@ -1221,7 +1221,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { var commitments []uint64 for i := uint64(0); i < 100; i++ { - ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data) if i < 10 { // populate the store with 100 and query for 10 specific acks @@ -1248,7 +1248,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { expAcknowledgements = make([]*types.PacketState, 9) for i := uint64(0); i < 9; i++ { - ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i))) + ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data) expAcknowledgements[i] = &ack } diff --git a/modules/core/04-channel/migrations/v10/store.go b/modules/core/04-channel/migrations/v10/store.go index 29f6f5cadf1..c0b4080dd7f 100644 --- a/modules/core/04-channel/migrations/v10/store.go +++ b/modules/core/04-channel/migrations/v10/store.go @@ -27,19 +27,19 @@ const ( // PruningSequenceStartKey returns the store key for the pruning sequence start of a particular channel func PruningSequenceStartKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyPruningSequenceStart, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyPruningSequenceStart, channelPath(portID, channelID)) } func ChannelUpgradeKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradePrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradePrefix, channelPath(portID, channelID)) } func ChannelUpgradeErrorKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID)) } func ChannelCounterpartyUpgradeKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyCounterpartyUpgrade, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s/%s", KeyChannelUpgradePrefix, KeyCounterpartyUpgrade, channelPath(portID, channelID)) } func channelPath(portID, channelID string) string { diff --git a/modules/core/04-channel/migrations/v10/store_test.go b/modules/core/04-channel/migrations/v10/store_test.go index f9e0cd54f5b..0a60a08ad14 100644 --- a/modules/core/04-channel/migrations/v10/store_test.go +++ b/modules/core/04-channel/migrations/v10/store_test.go @@ -78,7 +78,7 @@ func (suite *MigrationsV10TestSuite) TestMigrateStore() { store := storeService.OpenKVStore(ctx) numberOfChannels := 100 - for i := 0; i < numberOfChannels; i++ { + for range numberOfChannels { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.Setup() } diff --git a/modules/core/04-channel/types/keys.go b/modules/core/04-channel/types/keys.go index d4229e29564..51c1c76cf5f 100644 --- a/modules/core/04-channel/types/keys.go +++ b/modules/core/04-channel/types/keys.go @@ -63,5 +63,5 @@ func ParseChannelSequence(channelID string) (uint64, error) { // FilteredPortPrefix returns the prefix key for the given port prefix. func FilteredPortPrefix(portPrefix string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", host.KeyChannelEndPrefix, host.KeyPortPrefix, portPrefix)) + return fmt.Appendf(nil, "%s/%s/%s", host.KeyChannelEndPrefix, host.KeyPortPrefix, portPrefix) } diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index d07fba57031..997a662691e 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -126,7 +126,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments for i := uint64(1); i <= 10; i++ { - pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ClientId, pktStateCommitment.Sequence, pktStateCommitment.Data) expCommitments = append(expCommitments, &pktStateCommitment) } @@ -150,7 +150,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { expCommitments = make([]*types.PacketState, 0, 10) // reset expected commitments for i := uint64(1); i <= 10; i++ { - pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + pktStateCommitment := types.NewPacketState(path.EndpointA.ClientID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), pktStateCommitment.ClientId, pktStateCommitment.Sequence, pktStateCommitment.Data) expCommitments = append(expCommitments, &pktStateCommitment) } @@ -325,7 +325,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { var commitments []uint64 for i := uint64(0); i < 100; i++ { - ack := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + ack := types.NewPacketState(path.EndpointA.ClientID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ClientId, ack.Sequence, ack.Data) if i < 10 { // populate the store with 100 and query for 10 specific acks @@ -351,7 +351,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { expAcknowledgements = make([]*types.PacketState, 0, 10) for i := uint64(1); i <= 10; i++ { - ack := types.NewPacketState(path.EndpointA.ClientID, i, []byte(fmt.Sprintf("hash_%d", i))) + ack := types.NewPacketState(path.EndpointA.ClientID, i, fmt.Appendf(nil, "hash_%d", i)) suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.ClientId, ack.Sequence, ack.Data) expAcknowledgements = append(expAcknowledgements, &ack) } diff --git a/modules/core/04-channel/v2/types/merkle.go b/modules/core/04-channel/v2/types/merkle.go index 68ad501d3ee..06ac34168f1 100644 --- a/modules/core/04-channel/v2/types/merkle.go +++ b/modules/core/04-channel/v2/types/merkle.go @@ -2,6 +2,7 @@ package types import ( commitmenttypesv2 "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" + "slices" ) // BuildMerklePath takes the merkle path prefix and an ICS24 path @@ -13,7 +14,7 @@ func BuildMerklePath(prefix [][]byte, path []byte) commitmenttypesv2.MerklePath } // copy prefix to avoid modifying the original slice - fullPath := append([][]byte(nil), prefix...) + fullPath := slices.Clone(prefix) // append path to last element fullPath[prefixLength-1] = append(fullPath[prefixLength-1], path...) return commitmenttypesv2.NewMerklePath(fullPath...) diff --git a/modules/core/05-port/types/module.go b/modules/core/05-port/types/module.go index c0a67981982..2d2779ad126 100644 --- a/modules/core/05-port/types/module.go +++ b/modules/core/05-port/types/module.go @@ -143,5 +143,5 @@ type PacketDataUnmarshaler interface { // UnmarshalPacketData unmarshals the packet data into a concrete type // ctx, portID, channelID are provided as arguments, so that (if needed) // the packet data can be unmarshaled based on the channel version. - UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) + UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) } diff --git a/modules/core/24-host/channel_keys.go b/modules/core/24-host/channel_keys.go index 40894ac776b..89969892ac9 100644 --- a/modules/core/24-host/channel_keys.go +++ b/modules/core/24-host/channel_keys.go @@ -12,7 +12,7 @@ const ( // ChannelKey returns the store key for a particular channel func ChannelKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID)) } func channelPath(portID, channelID string) string { diff --git a/modules/core/24-host/client_keys.go b/modules/core/24-host/client_keys.go index bd1efe5b0fe..2e4f8214d35 100644 --- a/modules/core/24-host/client_keys.go +++ b/modules/core/24-host/client_keys.go @@ -17,14 +17,14 @@ const ( // FullClientKey returns the full path of specific client path in the format: // "clients/{clientID}/{path}" as a byte array. func FullClientKey(clientID string, path []byte) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyClientStorePrefix, clientID, path)) + return fmt.Appendf(nil, "%s/%s/%s", KeyClientStorePrefix, clientID, path) } // PrefixedClientStoreKey returns a key which can be used for prefixed // key store iteration. The prefix may be a clientType, clientID, or any // valid key prefix which may be concatenated with the client store constant. func PrefixedClientStoreKey(prefix []byte) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyClientStorePrefix, prefix)) + return fmt.Appendf(nil, "%s/%s", KeyClientStorePrefix, prefix) } // FullClientStateKey takes a client identifier and returns a Key under which to store a @@ -48,5 +48,5 @@ func FullConsensusStateKey(clientID string, height exported.Height) []byte { // ConsensusStateKey returns the store key for a the consensus state of a particular // client stored in a client prefixed store. func ConsensusStateKey(height exported.Height) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyConsensusStatePrefix, height)) + return fmt.Appendf(nil, "%s/%s", KeyConsensusStatePrefix, height) } diff --git a/modules/core/24-host/connection_keys.go b/modules/core/24-host/connection_keys.go index bd0b1802ccd..99355f416bc 100644 --- a/modules/core/24-host/connection_keys.go +++ b/modules/core/24-host/connection_keys.go @@ -14,5 +14,5 @@ func ClientConnectionsKey(clientID string) []byte { // ConnectionKey returns the store key for a particular connection func ConnectionKey(connectionID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyConnectionPrefix, connectionID)) + return fmt.Appendf(nil, "%s/%s", KeyConnectionPrefix, connectionID) } diff --git a/modules/core/24-host/packet_keys.go b/modules/core/24-host/packet_keys.go index 1c9e513345d..4d567818d78 100644 --- a/modules/core/24-host/packet_keys.go +++ b/modules/core/24-host/packet_keys.go @@ -19,52 +19,52 @@ const ( // NextSequenceSendKey returns the store key for the send sequence of a particular // channel binded to a specific port. func NextSequenceSendKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyNextSeqSendPrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyNextSeqSendPrefix, channelPath(portID, channelID)) } // NextSequenceRecvKey returns the store key for the receive sequence of a particular // channel binded to a specific port func NextSequenceRecvKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyNextSeqRecvPrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyNextSeqRecvPrefix, channelPath(portID, channelID)) } // NextSequenceAckKey returns the store key for the acknowledgement sequence of // a particular channel binded to a specific port. func NextSequenceAckKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyNextSeqAckPrefix, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyNextSeqAckPrefix, channelPath(portID, channelID)) } // PacketCommitmentKey returns the store key of under which a packet commitment // is stored func PacketCommitmentKey(portID, channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("%s/%d", PacketCommitmentPrefixKey(portID, channelID), sequence)) + return fmt.Appendf(nil, "%s/%d", PacketCommitmentPrefixKey(portID, channelID), sequence) } // PacketCommitmentPrefixKey defines the prefix for commitments to packet data fields store path. func PacketCommitmentPrefixKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), KeySequencePrefix)) + return fmt.Appendf(nil, "%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), KeySequencePrefix) } // PacketAcknowledgementKey returns the store key of under which a packet // acknowledgement is stored func PacketAcknowledgementKey(portID, channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("%s/%d", PacketAcknowledgementPrefixKey(portID, channelID), sequence)) + return fmt.Appendf(nil, "%s/%d", PacketAcknowledgementPrefixKey(portID, channelID), sequence) } // PacketAcknowledgementPrefixKey defines the prefix for commitments to packet data fields store path. func PacketAcknowledgementPrefixKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), KeySequencePrefix)) + return fmt.Appendf(nil, "%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), KeySequencePrefix) } // PacketReceiptKey returns the store key of under which a packet // receipt is stored func PacketReceiptKey(portID, channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence))) + return fmt.Appendf(nil, "%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence)) } // RecvStartSequenceKey returns the store key for the recv start sequence of a particular channel func RecvStartSequenceKey(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s", KeyRecvStartSequence, channelPath(portID, channelID))) + return fmt.Appendf(nil, "%s/%s", KeyRecvStartSequence, channelPath(portID, channelID)) } func sequencePath(sequence uint64) string { diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index 1a0e5d796da..9a811985eff 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -50,5 +50,5 @@ func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { // NextSequenceSendKey returns the store key for the next sequence send of a given channelID. func NextSequenceSendKey(channelID string) []byte { - return []byte(fmt.Sprintf("nextSequenceSend/%s", channelID)) + return fmt.Appendf(nil, "nextSequenceSend/%s", channelID) } diff --git a/modules/core/api/module.go b/modules/core/api/module.go index 4982beef012..b102f35e221 100644 --- a/modules/core/api/module.go +++ b/modules/core/api/module.go @@ -67,5 +67,5 @@ type WriteAcknowledgementWrapper interface { type PacketDataUnmarshaler interface { // UnmarshalPacketData unmarshals the packet data into a concrete type // the payload is provided and the packet data interface is returned - UnmarshalPacketData(payload channeltypesv2.Payload) (interface{}, error) + UnmarshalPacketData(payload channeltypesv2.Payload) (any, error) } diff --git a/modules/core/exported/packet.go b/modules/core/exported/packet.go index f8e6a09ebd6..9f0133c4aa3 100644 --- a/modules/core/exported/packet.go +++ b/modules/core/exported/packet.go @@ -48,5 +48,5 @@ type PacketDataProvider interface { // GetCustomPacketData returns the packet data held on behalf of another application. // The name the information is stored under should be provided as the key. // If no custom packet data exists for the key, nil should be returned. - GetCustomPacketData(key string) interface{} + GetCustomPacketData(key string) any } diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 1785b9273e1..78c4a1e617f 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -96,7 +96,7 @@ func (k *Keeper) GetAuthority() string { // isEmpty checks if the interface is an empty struct or a pointer pointing // to an empty struct -func isEmpty(keeper interface{}) bool { +func isEmpty(keeper any) bool { switch reflect.TypeOf(keeper).Kind() { case reflect.Ptr: if reflect.ValueOf(keeper).Elem().IsZero() { diff --git a/modules/core/migrations/v7/genesis_test.go b/modules/core/migrations/v7/genesis_test.go index 9a66a39a360..8e634e13a4d 100644 --- a/modules/core/migrations/v7/genesis_test.go +++ b/modules/core/migrations/v7/genesis_test.go @@ -45,7 +45,7 @@ func (suite *MigrationsV7TestSuite) SetupTest() { // NOTE: this test is mainly copied from 02-client/migrations/v7/genesis_test.go func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { // create tendermint clients - for i := 0; i < 3; i++ { + for range 3 { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() diff --git a/modules/light-clients/06-solomachine/solomachine.go b/modules/light-clients/06-solomachine/solomachine.go index b68ee7062b2..36986c2b85d 100644 --- a/modules/light-clients/06-solomachine/solomachine.go +++ b/modules/light-clients/06-solomachine/solomachine.go @@ -9,7 +9,7 @@ import ( var _, _, _, _ codectypes.UnpackInterfacesMessage = (*ClientState)(nil), (*ConsensusState)(nil), (*Header)(nil), (*HeaderData)(nil) // Data is an interface used for all the signature data bytes proto definitions. -type Data interface{} +type Data any // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (cs ClientState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { diff --git a/modules/light-clients/07-tendermint/migrations/migrations_test.go b/modules/light-clients/07-tendermint/migrations/migrations_test.go index 395dd3a8b91..2b1c0197361 100644 --- a/modules/light-clients/07-tendermint/migrations/migrations_test.go +++ b/modules/light-clients/07-tendermint/migrations/migrations_test.go @@ -43,7 +43,7 @@ func (suite *MigrationsTestSuite) TestPruneExpiredConsensusStates() { numTMClients := 3 paths := make([]*ibctesting.Path, numTMClients) - for i := 0; i < numTMClients; i++ { + for i := range numTMClients { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() @@ -72,7 +72,7 @@ func (suite *MigrationsTestSuite) TestPruneExpiredConsensusStates() { pruneHeights = append(pruneHeights, path.EndpointA.GetClientLatestHeight()) // these heights will be expired and also pruned - for i := 0; i < 3; i++ { + for range 3 { err := path.EndpointA.UpdateClient() suite.Require().NoError(err) diff --git a/modules/light-clients/07-tendermint/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go index 4a89bcbfb8d..e2893ba87cd 100644 --- a/modules/light-clients/07-tendermint/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/proposal_handle_test.go @@ -111,7 +111,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), substitutePath.EndpointA.ClientID, substituteClientState) // update substitute a few times - for i := 0; i < 3; i++ { + for range 3 { err := substitutePath.EndpointA.UpdateClient() suite.Require().NoError(err) // skip a block diff --git a/modules/light-clients/08-wasm/blsverifier/handler.go b/modules/light-clients/08-wasm/blsverifier/handler.go index b6f474a9915..f793b61e683 100644 --- a/modules/light-clients/08-wasm/blsverifier/handler.go +++ b/modules/light-clients/08-wasm/blsverifier/handler.go @@ -51,7 +51,7 @@ func CustomQuerier() func(sdk.Context, json.RawMessage) ([]byte, error) { } msg := [MessageSize]byte{} - for i := 0; i < MessageSize; i++ { + for i := range MessageSize { msg[i] = customQuery.AggregateVerify.Message[i] } result, err := VerifySignature(customQuery.AggregateVerify.Signature, msg, customQuery.AggregateVerify.PublicKeys) diff --git a/modules/light-clients/08-wasm/keeper/msg_server_test.go b/modules/light-clients/08-wasm/keeper/msg_server_test.go index 20c516c33d0..feff3cddd90 100644 --- a/modules/light-clients/08-wasm/keeper/msg_server_test.go +++ b/modules/light-clients/08-wasm/keeper/msg_server_test.go @@ -351,7 +351,7 @@ func (suite *KeeperTestSuite) TestMsgRemoveChecksum() { expChecksums = []types.Checksum{} - for i := 0; i < 20; i++ { + for i := range 20 { mockCode := wasmtesting.CreateMockContract([]byte{byte(i)}) checksum, err := types.CreateChecksum(mockCode) suite.Require().NoError(err) diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 55b3634eb36..1044fbf9387 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -132,6 +132,7 @@ import ( solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" + "maps" ) const appName = "SimApp" @@ -998,9 +999,7 @@ func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Conf // NOTE: This is solely to be used for testing purposes. func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } + maps.Copy(dupMaccPerms, maccPerms) return dupMaccPerms } diff --git a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go index 4d3800f9be9..37e3e3a120f 100644 --- a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go +++ b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go @@ -160,7 +160,7 @@ func initCometBFTConfig() *cmtcfg.Config { // initAppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. -func initAppConfig() (string, interface{}) { +func initAppConfig() (string, any) { // The following code snippet is just for reference. // WASMConfig defines configuration for the wasm module. diff --git a/simapp/app.go b/simapp/app.go index bb2fe408c0a..0ec256b29ba 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -120,6 +120,7 @@ import ( ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper" solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" + "maps" ) const appName = "SimApp" @@ -847,9 +848,7 @@ func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Conf // NOTE: This is solely to be used for testing purposes. func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } + maps.Copy(dupMaccPerms, maccPerms) return dupMaccPerms } diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 496a129da46..223d3ef46bb 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -158,7 +158,7 @@ func initCometBFTConfig() *cmtcfg.Config { // initAppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. -func initAppConfig() (string, interface{}) { +func initAppConfig() (string, any) { // The following code snippet is just for reference. // WASMConfig defines configuration for the wasm module. diff --git a/testing/mock/ibc_module.go b/testing/mock/ibc_module.go index 25417ec130c..f685e304ad7 100644 --- a/testing/mock/ibc_module.go +++ b/testing/mock/ibc_module.go @@ -144,7 +144,7 @@ func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, channelVersion string, pack // UnmarshalPacketData returns the MockPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { +func (IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (any, string, error) { if reflect.DeepEqual(bz, MockPacketData) { return MockPacketData, Version, nil } diff --git a/testing/mock/v2/ibc_module.go b/testing/mock/v2/ibc_module.go index 4d07f08c622..5e53f7e397b 100644 --- a/testing/mock/v2/ibc_module.go +++ b/testing/mock/v2/ibc_module.go @@ -67,7 +67,7 @@ func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, sourceChannel string, desti return nil } -func (IBCModule) UnmarshalPacketData(payload channeltypesv2.Payload) (interface{}, error) { +func (IBCModule) UnmarshalPacketData(payload channeltypesv2.Payload) (any, error) { if bytes.Equal(payload.Value, mockv1.MockPacketData) { return mockv1.MockPacketData, nil } diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 755f342c3f3..4a65db74115 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -105,6 +105,7 @@ import ( ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" mockv2 "github.com/cosmos/ibc-go/v10/testing/mock/v2" + "maps" ) const appName = "SimApp" @@ -812,9 +813,7 @@ func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Conf // NOTE: This is solely to be used for testing purposes. func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) - for k, v := range maccPerms { - dupMaccPerms[k] = v - } + maps.Copy(dupMaccPerms, maccPerms) return dupMaccPerms } diff --git a/testing/utils.go b/testing/utils.go index 861bb54e1a6..ca90ade4cc1 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -85,7 +85,7 @@ func UnmarshalMsgResponses(cdc codec.Codec, data []byte, msgs ...codec.ProtoMars } // RequireErrorIsOrContains verifies that the passed error is either a target error or contains its error message. -func RequireErrorIsOrContains(t *testing.T, err, targetError error, msgAndArgs ...interface{}) { +func RequireErrorIsOrContains(t *testing.T, err, targetError error, msgAndArgs ...any) { t.Helper() require.Error(t, err) require.True( From 05105fdbd79378ea5d23599d7f1b263f27404c1c Mon Sep 17 00:00:00 2001 From: jike2021 Date: Wed, 2 Apr 2025 11:19:39 +0800 Subject: [PATCH 02/10] chore: update golangci-lint to v2 --- .golangci.yml | 230 +++++++++--------- .../host/keeper/relay_test.go | 18 +- modules/apps/callbacks/testing/simapp/app.go | 4 +- .../apps/callbacks/testing/simapp/export.go | 7 +- .../apps/transfer/keeper/mbt_relay_test.go | 2 +- modules/core/02-client/client/utils/utils.go | 2 +- modules/core/02-client/keeper/keeper_test.go | 2 +- .../core/02-client/v2/keeper/keeper_test.go | 2 +- modules/core/05-port/keeper/keeper_test.go | 2 +- modules/core/genesis_test.go | 2 +- .../07-tendermint/header_test.go | 4 +- .../07-tendermint/misbehaviour.go | 4 +- .../07-tendermint/misbehaviour_handle.go | 6 +- .../07-tendermint/tendermint_test.go | 2 +- .../07-tendermint/update_test.go | 2 +- testing/simapp/app.go | 4 +- 16 files changed, 148 insertions(+), 145 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f65b69e4489..4195e0d6fb5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,133 +1,139 @@ +version: "2" run: tests: true - timeout: 10m - linters: - disable-all: true + default: none enable: - errcheck - - gci - goconst - gocritic - - gofumpt - gosec - - gosimple - govet - ineffassign - misspell - nakedret - revive - staticcheck - - stylecheck - - tenv - thelper - - typecheck - unconvert - # Prefer unparam over revive's unused param. It is more thorough in its checking. - unparam - unused - + settings: + gocritic: + disabled-checks: + - appendAssign + gosec: + excludes: + - G101 + - G107 + - G115 + - G404 + confidence: medium + revive: + enable-all-rules: true + rules: + - name: redundant-import-alias + disabled: true + - name: use-any + disabled: true + - name: if-return + disabled: true + - name: max-public-structs + disabled: true + - name: cognitive-complexity + disabled: true + - name: argument-limit + disabled: true + - name: cyclomatic + disabled: true + - name: file-header + disabled: true + - name: function-length + disabled: true + - name: function-result-limit + disabled: true + - name: line-length-limit + disabled: true + - name: flag-parameter + disabled: true + - name: add-constant + disabled: true + - name: empty-lines + disabled: true + - name: banned-characters + disabled: true + - name: deep-exit + disabled: true + - name: confusing-results + disabled: true + - name: unused-parameter + disabled: true + - name: modifies-value-receiver + disabled: true + - name: early-return + disabled: true + - name: confusing-naming + disabled: true + - name: defer + disabled: true + - name: unused-parameter + disabled: true + - name: unhandled-error + arguments: + - fmt.Printf + - fmt.Print + - fmt.Println + - myFunction + disabled: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - revive + text: differs only by capitalization to method + - linters: + - gosec + text: Use of weak random number generator + - linters: + - gosec + text: 'G115: integer overflow conversion' + - linters: + - staticcheck + text: 'SA1019:' + - linters: + - gosec + text: 'G115: integer overflow conversion' + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - text: "differs only by capitalization to method" - linters: - - revive - - text: "Use of weak random number generator" - linters: - - gosec - - text: "G115: integer overflow conversion" - linters: - - gosec - - linters: - - staticcheck - text: "SA1019:" # silence errors on usage of deprecated funcs - - text: "G115: integer overflow conversion" - linters: - - gosec - max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - gci: - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - blank # blank imports - - dot # dot imports - - prefix(cosmossdk.io) - - prefix(github.com/cosmos/cosmos-sdk) - - prefix(github.com/cometbft/cometbft) - - prefix(github.com/cosmos/ibc-go) - custom-order: true - gocritic: - disabled-checks: - - appendAssign - gosec: - # Available rules: https://github.com/securego/gosec#available-rules - excludes: - - G101 # Potential hardcoded credentials - - G107 # Potential HTTP request made with variable url - - G115 # Integer overflow conversion (used everywhere with int64 -> uint64 block height) - - G404 # Use of weak random number generator (math/rand instead of crypto/rand) - exclude-generated: true - confidence: medium - revive: - enable-all-rules: true - # Do NOT whine about the following, full explanation found in: - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#description-of-available-rules - rules: - - name: redundant-import-alias - disabled: true - - name: use-any - disabled: true - - name: if-return - disabled: true - - name: max-public-structs - disabled: true - - name: cognitive-complexity - disabled: true - - name: argument-limit - disabled: true - - name: cyclomatic - disabled: true - - name: file-header - disabled: true - - name: function-length - disabled: true - - name: function-result-limit - disabled: true - - name: line-length-limit - disabled: true - - name: flag-parameter - disabled: true - - name: add-constant - disabled: true - - name: empty-lines - disabled: true - - name: banned-characters - disabled: true - - name: deep-exit - disabled: true - - name: confusing-results - disabled: true - - name: unused-parameter - disabled: true - - name: modifies-value-receiver - disabled: true - - name: early-return - disabled: true - - name: confusing-naming - disabled: true - - name: defer - disabled: true - # Disabled in favour of unparam. - - name: unused-parameter - disabled: true - - name: unhandled-error - disabled: false - arguments: - - "fmt.Printf" - - "fmt.Print" - - "fmt.Println" - - "myFunction" +formatters: + enable: + - gci + - gofumpt + settings: + gci: + sections: + - standard + - default + - blank + - dot + - prefix(cosmossdk.io) + - prefix(github.com/cosmos/cosmos-sdk) + - prefix(github.com/cometbft/cometbft) + - prefix(github.com/cosmos/ibc-go) + custom-order: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 33b5e7b3c04..eadf92a166f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -590,7 +590,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { }`) // this is the way cosmwasm encodes byte arrays by default // golang doesn't use this encoding by default, but it can still deserialize: - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -615,7 +615,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -644,7 +644,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -677,7 +677,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -718,7 +718,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -752,7 +752,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -768,7 +768,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { "unregistered sdk.Msg", func(icaAddress string) { msgBytes := []byte(`{"messages":[{}]}`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -793,7 +793,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -818,7 +818,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index ac6b182ba40..57f7caaa8cc 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -797,7 +797,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // RegisterTxService implements the Application.RegisterTxService method. func (app *SimApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -805,7 +805,7 @@ func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query, ) diff --git a/modules/apps/callbacks/testing/simapp/export.go b/modules/apps/callbacks/testing/simapp/export.go index c436fb9d775..6ce02a08309 100644 --- a/modules/apps/callbacks/testing/simapp/export.go +++ b/modules/apps/callbacks/testing/simapp/export.go @@ -44,7 +44,7 @@ func (app *SimApp) ExportAppStateAndValidators( AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, err } @@ -52,12 +52,9 @@ func (app *SimApp) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // in favour of export at a block height func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false + applyAllowedAddrs := len(jailAllowedAddrs) > 0 // check if there is an allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } allowedAddrsMap := make(map[string]bool) diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index d3acd335e66..def0d2977b8 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -118,7 +118,7 @@ func AddressFromTla(addr []string) string { func DenomFromTla(denom []string) string { var i int for i = 0; i+1 < len(denom); i += 2 { - if !(len(denom[i]) == 0 && len(denom[i+1]) == 0) { + if len(denom[i]) != 0 || len(denom[i+1]) != 0 { break } } diff --git a/modules/core/02-client/client/utils/utils.go b/modules/core/02-client/client/utils/utils.go index 0f1ed87a084..b3592d6592b 100644 --- a/modules/core/02-client/client/utils/utils.go +++ b/modules/core/02-client/client/utils/utils.go @@ -152,7 +152,7 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctm.Header, int64, error return ibctm.Header{}, 0, err } - protoCommit := commit.SignedHeader.ToProto() + protoCommit := commit.ToProto() protoValset, err := cmttypes.NewValidatorSet(validators.Validators).ToProto() if err != nil { return ibctm.Header{}, 0, err diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index e85cb8d137b..9a605b61dd6 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -79,7 +79,7 @@ func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = app.AppCodec() - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.ClientKeeper suite.privVal = cmttypes.NewMockPV() pubKey, err := suite.privVal.GetPubKey() diff --git a/modules/core/02-client/v2/keeper/keeper_test.go b/modules/core/02-client/v2/keeper/keeper_test.go index 19169b4c84a..cc26b2a79e2 100644 --- a/modules/core/02-client/v2/keeper/keeper_test.go +++ b/modules/core/02-client/v2/keeper/keeper_test.go @@ -46,7 +46,7 @@ func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = app.AppCodec() - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.ClientV2Keeper } diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index 0a6ca77ef23..659beece1f4 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -22,7 +22,7 @@ func (suite *KeeperTestSuite) SetupTest() { isCheckTx := false app := simapp.Setup(suite.T(), isCheckTx) - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.PortKeeper } diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 9aa65bab87c..296c680eba6 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -423,7 +423,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { app := simapp.Setup(suite.T(), false) suite.NotPanics(func() { - ibc.InitGenesis(app.BaseApp.NewContext(false), *app.IBCKeeper, tc.genState) + ibc.InitGenesis(app.NewContext(false), *app.IBCKeeper, tc.genState) }) } } diff --git a/modules/light-clients/07-tendermint/header_test.go b/modules/light-clients/07-tendermint/header_test.go index d68678126c7..a17ff892dc9 100644 --- a/modules/light-clients/07-tendermint/header_test.go +++ b/modules/light-clients/07-tendermint/header_test.go @@ -36,11 +36,11 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { header.SignedHeader = nil }, errors.New("tendermint signed header cannot be nil")}, {"SignedHeaderFromProto failed", func() { - header.SignedHeader.Commit.Height = -1 + header.Commit.Height = -1 }, errors.New("header is not a tendermint header")}, {"signed header failed tendermint ValidateBasic", func() { header = suite.chainA.LatestCommittedHeader - header.SignedHeader.Commit = nil + header.Commit = nil }, errors.New("header failed basic validation")}, {"trusted height is equal to header height", func() { var ok bool diff --git a/modules/light-clients/07-tendermint/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go index c0ead89c659..bed22ad137a 100644 --- a/modules/light-clients/07-tendermint/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -89,11 +89,11 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { return errorsmod.Wrapf(clienttypes.ErrInvalidMisbehaviour, "Header1 height is less than Header2 height (%s < %s)", misbehaviour.Header1.GetHeight(), misbehaviour.Header2.GetHeight()) } - blockID1, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 1 in misbehaviour") } - blockID2, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 2 in misbehaviour") } diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle.go b/modules/light-clients/07-tendermint/misbehaviour_handle.go index bee6310bdde..4247f51c92b 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle.go @@ -57,12 +57,12 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, // if heights are equal check that this is valid misbehaviour of a fork // otherwise if heights are unequal check that this is valid misbehavior of BFT time violation if msg.Header1.GetHeight().EQ(msg.Header2.GetHeight()) { - blockID1, err := cmttypes.BlockIDFromProto(&msg.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&msg.Header1.Commit.BlockID) if err != nil { return false } - blockID2, err := cmttypes.BlockIDFromProto(&msg.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&msg.Header2.Commit.BlockID) if err != nil { return false } @@ -72,7 +72,7 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, return true } - } else if !msg.Header1.SignedHeader.Header.Time.After(msg.Header2.SignedHeader.Header.Time) { + } else if !msg.Header1.Header.Time.After(msg.Header2.Header.Time) { // Header1 is at greater height than Header2, therefore Header1 time must be less than or equal to // Header2 time in order to be valid misbehaviour (violation of monotonic time). return true diff --git a/modules/light-clients/07-tendermint/tendermint_test.go b/modules/light-clients/07-tendermint/tendermint_test.go index f122583d7bc..decb64b1dfa 100644 --- a/modules/light-clients/07-tendermint/tendermint_test.go +++ b/modules/light-clients/07-tendermint/tendermint_test.go @@ -91,7 +91,7 @@ func (suite *TendermintTestSuite) SetupTest() { suite.valSet = cmttypes.NewValidatorSet([]*cmttypes.Validator{val}) suite.valsHash = suite.valSet.Hash() suite.header = suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers) - suite.ctx = app.BaseApp.NewContext(checkTx) + suite.ctx = app.NewContext(checkTx) } func getAltSigners(altVal *cmttypes.Validator, altPrivVal cmttypes.PrivValidator) map[string]cmttypes.PrivValidator { diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index e4679f043a3..67239f8439c 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -177,7 +177,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { name: "unsuccessful verify header: header basic validation failed", malleate: func() { // cause header to fail validatebasic by changing commit height to mismatch header height - header.SignedHeader.Commit.Height = revisionHeight - 1 + header.Commit.Height = revisionHeight - 1 }, expErr: errors.New("header and commit height mismatch"), }, diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 755f342c3f3..db1944416c8 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -789,7 +789,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // RegisterTxService implements the Application.RegisterTxService method. func (app *SimApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -797,7 +797,7 @@ func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query, ) From 7ca199a4cbf143e30a4fa059ee98f0d7b156b114 Mon Sep 17 00:00:00 2001 From: jike2021 Date: Wed, 2 Apr 2025 11:27:48 +0800 Subject: [PATCH 03/10] upgrade golangci-lint-action --- .github/workflows/golangci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index 3eaef8390af..9a74dc5d95e 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -18,13 +18,12 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.23' + go-version: "1.23" - uses: actions/checkout@v4 with: fetch-depth: 0 - name: golangci-lint - uses: golangci/golangci-lint-action@v6.5.2 + uses: golangci/golangci-lint-action@v7 with: - version: v1.62 + version: v2.0 only-new-issues: true - args: --timeout 10m From 5e2b1cf62fb61d5bda12aac1cbf694ade71fe8e4 Mon Sep 17 00:00:00 2001 From: jike2021 Date: Wed, 2 Apr 2025 11:41:03 +0800 Subject: [PATCH 04/10] upgrade more golangci-lint-action --- .github/workflows/e2emodule.yml | 5 ++--- .github/workflows/golangci-feature.yml | 5 ++--- .github/workflows/wasm-client.yml | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2emodule.yml b/.github/workflows/e2emodule.yml index 4dd47dfee1e..85667a52f46 100644 --- a/.github/workflows/e2emodule.yml +++ b/.github/workflows/e2emodule.yml @@ -22,11 +22,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: golangci/golangci-lint-action@v6.5.2 + - uses: golangci/golangci-lint-action@v7 with: - version: v1.62 + version: v2.0 only-new-issues: true - args: --timeout 5m working-directory: e2e/ tests: diff --git a/.github/workflows/golangci-feature.yml b/.github/workflows/golangci-feature.yml index e22269b1284..f4d5b1d18fc 100644 --- a/.github/workflows/golangci-feature.yml +++ b/.github/workflows/golangci-feature.yml @@ -27,8 +27,7 @@ jobs: with: fetch-depth: 0 - name: golangci-lint - uses: golangci/golangci-lint-action@v6.5.2 + uses: golangci/golangci-lint-action@v7 with: - version: v1.62 + version: v2.0 only-new-issues: true - args: --timeout 10m diff --git a/.github/workflows/wasm-client.yml b/.github/workflows/wasm-client.yml index ad8710848af..ecc4940ade7 100644 --- a/.github/workflows/wasm-client.yml +++ b/.github/workflows/wasm-client.yml @@ -20,11 +20,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: golangci/golangci-lint-action@v6.5.2 + - uses: golangci/golangci-lint-action@v7 with: - version: v1.62 + version: v2.0 only-new-issues: true - args: --timeout 10m working-directory: modules/light-clients/08-wasm build: From 3f74cd020a05825927522a4264fc318af42d71c1 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 2 Apr 2025 13:43:08 +0700 Subject: [PATCH 05/10] upgrade linter and add maintidx --- .golangci.yml | 233 ++++++----- e2e/go.mod | 2 +- e2e/tests/core/02-client/client_test.go | 2 +- .../interchain_accounts/localhost_test.go | 388 ++++++++---------- e2e/testsuite/testsuite.go | 2 +- go.mod | 2 +- .../host/keeper/relay_test.go | 18 +- modules/apps/callbacks/ibc_middleware_test.go | 8 - modules/apps/callbacks/testing/simapp/app.go | 6 +- .../apps/callbacks/testing/simapp/export.go | 7 +- .../apps/callbacks/v2/ibc_middleware_test.go | 7 - .../apps/transfer/keeper/grpc_query_test.go | 18 +- .../apps/transfer/keeper/mbt_relay_test.go | 2 +- modules/apps/transfer/types/denom.go | 2 +- modules/core/02-client/client/utils/utils.go | 2 +- modules/core/02-client/keeper/keeper_test.go | 2 +- modules/core/02-client/types/msgs_test.go | 2 +- .../core/02-client/v2/keeper/keeper_test.go | 2 +- modules/core/04-channel/keeper/ante_test.go | 2 +- modules/core/04-channel/v2/types/merkle.go | 3 +- modules/core/05-port/keeper/keeper_test.go | 2 +- .../core/23-commitment/types/merkle_test.go | 8 +- modules/core/ante/ante_test.go | 2 +- modules/core/genesis_test.go | 2 +- modules/core/keeper/msg_server.go | 2 +- .../07-tendermint/header_test.go | 4 +- .../07-tendermint/misbehaviour.go | 4 +- .../07-tendermint/misbehaviour_handle.go | 8 +- .../07-tendermint/tendermint_test.go | 2 +- .../07-tendermint/update_test.go | 2 +- testing/chain.go | 2 +- testing/simapp/app.go | 6 +- 32 files changed, 343 insertions(+), 411 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f65b69e4489..605549c225d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,133 +1,142 @@ +version: "2" run: tests: true - timeout: 10m - linters: - disable-all: true + default: none enable: - errcheck - - gci + - exhaustive - goconst - gocritic - - gofumpt - gosec - - gosimple - govet - ineffassign + - maintidx - misspell - nakedret + - nolintlint - revive - staticcheck - - stylecheck - - tenv - thelper - - typecheck - unconvert - # Prefer unparam over revive's unused param. It is more thorough in its checking. - unparam - unused - + settings: + gocritic: + disabled-checks: + - appendAssign + gosec: + excludes: + - G101 + - G107 + - G115 + - G404 + confidence: medium + revive: + enable-all-rules: true + rules: + - name: redundant-import-alias + disabled: true + - name: use-any + disabled: true + - name: if-return + disabled: true + - name: max-public-structs + disabled: true + - name: cognitive-complexity + disabled: true + - name: argument-limit + disabled: true + - name: cyclomatic + disabled: true + - name: file-header + disabled: true + - name: function-length + disabled: true + - name: function-result-limit + disabled: true + - name: line-length-limit + disabled: true + - name: flag-parameter + disabled: true + - name: add-constant + disabled: true + - name: empty-lines + disabled: true + - name: banned-characters + disabled: true + - name: deep-exit + disabled: true + - name: confusing-results + disabled: true + - name: unused-parameter + disabled: true + - name: modifies-value-receiver + disabled: true + - name: early-return + disabled: true + - name: confusing-naming + disabled: true + - name: defer + disabled: true + - name: unused-parameter + disabled: true + - name: unhandled-error + arguments: + - fmt.Printf + - fmt.Print + - fmt.Println + - myFunction + disabled: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - revive + text: differs only by capitalization to method + - linters: + - gosec + text: Use of weak random number generator + - linters: + - gosec + text: 'G115: integer overflow conversion' + - linters: + - staticcheck + text: 'SA1019:' + - linters: + - gosec + text: 'G115: integer overflow conversion' + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - text: "differs only by capitalization to method" - linters: - - revive - - text: "Use of weak random number generator" - linters: - - gosec - - text: "G115: integer overflow conversion" - linters: - - gosec - - linters: - - staticcheck - text: "SA1019:" # silence errors on usage of deprecated funcs - - text: "G115: integer overflow conversion" - linters: - - gosec - max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - gci: - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - blank # blank imports - - dot # dot imports - - prefix(cosmossdk.io) - - prefix(github.com/cosmos/cosmos-sdk) - - prefix(github.com/cometbft/cometbft) - - prefix(github.com/cosmos/ibc-go) - custom-order: true - gocritic: - disabled-checks: - - appendAssign - gosec: - # Available rules: https://github.com/securego/gosec#available-rules - excludes: - - G101 # Potential hardcoded credentials - - G107 # Potential HTTP request made with variable url - - G115 # Integer overflow conversion (used everywhere with int64 -> uint64 block height) - - G404 # Use of weak random number generator (math/rand instead of crypto/rand) - exclude-generated: true - confidence: medium - revive: - enable-all-rules: true - # Do NOT whine about the following, full explanation found in: - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#description-of-available-rules - rules: - - name: redundant-import-alias - disabled: true - - name: use-any - disabled: true - - name: if-return - disabled: true - - name: max-public-structs - disabled: true - - name: cognitive-complexity - disabled: true - - name: argument-limit - disabled: true - - name: cyclomatic - disabled: true - - name: file-header - disabled: true - - name: function-length - disabled: true - - name: function-result-limit - disabled: true - - name: line-length-limit - disabled: true - - name: flag-parameter - disabled: true - - name: add-constant - disabled: true - - name: empty-lines - disabled: true - - name: banned-characters - disabled: true - - name: deep-exit - disabled: true - - name: confusing-results - disabled: true - - name: unused-parameter - disabled: true - - name: modifies-value-receiver - disabled: true - - name: early-return - disabled: true - - name: confusing-naming - disabled: true - - name: defer - disabled: true - # Disabled in favour of unparam. - - name: unused-parameter - disabled: true - - name: unhandled-error - disabled: false - arguments: - - "fmt.Printf" - - "fmt.Print" - - "fmt.Println" - - "myFunction" +formatters: + enable: + - gci + - gofumpt + settings: + gci: + sections: + - standard + - default + - blank + - dot + - prefix(cosmossdk.io) + - prefix(github.com/cosmos/cosmos-sdk) + - prefix(github.com/cometbft/cometbft) + - prefix(github.com/cosmos/ibc-go) + custom-order: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/e2e/go.mod b/e2e/go.mod index bb8b2a70fa4..cac4eb1d756 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/ibc-go/e2e -go 1.23.6 +go 1.24 replace github.com/strangelove-ventures/interchaintest/v8 => github.com/gjermundgaraba/interchaintest/v8 v8.0.0-20250302163936-9fca2b7de400 diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 9e70f6041a6..cd448264db6 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -485,7 +485,7 @@ func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight cl AppHash: tmhash.Sum([]byte(invalidHashValue)), LastResultsHash: tmhash.Sum([]byte(invalidHashValue)), EvidenceHash: tmhash.Sum([]byte(invalidHashValue)), - ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck + ProposerAddress: tmValSet.Proposer.Address, } hhash := tmHeader.Hash() diff --git a/e2e/tests/interchain_accounts/localhost_test.go b/e2e/tests/interchain_accounts/localhost_test.go index 583cb40d517..d46ca76812f 100644 --- a/e2e/tests/interchain_accounts/localhost_test.go +++ b/e2e/tests/interchain_accounts/localhost_test.go @@ -204,18 +204,35 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan s.CreateDefaultPaths(testName) chainA, _ := s.GetChains() - chainADenom := chainA.Config().Denom rlyWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) userAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) userBWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + // Initial channel setup + controllerPortID, msgChanOpenInitRes, msgChanOpenTryRes := s.setupInitialChannel(ctx, t, chainA, userAWallet, rlyWallet) + + // Verify initial channel state + s.verifyInitialChannelState(ctx, t, chainA, controllerPortID, msgChanOpenInitRes, msgChanOpenTryRes) + + // Fund and verify interchain account + interchainAccAddress := s.fundAndVerifyInterchainAccount(ctx, t, chainA, userAWallet, chainADenom) + + // Test packet timeout and channel closure + s.testPacketTimeoutAndChannelClosure(ctx, t, chainA, userAWallet, userBWallet, rlyWallet, interchainAccAddress, chainADenom, controllerPortID, msgChanOpenInitRes, msgChanOpenTryRes) + + // Reopen channel and verify + s.reopenChannelAndVerify(ctx, t, chainA, userAWallet, rlyWallet, controllerPortID, interchainAccAddress, chainADenom) + + // Test successful packet transfer + s.testSuccessfulPacketTransfer(ctx, t, chainA, userAWallet, userBWallet, rlyWallet, interchainAccAddress, chainADenom, controllerPortID, msgChanOpenInitRes) +} + +func (s *LocalhostInterchainAccountsTestSuite) setupInitialChannel(ctx context.Context, t *testing.T, chainA ibc.Chain, userAWallet, rlyWallet ibc.Wallet) (string, channeltypes.MsgChannelOpenInitResponse, channeltypes.MsgChannelOpenTryResponse) { var ( msgChanOpenInitRes channeltypes.MsgChannelOpenInitResponse msgChanOpenTryRes channeltypes.MsgChannelOpenTryResponse - ack []byte - packet channeltypes.Packet ) s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA), "failed to wait for blocks") @@ -224,260 +241,183 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan controllerPortID, err := icatypes.NewControllerPortID(userAWallet.FormattedAddress()) s.Require().NoError(err) - t.Run("channel open init localhost - broadcast MsgRegisterInterchainAccount", func(t *testing.T) { - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(exported.LocalhostConnectionID, userAWallet.FormattedAddress(), version, channeltypes.ORDERED) - - txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgRegisterAccount) - s.AssertTxSuccess(txResp) - - s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenInitRes)) - }) - - t.Run("channel open try localhost", func(t *testing.T) { - msgChanOpenTry := channeltypes.NewMsgChannelOpenTry( - icatypes.HostPortID, icatypes.Version, - channeltypes.ORDERED, []string{exported.LocalhostConnectionID}, - controllerPortID, msgChanOpenInitRes.ChannelId, - version, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) - - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenTry) - s.AssertTxSuccess(txResp) - - s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenTryRes)) - }) - - t.Run("channel open ack localhost", func(t *testing.T) { - msgChanOpenAck := channeltypes.NewMsgChannelOpenAck( - controllerPortID, msgChanOpenInitRes.ChannelId, - msgChanOpenTryRes.ChannelId, msgChanOpenTryRes.Version, - localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) - - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenAck) - s.AssertTxSuccess(txResp) - }) - - t.Run("channel open confirm localhost", func(t *testing.T) { - msgChanOpenConfirm := channeltypes.NewMsgChannelOpenConfirm( - icatypes.HostPortID, msgChanOpenTryRes.ChannelId, - localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) - - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenConfirm) - s.AssertTxSuccess(txResp) - }) - - t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) - s.Require().NoError(err) - s.Require().NotNil(channelEndA) - - channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) - s.Require().NoError(err) - s.Require().NotNil(channelEndB) - - s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops) - }) - - t.Run("verify interchain account registration and deposit funds", func(t *testing.T) { - interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) - s.Require().NoError(err) - s.Require().NotEmpty(interchainAccAddress) - - walletAmount := ibc.WalletAmount{ - Address: interchainAccAddress, - Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), - Denom: chainADenom, - } - - s.Require().NoError(chainA.SendFunds(ctx, interchaintest.FaucetAccountKeyName, walletAmount)) - }) - - t.Run("send localhost interchain accounts packet with timeout", func(t *testing.T) { - interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) - s.Require().NoError(err) - s.Require().NotEmpty(interchainAccAddress) - - msgSend := &banktypes.MsgSend{ - FromAddress: interchainAccAddress, - ToAddress: userBWallet.FormattedAddress(), - Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainADenom)), - } - - cdc := testsuite.Codec() - bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) - s.Require().NoError(err) - - packetData := icatypes.InterchainAccountPacketData{ - Type: icatypes.EXECUTE_TX, - Data: bz, - Memo: "e2e", - } - - msgSendTx := controllertypes.NewMsgSendTx(userAWallet.FormattedAddress(), exported.LocalhostConnectionID, uint64(1), packetData) - - txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgSendTx) - s.AssertTxSuccess(txResp) - - packet, err = ibctesting.ParsePacketFromEvents(txResp.Events) - s.Require().NoError(err) - s.Require().NotNil(packet) - }) - - t.Run("timeout localhost interchain accounts packet", func(t *testing.T) { - msgTimeout := channeltypes.NewMsgTimeout(packet, 1, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) - - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgTimeout) - s.AssertTxSuccess(txResp) - }) - - t.Run("close interchain accounts host channel end", func(t *testing.T) { - // Pass in zero for counterpartyUpgradeSequence given that channel has not undergone any upgrades. - msgCloseConfirm := channeltypes.NewMsgChannelCloseConfirm(icatypes.HostPortID, msgChanOpenTryRes.ChannelId, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) - - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgCloseConfirm) - s.AssertTxSuccess(txResp) - }) + // Channel open init + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(exported.LocalhostConnectionID, userAWallet.FormattedAddress(), version, channeltypes.ORDERED) + txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgRegisterAccount) + s.AssertTxSuccess(txResp) + s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenInitRes)) + + // Channel open try + msgChanOpenTry := channeltypes.NewMsgChannelOpenTry( + icatypes.HostPortID, icatypes.Version, + channeltypes.ORDERED, []string{exported.LocalhostConnectionID}, + controllerPortID, msgChanOpenInitRes.ChannelId, + version, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), + ) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenTry) + s.AssertTxSuccess(txResp) + s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenTryRes)) - t.Run("verify localhost interchain accounts channel is closed", func(t *testing.T) { - channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) - s.Require().NoError(err) + return controllerPortID, msgChanOpenInitRes, msgChanOpenTryRes +} - s.Require().Equal(channeltypes.CLOSED, channelEndA.State, "the channel was not in an expected state") +func (s *LocalhostInterchainAccountsTestSuite) verifyInitialChannelState(ctx context.Context, t *testing.T, chainA ibc.Chain, controllerPortID string, msgChanOpenInitRes channeltypes.MsgChannelOpenInitResponse, msgChanOpenTryRes channeltypes.MsgChannelOpenTryResponse) { + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + s.Require().NoError(err) + s.Require().NotNil(channelEndA) - channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) - s.Require().NoError(err) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + s.Require().NoError(err) + s.Require().NotNil(channelEndB) - s.Require().Equal(channeltypes.CLOSED, channelEndB.State, "the channel was not in an expected state") - }) + s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops) +} - t.Run("channel open init localhost: create new channel for existing account", func(t *testing.T) { - msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(exported.LocalhostConnectionID, userAWallet.FormattedAddress(), version, channeltypes.ORDERED) +func (s *LocalhostInterchainAccountsTestSuite) fundAndVerifyInterchainAccount(ctx context.Context, t *testing.T, chainA ibc.Chain, userAWallet ibc.Wallet, chainADenom string) string { + interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) + s.Require().NoError(err) + s.Require().NotEmpty(interchainAccAddress) - txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgRegisterAccount) - s.AssertTxSuccess(txResp) + walletAmount := ibc.WalletAmount{ + Address: interchainAccAddress, + Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), + Denom: chainADenom, + } - // note: response values are updated here in msgChanOpenInitRes - s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenInitRes)) - }) + s.Require().NoError(chainA.SendFunds(ctx, interchaintest.FaucetAccountKeyName, walletAmount)) + return interchainAccAddress +} - t.Run("channel open try localhost", func(t *testing.T) { - msgChanOpenTry := channeltypes.NewMsgChannelOpenTry( - icatypes.HostPortID, icatypes.Version, - channeltypes.ORDERED, []string{exported.LocalhostConnectionID}, - controllerPortID, msgChanOpenInitRes.ChannelId, - version, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) +func (s *LocalhostInterchainAccountsTestSuite) testPacketTimeoutAndChannelClosure(ctx context.Context, t *testing.T, chainA ibc.Chain, userAWallet, userBWallet, rlyWallet ibc.Wallet, interchainAccAddress, chainADenom, controllerPortID string, msgChanOpenInitRes channeltypes.MsgChannelOpenInitResponse, msgChanOpenTryRes channeltypes.MsgChannelOpenTryResponse) { + // Send packet with timeout + msgSend := &banktypes.MsgSend{ + FromAddress: interchainAccAddress, + ToAddress: userBWallet.FormattedAddress(), + Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainADenom)), + } - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenTry) - s.AssertTxSuccess(txResp) + cdc := testsuite.Codec() + bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) + s.Require().NoError(err) - // note: response values are updated here in msgChanOpenTryRes - s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenTryRes)) - }) + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: bz, + Memo: "e2e", + } - t.Run("channel open ack localhost", func(t *testing.T) { - msgChanOpenAck := channeltypes.NewMsgChannelOpenAck( - controllerPortID, msgChanOpenInitRes.ChannelId, - msgChanOpenTryRes.ChannelId, msgChanOpenTryRes.Version, - localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) + msgSendTx := controllertypes.NewMsgSendTx(userAWallet.FormattedAddress(), exported.LocalhostConnectionID, uint64(1), packetData) + txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgSendTx) + s.AssertTxSuccess(txResp) - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenAck) - s.AssertTxSuccess(txResp) - }) + packet, err := ibctesting.ParsePacketFromEvents(txResp.Events) + s.Require().NoError(err) + s.Require().NotNil(packet) - t.Run("channel open confirm localhost", func(t *testing.T) { - msgChanOpenConfirm := channeltypes.NewMsgChannelOpenConfirm( - icatypes.HostPortID, msgChanOpenTryRes.ChannelId, - localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), - ) + // Timeout packet + msgTimeout := channeltypes.NewMsgTimeout(packet, 1, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgTimeout) + s.AssertTxSuccess(txResp) - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenConfirm) - s.AssertTxSuccess(txResp) - }) + // Close channel + msgCloseConfirm := channeltypes.NewMsgChannelCloseConfirm(icatypes.HostPortID, msgChanOpenTryRes.ChannelId, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgCloseConfirm) + s.AssertTxSuccess(txResp) - t.Run("query localhost interchain accounts channel ends", func(t *testing.T) { - channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) - s.Require().NoError(err) - s.Require().NotNil(channelEndA) + // Verify channel is closed + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + s.Require().NoError(err) + s.Require().Equal(channeltypes.CLOSED, channelEndA.State) - channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) - s.Require().NoError(err) - s.Require().NotNil(channelEndB) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + s.Require().NoError(err) + s.Require().Equal(channeltypes.CLOSED, channelEndB.State) +} - s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops) - }) +func (s *LocalhostInterchainAccountsTestSuite) reopenChannelAndVerify(ctx context.Context, t *testing.T, chainA ibc.Chain, userAWallet, rlyWallet ibc.Wallet, controllerPortID, interchainAccAddress, chainADenom string) { + version := icatypes.NewDefaultMetadataString(exported.LocalhostConnectionID, exported.LocalhostConnectionID) - t.Run("verify interchain account and existing balance", func(t *testing.T) { - interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) - s.Require().NoError(err) - s.Require().NotEmpty(interchainAccAddress) + // Register new interchain account + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(exported.LocalhostConnectionID, userAWallet.FormattedAddress(), version, channeltypes.ORDERED) + txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgRegisterAccount) + s.AssertTxSuccess(txResp) - balance, err := query.Balance(ctx, chainA, interchainAccAddress, chainADenom) - s.Require().NoError(err) + var msgChanOpenInitRes channeltypes.MsgChannelOpenInitResponse + s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenInitRes)) - expected := testvalues.StartingTokenAmount - s.Require().Equal(expected, balance.Int64()) - }) + // Channel open try + msgChanOpenTry := channeltypes.NewMsgChannelOpenTry( + icatypes.HostPortID, icatypes.Version, + channeltypes.ORDERED, []string{exported.LocalhostConnectionID}, + controllerPortID, msgChanOpenInitRes.ChannelId, + version, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress(), + ) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgChanOpenTry) + s.AssertTxSuccess(txResp) - t.Run("send packet localhost interchain accounts", func(t *testing.T) { - interchainAccAddress, err := query.InterchainAccount(ctx, chainA, userAWallet.FormattedAddress(), exported.LocalhostConnectionID) - s.Require().NoError(err) - s.Require().NotEmpty(interchainAccAddress) + var msgChanOpenTryRes channeltypes.MsgChannelOpenTryResponse + s.Require().NoError(testsuite.UnmarshalMsgResponses(txResp, &msgChanOpenTryRes)) - msgSend := &banktypes.MsgSend{ - FromAddress: interchainAccAddress, - ToAddress: userBWallet.FormattedAddress(), - Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainADenom)), - } + // Verify channel state + channelEndA, err := query.Channel(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId) + s.Require().NoError(err) + s.Require().NotNil(channelEndA) - cdc := testsuite.Codec() - bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) - s.Require().NoError(err) + channelEndB, err := query.Channel(ctx, chainA, icatypes.HostPortID, msgChanOpenTryRes.ChannelId) + s.Require().NoError(err) + s.Require().NotNil(channelEndB) - packetData := icatypes.InterchainAccountPacketData{ - Type: icatypes.EXECUTE_TX, - Data: bz, - Memo: "e2e", - } + s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops) - msgSendTx := controllertypes.NewMsgSendTx(userAWallet.FormattedAddress(), exported.LocalhostConnectionID, uint64(time.Hour.Nanoseconds()), packetData) + // Verify interchain account balance + balance, err := query.Balance(ctx, chainA, interchainAccAddress, chainADenom) + s.Require().NoError(err) + s.Require().Equal(testvalues.StartingTokenAmount, balance.Int64()) +} - txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgSendTx) - s.AssertTxSuccess(txResp) +func (s *LocalhostInterchainAccountsTestSuite) testSuccessfulPacketTransfer(ctx context.Context, t *testing.T, chainA ibc.Chain, userAWallet, userBWallet, rlyWallet ibc.Wallet, interchainAccAddress, chainADenom, controllerPortID string, msgChanOpenInitRes channeltypes.MsgChannelOpenInitResponse) { + msgSend := &banktypes.MsgSend{ + FromAddress: interchainAccAddress, + ToAddress: userBWallet.FormattedAddress(), + Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainADenom)), + } - packet, err = ibctesting.ParsePacketFromEvents(txResp.Events) - s.Require().NoError(err) - s.Require().NotNil(packet) - }) + cdc := testsuite.Codec() + bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) + s.Require().NoError(err) - t.Run("recv packet localhost interchain accounts", func(t *testing.T) { - msgRecvPacket := channeltypes.NewMsgRecvPacket(packet, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + packetData := icatypes.InterchainAccountPacketData{ + Type: icatypes.EXECUTE_TX, + Data: bz, + Memo: "e2e", + } - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgRecvPacket) - s.AssertTxSuccess(txResp) + msgSendTx := controllertypes.NewMsgSendTx(userAWallet.FormattedAddress(), exported.LocalhostConnectionID, uint64(time.Hour.Nanoseconds()), packetData) + txResp := s.BroadcastMessages(ctx, chainA, userAWallet, msgSendTx) + s.AssertTxSuccess(txResp) - ack, err = ibctesting.ParseAckFromEvents(txResp.Events) - s.Require().NoError(err) - s.Require().NotNil(ack) - }) + packet, err := ibctesting.ParsePacketFromEvents(txResp.Events) + s.Require().NoError(err) + s.Require().NotNil(packet) - t.Run("acknowledge packet localhost interchain accounts", func(t *testing.T) { - msgAcknowledgement := channeltypes.NewMsgAcknowledgement(packet, ack, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + // Recv packet + msgRecvPacket := channeltypes.NewMsgRecvPacket(packet, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgRecvPacket) + s.AssertTxSuccess(txResp) - txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgAcknowledgement) - s.AssertTxSuccess(txResp) - }) + ack, err := ibctesting.ParseAckFromEvents(txResp.Events) + s.Require().NoError(err) + s.Require().NotNil(ack) - t.Run("verify tokens transferred", func(t *testing.T) { - s.AssertPacketRelayed(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId, 1) + // Acknowledge packet + msgAcknowledgement := channeltypes.NewMsgAcknowledgement(packet, ack, localhost.SentinelProof, clienttypes.ZeroHeight(), rlyWallet.FormattedAddress()) + txResp = s.BroadcastMessages(ctx, chainA, rlyWallet, msgAcknowledgement) + s.AssertTxSuccess(txResp) - balance, err := query.Balance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) - s.Require().NoError(err) + // Verify tokens transferred + s.AssertPacketRelayed(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId, 1) - expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount - s.Require().Equal(expected, balance.Int64()) - }) + balance, err := query.Balance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom) + s.Require().NoError(err) + s.Require().Equal(testvalues.IBCTransferAmount+testvalues.StartingTokenAmount, balance.Int64()) } diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index efd68462325..9b96eeda6ae 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -724,7 +724,7 @@ func (s *E2ETestSuite) SuiteName() string { func ThreeChainSetup() ChainOptionConfiguration { // copy all values of existing chains and tweak to make unique to new chain. return func(options *ChainOptions) { - chainCSpec := *options.ChainSpecs[0] // nolint + chainCSpec := *options.ChainSpecs[0] //nolint chainCSpec.ChainID = "chainC-1" chainCSpec.Name = "simapp-c" diff --git a/go.mod b/go.mod index 73ba9d8e16c..f4d42102741 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -go 1.23.6 +go 1.24 module github.com/cosmos/ibc-go/v10 diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 33b5e7b3c04..eadf92a166f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -590,7 +590,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { }`) // this is the way cosmwasm encodes byte arrays by default // golang doesn't use this encoding by default, but it can still deserialize: - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -615,7 +615,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -644,7 +644,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -677,7 +677,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -718,7 +718,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -752,7 +752,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -768,7 +768,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { "unregistered sdk.Msg", func(icaAddress string) { msgBytes := []byte(`{"messages":[{}]}`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -793,7 +793,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, @@ -818,7 +818,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { } ] }`) - byteArrayString := strings.Join(strings.Fields(fmt.Sprint(msgBytes)), ",") + byteArrayString := strings.Join(strings.Fields(fmt.Sprint(string(msgBytes))), ",") packetData = []byte(`{ "type": 1, diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 2667537eb46..4cc3b00c9c4 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -112,7 +112,6 @@ func (s *CallbacksTestSuite) TestSendPacket() { { "success: callback data doesn't exist", func() { - //nolint:goconst packetData.Memo = "" }, "none", // nonexistent callback data should result in no callback execution @@ -257,7 +256,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { { "success: callback data doesn't exist", func() { - //nolint:goconst packetData.Memo = "" packet.Data = packetData.GetBytes() }, @@ -275,7 +273,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { { "failure: no-op on callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"src_callback": {"address": ""}}` packet.Data = packetData.GetBytes() }, @@ -428,7 +425,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { { "success: callback data doesn't exist", func() { - //nolint:goconst packetData.Memo = "" packet.Data = packetData.GetBytes() }, @@ -446,7 +442,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { { "failure: no-op on callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"src_callback": {"address": ""}}` packet.Data = packetData.GetBytes() }, @@ -604,7 +599,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { { "success: callback data doesn't exist", func() { - //nolint:goconst packetData.Memo = "" packet.Data = packetData.GetBytes() }, @@ -622,7 +616,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { { "failure: callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"dest_callback": {"address": ""}}` packet.Data = packetData.GetBytes() }, @@ -772,7 +765,6 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { { "success: callback data doesn't exist", func() { - //nolint:goconst packetData.Memo = "" packet.Data = packetData.GetBytes() }, diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index 73ad86251b2..4601160e6df 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "os" "path/filepath" @@ -100,7 +101,6 @@ import ( solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" - "maps" ) const appName = "SimApp" @@ -798,7 +798,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // RegisterTxService implements the Application.RegisterTxService method. func (app *SimApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -806,7 +806,7 @@ func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query, ) diff --git a/modules/apps/callbacks/testing/simapp/export.go b/modules/apps/callbacks/testing/simapp/export.go index c436fb9d775..6ce02a08309 100644 --- a/modules/apps/callbacks/testing/simapp/export.go +++ b/modules/apps/callbacks/testing/simapp/export.go @@ -44,7 +44,7 @@ func (app *SimApp) ExportAppStateAndValidators( AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, err } @@ -52,12 +52,9 @@ func (app *SimApp) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // in favour of export at a block height func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { - applyAllowedAddrs := false + applyAllowedAddrs := len(jailAllowedAddrs) > 0 // check if there is an allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } allowedAddrsMap := make(map[string]bool) diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 0087ff5937f..7717b83d9d8 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -117,7 +117,6 @@ func (s *CallbacksTestSuite) TestSendPacket() { { "success: callback data nonexistent", func() { - //nolint:goconst packetData.Memo = "" }, "none", @@ -254,7 +253,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { { "success: callback data nonexistent", func() { - //nolint:goconst packetData.Memo = "" }, noExecution, @@ -271,7 +269,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { { "failure: callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"src_callback": {"address": ""}}` }, noExecution, @@ -414,7 +411,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { { "success: callback data nonexistent", func() { - //nolint:goconst packetData.Memo = "" }, noExecution, @@ -431,7 +427,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { { "failure: callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"src_callback": {"address": ""}}` }, noExecution, @@ -589,7 +584,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { { "success: callback data nonexistent", func() { - //nolint:goconst packetData.Memo = "" }, noExecution, @@ -606,7 +600,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { { "failure: no-op on callback data is not valid", func() { - //nolint:goconst packetData.Memo = `{"dest_callback": {"address": ""}}` }, noExecution, diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index eca2d611318..f5a94f0b3af 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -28,9 +28,9 @@ func (suite *KeeperTestSuite) TestQueryDenom() { "success: correct ibc denom", func() { expDenom = types.NewDenom( - "uatom", //nolint:goconst - types.NewHop("transfer", "channelToA"), //nolint:goconst - types.NewHop("transfer", "channelToB"), //nolint:goconst + "uatom", + types.NewHop("transfer", "channelToA"), + types.NewHop("transfer", "channelToB"), ) suite.chainA.GetSimApp().TransferKeeper.SetDenom(suite.chainA.GetContext(), expDenom) @@ -44,9 +44,9 @@ func (suite *KeeperTestSuite) TestQueryDenom() { "success: correct hex hash", func() { expDenom = types.NewDenom( - "uatom", //nolint:goconst - types.NewHop("transfer", "channelToA"), //nolint:goconst - types.NewHop("transfer", "channelToB"), //nolint:goconst + "uatom", + types.NewHop("transfer", "channelToA"), + types.NewHop("transfer", "channelToB"), ) suite.chainA.GetSimApp().TransferKeeper.SetDenom(suite.chainA.GetContext(), expDenom) @@ -69,9 +69,9 @@ func (suite *KeeperTestSuite) TestQueryDenom() { "failure: not found denom trace", func() { expDenom = types.NewDenom( - "uatom", //nolint:goconst - types.NewHop("transfer", "channelToA"), //nolint:goconst - types.NewHop("transfer", "channelToB"), //nolint:goconst + "uatom", + types.NewHop("transfer", "channelToA"), + types.NewHop("transfer", "channelToB"), ) req = &types.QueryDenomRequest{ diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index d3acd335e66..def0d2977b8 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -118,7 +118,7 @@ func AddressFromTla(addr []string) string { func DenomFromTla(denom []string) string { var i int for i = 0; i+1 < len(denom); i += 2 { - if !(len(denom[i]) == 0 && len(denom[i+1]) == 0) { + if len(denom[i]) != 0 || len(denom[i+1]) != 0 { break } } diff --git a/modules/apps/transfer/types/denom.go b/modules/apps/transfer/types/denom.go index eb601def846..764872f22c8 100644 --- a/modules/apps/transfer/types/denom.go +++ b/modules/apps/transfer/types/denom.go @@ -71,7 +71,7 @@ func (d Denom) Path() string { var sb strings.Builder for _, t := range d.Trace { - sb.WriteString(t.String()) // nolint:revive // no error returned by WriteString + sb.WriteString(t.String()) //nolint:revive // no error returned by WriteString sb.WriteByte('/') //nolint:revive // no error returned by WriteByte } sb.WriteString(d.Base) //nolint:revive diff --git a/modules/core/02-client/client/utils/utils.go b/modules/core/02-client/client/utils/utils.go index 0f1ed87a084..b3592d6592b 100644 --- a/modules/core/02-client/client/utils/utils.go +++ b/modules/core/02-client/client/utils/utils.go @@ -152,7 +152,7 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctm.Header, int64, error return ibctm.Header{}, 0, err } - protoCommit := commit.SignedHeader.ToProto() + protoCommit := commit.ToProto() protoValset, err := cmttypes.NewValidatorSet(validators.Validators).ToProto() if err != nil { return ibctm.Header{}, 0, err diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 4cf07fb0242..ae27bba6ee3 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -79,7 +79,7 @@ func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = app.AppCodec() - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.ClientKeeper suite.privVal = cmttypes.NewMockPV() pubKey, err := suite.privVal.GetPubKey() diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 9c5510eddc5..8d9b6333b2b 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" "github.com/stretchr/testify/require" testifysuite "github.com/stretchr/testify/suite" diff --git a/modules/core/02-client/v2/keeper/keeper_test.go b/modules/core/02-client/v2/keeper/keeper_test.go index 19169b4c84a..cc26b2a79e2 100644 --- a/modules/core/02-client/v2/keeper/keeper_test.go +++ b/modules/core/02-client/v2/keeper/keeper_test.go @@ -46,7 +46,7 @@ func (suite *KeeperTestSuite) SetupTest() { app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = app.AppCodec() - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.ClientV2Keeper } diff --git a/modules/core/04-channel/keeper/ante_test.go b/modules/core/04-channel/keeper/ante_test.go index ccd3a007210..d7c1d49e4d2 100644 --- a/modules/core/04-channel/keeper/ante_test.go +++ b/modules/core/04-channel/keeper/ante_test.go @@ -24,7 +24,7 @@ func (suite *KeeperTestSuite) TestRecvPacketReCheckTx() { { "channel not found", func() { - packet.DestinationPort = "invalid-port" //nolint:goconst + packet.DestinationPort = "invalid-port" }, types.ErrChannelNotFound, }, diff --git a/modules/core/04-channel/v2/types/merkle.go b/modules/core/04-channel/v2/types/merkle.go index 06ac34168f1..f2c6b170d66 100644 --- a/modules/core/04-channel/v2/types/merkle.go +++ b/modules/core/04-channel/v2/types/merkle.go @@ -1,8 +1,9 @@ package types import ( - commitmenttypesv2 "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" "slices" + + commitmenttypesv2 "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" ) // BuildMerklePath takes the merkle path prefix and an ICS24 path diff --git a/modules/core/05-port/keeper/keeper_test.go b/modules/core/05-port/keeper/keeper_test.go index 0a6ca77ef23..659beece1f4 100644 --- a/modules/core/05-port/keeper/keeper_test.go +++ b/modules/core/05-port/keeper/keeper_test.go @@ -22,7 +22,7 @@ func (suite *KeeperTestSuite) SetupTest() { isCheckTx := false app := simapp.Setup(suite.T(), isCheckTx) - suite.ctx = app.BaseApp.NewContext(isCheckTx) + suite.ctx = app.NewContext(isCheckTx) suite.keeper = app.IBCKeeper.PortKeeper } diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index f821d7b4d55..fca2c7d7820 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -64,10 +64,10 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { err := proof.VerifyMembership(types.GetSDKSpecs(), &root, path, tc.value) if tc.shouldPass { - // nolint: scopelint + //nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - // nolint: scopelint + //nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } }) @@ -126,10 +126,10 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { err := proof.VerifyNonMembership(types.GetSDKSpecs(), &root, path) if tc.shouldPass { - // nolint: scopelint + //nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - // nolint: scopelint + //nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } }) diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 29b3477d15e..82f6b26a081 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -432,7 +432,7 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { } // append non packet and update message to msgs to ensure multimsg tx should pass - msgs = append(msgs, &clienttypes.MsgSubmitMisbehaviour{}) //nolint:staticcheck // we're using the deprecated message for testing + msgs = append(msgs, &clienttypes.MsgSubmitMisbehaviour{}) return msgs }, nil, diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 9aa65bab87c..296c680eba6 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -423,7 +423,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { app := simapp.Setup(suite.T(), false) suite.NotPanics(func() { - ibc.InitGenesis(app.BaseApp.NewContext(false), *app.IBCKeeper, tc.genState) + ibc.InitGenesis(app.NewContext(false), *app.IBCKeeper, tc.genState) }) } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b69f7787d0e..b7b6f80ad64 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -124,7 +124,7 @@ func (k *Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgrad // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. // Warning: DEPRECATED // This handler is redundant as `MsgUpdateClient` is now capable of handling both a Header and a Misbehaviour -func (k *Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. +func (k *Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) misbehaviour, err := clienttypes.UnpackClientMessage(msg.Misbehaviour) diff --git a/modules/light-clients/07-tendermint/header_test.go b/modules/light-clients/07-tendermint/header_test.go index d68678126c7..a17ff892dc9 100644 --- a/modules/light-clients/07-tendermint/header_test.go +++ b/modules/light-clients/07-tendermint/header_test.go @@ -36,11 +36,11 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { header.SignedHeader = nil }, errors.New("tendermint signed header cannot be nil")}, {"SignedHeaderFromProto failed", func() { - header.SignedHeader.Commit.Height = -1 + header.Commit.Height = -1 }, errors.New("header is not a tendermint header")}, {"signed header failed tendermint ValidateBasic", func() { header = suite.chainA.LatestCommittedHeader - header.SignedHeader.Commit = nil + header.Commit = nil }, errors.New("header failed basic validation")}, {"trusted height is equal to header height", func() { var ok bool diff --git a/modules/light-clients/07-tendermint/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go index c0ead89c659..bed22ad137a 100644 --- a/modules/light-clients/07-tendermint/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -89,11 +89,11 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { return errorsmod.Wrapf(clienttypes.ErrInvalidMisbehaviour, "Header1 height is less than Header2 height (%s < %s)", misbehaviour.Header1.GetHeight(), misbehaviour.Header2.GetHeight()) } - blockID1, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 1 in misbehaviour") } - blockID2, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 2 in misbehaviour") } diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle.go b/modules/light-clients/07-tendermint/misbehaviour_handle.go index bee6310bdde..c07e37b7054 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle.go @@ -31,7 +31,7 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, if existingConsState, found := GetConsensusState(clientStore, cdc, tmHeader.GetHeight()); found { // This header has already been submitted and the necessary state is already stored // in client store, thus we can return early without further validation. - if reflect.DeepEqual(existingConsState, tmHeader.ConsensusState()) { //nolint:gosimple + if reflect.DeepEqual(existingConsState, tmHeader.ConsensusState()) { return false } @@ -57,12 +57,12 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, // if heights are equal check that this is valid misbehaviour of a fork // otherwise if heights are unequal check that this is valid misbehavior of BFT time violation if msg.Header1.GetHeight().EQ(msg.Header2.GetHeight()) { - blockID1, err := cmttypes.BlockIDFromProto(&msg.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&msg.Header1.Commit.BlockID) if err != nil { return false } - blockID2, err := cmttypes.BlockIDFromProto(&msg.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&msg.Header2.Commit.BlockID) if err != nil { return false } @@ -72,7 +72,7 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, return true } - } else if !msg.Header1.SignedHeader.Header.Time.After(msg.Header2.SignedHeader.Header.Time) { + } else if !msg.Header1.Header.Time.After(msg.Header2.Header.Time) { // Header1 is at greater height than Header2, therefore Header1 time must be less than or equal to // Header2 time in order to be valid misbehaviour (violation of monotonic time). return true diff --git a/modules/light-clients/07-tendermint/tendermint_test.go b/modules/light-clients/07-tendermint/tendermint_test.go index f122583d7bc..decb64b1dfa 100644 --- a/modules/light-clients/07-tendermint/tendermint_test.go +++ b/modules/light-clients/07-tendermint/tendermint_test.go @@ -91,7 +91,7 @@ func (suite *TendermintTestSuite) SetupTest() { suite.valSet = cmttypes.NewValidatorSet([]*cmttypes.Validator{val}) suite.valsHash = suite.valSet.Hash() suite.header = suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers) - suite.ctx = app.BaseApp.NewContext(checkTx) + suite.ctx = app.NewContext(checkTx) } func getAltSigners(altVal *cmttypes.Validator, altPrivVal cmttypes.PrivValidator) map[string]cmttypes.PrivValidator { diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index e4679f043a3..67239f8439c 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -177,7 +177,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { name: "unsuccessful verify header: header basic validation failed", malleate: func() { // cause header to fail validatebasic by changing commit height to mismatch header height - header.SignedHeader.Commit.Height = revisionHeight - 1 + header.Commit.Height = revisionHeight - 1 }, expErr: errors.New("header and commit height mismatch"), }, diff --git a/testing/chain.go b/testing/chain.go index c5f92fbba44..78db2ce90fe 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -483,7 +483,7 @@ func CommitHeader(proposedHeader cmttypes.Header, valSet *cmttypes.ValidatorSet, // Thus we iterate over the ordered validator set and construct a signer array // from the signer map in the same order. signerArr := make([]cmttypes.PrivValidator, len(valSet.Validators)) - for i, v := range valSet.Validators { //nolint:staticcheck // need to check for nil validator set + for i, v := range valSet.Validators { signerArr[i] = signers[v.Address.String()] } diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 4a65db74115..42a9fdd2cf2 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "os" "path/filepath" @@ -105,7 +106,6 @@ import ( ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" ibcmock "github.com/cosmos/ibc-go/v10/testing/mock" mockv2 "github.com/cosmos/ibc-go/v10/testing/mock/v2" - "maps" ) const appName = "SimApp" @@ -790,7 +790,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // RegisterTxService implements the Application.RegisterTxService method. func (app *SimApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -798,7 +798,7 @@ func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query, ) From d05eb934a6acf4401a450bd65a841252419251e1 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 2 Apr 2025 14:39:02 +0700 Subject: [PATCH 06/10] 77 issues remain --- .../host/ibc_module_test.go | 3 ++- modules/core/04-channel/keeper/grpc_query_test.go | 15 ++++++++------- modules/core/04-channel/migrations/v10/store.go | 3 ++- .../core/04-channel/types/acknowledgement_test.go | 7 ++++--- .../core/04-channel/v2/keeper/msg_server_test.go | 3 +-- modules/core/23-commitment/types/codec_test.go | 6 +++--- modules/core/23-commitment/types/merkle_test.go | 2 +- modules/core/ante/ante_test.go | 6 +++--- .../light-clients/06-solomachine/codec_test.go | 4 ++-- modules/light-clients/07-tendermint/codec_test.go | 4 ++-- .../07-tendermint/light_client_module_test.go | 8 ++++---- testing/endpoint.go | 2 +- 12 files changed, 33 insertions(+), 30 deletions(-) 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 5d59bc7273c..9a5a2bb4fa6 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -1,6 +1,7 @@ package host_test import ( + "errors" "fmt" "strconv" "testing" @@ -161,7 +162,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { portID, channelID string, counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - return "", fmt.Errorf("mock ica auth fails") + return "", errors.New("mock ica auth fails") } }, nil, }, diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 849d42f3aa2..6a5ae8545a8 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "errors" "fmt" "google.golang.org/grpc/codes" @@ -715,7 +716,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence cannot be 0").Error(), + errors.New("packet sequence cannot be 0").Error(), ), }, { @@ -747,7 +748,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { }, status.Error( codes.NotFound, - fmt.Errorf("packet commitment hash not found").Error(), + errors.New("packet commitment hash not found").Error(), ), }, { @@ -958,7 +959,7 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence cannot be 0").Error(), + errors.New("packet sequence cannot be 0").Error(), ), }, { @@ -1090,7 +1091,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence cannot be 0").Error(), + errors.New("packet sequence cannot be 0").Error(), ), }, { @@ -1109,7 +1110,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { }, status.Error( codes.NotFound, - fmt.Errorf("packet acknowledgement hash not found").Error(), + errors.New("packet acknowledgement hash not found").Error(), ), }, { @@ -1349,7 +1350,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence 0 cannot be 0").Error(), + errors.New("packet sequence 0 cannot be 0").Error(), ), }, { @@ -1610,7 +1611,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence 0 cannot be 0").Error(), + errors.New("packet sequence 0 cannot be 0").Error(), ), }, { diff --git a/modules/core/04-channel/migrations/v10/store.go b/modules/core/04-channel/migrations/v10/store.go index c0b4080dd7f..6a39fa46d39 100644 --- a/modules/core/04-channel/migrations/v10/store.go +++ b/modules/core/04-channel/migrations/v10/store.go @@ -1,6 +1,7 @@ package v10 import ( + "errors" fmt "fmt" corestore "cosmossdk.io/core/store" @@ -83,7 +84,7 @@ func handleChannelMigration(ctx sdk.Context, store corestore.KVStore, cdc codec. cdc.MustUnmarshal(iterator.Value(), &channel) if channel.State == FLUSHING || channel.State == FLUSHCOMPLETE { - return fmt.Errorf("channel in state FLUSHING or FLUSHCOMPLETE found, to proceed with migration, please ensure no channels are currently upgrading") + return errors.New("channel in state FLUSHING or FLUSHCOMPLETE found, to proceed with migration, please ensure no channels are currently upgrading") } newChannel := types.Channel{ diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 9cd88531104..7e7daacd710 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "fmt" errorsmod "cosmossdk.io/errors" @@ -20,7 +21,7 @@ const ( ) // tests acknowledgement.ValidateBasic and acknowledgement.Acknowledgement -func (suite TypesTestSuite) TestAcknowledgement() { //nolint:govet // this is a test, we are okay with copying locks +func (suite *TypesTestSuite) TestAcknowledgement() { testCases := []struct { name string ack types.Acknowledgement @@ -142,7 +143,7 @@ func (suite *TypesTestSuite) TestAcknowledgementError() { suite.Require().NotEqual(ack, ackDifferentABCICode) } -func (suite TypesTestSuite) TestAcknowledgementWithCodespace() { //nolint:govet // this is a test, we are okay with copying locks +func (suite *TypesTestSuite) TestAcknowledgementWithCodespace() { testCases := []struct { name string ack types.Acknowledgement @@ -155,7 +156,7 @@ func (suite TypesTestSuite) TestAcknowledgementWithCodespace() { //nolint:govet }, { "unknown error", - types.NewErrorAcknowledgementWithCodespace(fmt.Errorf("unknown error")), + types.NewErrorAcknowledgementWithCodespace(errors.New("unknown error")), []byte(`{"error":"ABCI error: undefined/1: error handling packet: see events for details"}`), }, { diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 2928d9614b6..0cdb223907a 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "errors" - "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -96,7 +95,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { malleate: func() { payload.SourcePort = "foo" }, - expError: fmt.Errorf("no route for foo"), + expError: errors.New("no route for foo"), }, } diff --git a/modules/core/23-commitment/types/codec_test.go b/modules/core/23-commitment/types/codec_test.go index 10523699a8b..239bd9f8db1 100644 --- a/modules/core/23-commitment/types/codec_test.go +++ b/modules/core/23-commitment/types/codec_test.go @@ -1,14 +1,14 @@ package types_test import ( - "fmt" + "errors" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ibc "github.com/cosmos/ibc-go/v10/modules/core" "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" + v2 "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" ) func (suite *MerkleTestSuite) TestCodecTypeRegistration() { @@ -35,7 +35,7 @@ func (suite *MerkleTestSuite) TestCodecTypeRegistration() { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index fca2c7d7820..fc3949d6f1e 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -9,7 +9,7 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types" - "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" + v2 "github.com/cosmos/ibc-go/v10/modules/core/23-commitment/types/v2" ) func (suite *MerkleTestSuite) TestVerifyMembership() { diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 82f6b26a081..250eee3ff2d 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -1,7 +1,7 @@ package ante_test import ( - "fmt" + "errors" "testing" "time" @@ -443,7 +443,7 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { suite.chainB.GetSimApp().IBCMockModule.IBCApp.OnRecvPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress, ) exported.Acknowledgement { - panic(fmt.Errorf("failed OnRecvPacket mock callback")) + panic(errors.New("failed OnRecvPacket mock callback")) } // the RecvPacket message has not been submitted to the chain yet, so it will succeed @@ -687,7 +687,7 @@ func (suite *AnteTestSuite) TestAnteDecoratorReCheckTx() { suite.chainB.GetSimApp().IBCMockModule.IBCApp.OnRecvPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress, ) exported.Acknowledgement { - panic(fmt.Errorf("failed OnRecvPacket mock callback")) + panic(errors.New("failed OnRecvPacket mock callback")) } // the RecvPacket message has not been submitted to the chain yet, so it will succeed diff --git a/modules/light-clients/06-solomachine/codec_test.go b/modules/light-clients/06-solomachine/codec_test.go index a11af45d140..2de1912c4cb 100644 --- a/modules/light-clients/06-solomachine/codec_test.go +++ b/modules/light-clients/06-solomachine/codec_test.go @@ -1,7 +1,7 @@ package solomachine_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -41,7 +41,7 @@ func TestCodecTypeRegistration(t *testing.T) { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } diff --git a/modules/light-clients/07-tendermint/codec_test.go b/modules/light-clients/07-tendermint/codec_test.go index f0ee952eee5..49621b040d9 100644 --- a/modules/light-clients/07-tendermint/codec_test.go +++ b/modules/light-clients/07-tendermint/codec_test.go @@ -1,7 +1,7 @@ package tendermint_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -41,7 +41,7 @@ func TestCodecTypeRegistration(t *testing.T) { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } diff --git a/modules/light-clients/07-tendermint/light_client_module_test.go b/modules/light-clients/07-tendermint/light_client_module_test.go index 1b451d57b41..03e4e8af1dc 100644 --- a/modules/light-clients/07-tendermint/light_client_module_test.go +++ b/modules/light-clients/07-tendermint/light_client_module_test.go @@ -2,7 +2,7 @@ package tendermint_test import ( "crypto/sha256" - "fmt" + "errors" "time" errorsmod "cosmossdk.io/errors" @@ -54,21 +54,21 @@ func (suite *TendermintTestSuite) TestInitialize() { func() { clientState = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).ClientState() }, - fmt.Errorf("failed to unmarshal client state bytes into client state"), + errors.New("failed to unmarshal client state bytes into client state"), }, { "invalid consensus: consensus state is solomachine consensus", func() { consensusState = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).ConsensusState() }, - fmt.Errorf("failed to unmarshal consensus state bytes into consensus state"), + errors.New("failed to unmarshal consensus state bytes into consensus state"), }, { "invalid consensus state", func() { consensusState = ibctm.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte(ibctm.SentinelRoot)), []byte("invalidNextValsHash")) }, - fmt.Errorf("next validators hash is invalid"), + errors.New("next validators hash is invalid"), }, } diff --git a/testing/endpoint.go b/testing/endpoint.go index bf1f909b842..6a084dee0b3 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -550,7 +550,7 @@ func (endpoint *Endpoint) TimeoutPacketWithResult(packet channeltypes.Packet) (* case channeltypes.UNORDERED: packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) default: - return nil, fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) + return nil, errors.New("unsupported order type " + endpoint.ChannelConfig.Order.String()) } counterparty := endpoint.Counterparty From ecd382e555804bed42d1701611c8204e55d7e6f0 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 2 Apr 2025 17:03:43 +0700 Subject: [PATCH 07/10] fmt.Errorf -> errors.New --- .../controller/ibc_middleware_test.go | 26 +++++++++---------- .../apps/callbacks/v2/ibc_middleware_test.go | 12 +++++---- modules/core/02-client/types/codec_test.go | 4 +-- modules/core/02-client/types/msgs_test.go | 4 +-- .../core/03-connection/types/codec_test.go | 4 +-- .../core/04-channel/keeper/grpc_query_test.go | 2 +- .../04-channel/types/acknowledgement_test.go | 5 ++-- modules/core/04-channel/types/codec_test.go | 4 +-- 8 files changed, 31 insertions(+), 30 deletions(-) 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 0f590ce9a11..972df9ac2e1 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -1,7 +1,7 @@ package controller_test import ( - "fmt" + "errors" "strconv" "testing" @@ -146,9 +146,9 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { portID, channelID string, counterparty channeltypes.Counterparty, version string, ) (string, error) { - return "", fmt.Errorf("mock ica auth fails") + return "", errors.New("mock ica auth fails") } - }, fmt.Errorf("mock ica auth fails"), + }, errors.New("mock ica auth fails"), }, { "nil underlying app", func() { @@ -163,7 +163,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { portID, channelID string, counterparty channeltypes.Counterparty, version string, ) (string, error) { - return "", fmt.Errorf("error should be unreachable") + return "", errors.New("error should be unreachable") } }, nil, }, @@ -302,9 +302,9 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenAck = func( ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, ) error { - return fmt.Errorf("mock ica auth fails") + return errors.New("mock ica auth fails") } - }, fmt.Errorf("mock ica auth fails"), + }, errors.New("mock ica auth fails"), }, { "nil underlying app", func() { @@ -318,7 +318,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenAck = func( ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, ) error { - return fmt.Errorf("error should be unreachable") + return errors.New("error should be unreachable") } }, nil, }, @@ -576,9 +576,9 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnAcknowledgementPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, ) error { - return fmt.Errorf("mock ica auth fails") + return errors.New("mock ica auth fails") } - }, fmt.Errorf("mock ica auth fails"), + }, errors.New("mock ica auth fails"), }, { "nil underlying app", func() { @@ -592,7 +592,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnAcknowledgementPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, ) error { - return fmt.Errorf("error should be unreachable") + return errors.New("error should be unreachable") } }, nil, }, @@ -670,9 +670,9 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnTimeoutPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress, ) error { - return fmt.Errorf("mock ica auth fails") + return errors.New("mock ica auth fails") } - }, fmt.Errorf("mock ica auth fails"), + }, errors.New("mock ica auth fails"), }, { "nil underlying app", func() { @@ -686,7 +686,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnTimeoutPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress, ) error { - return fmt.Errorf("error should be unreachable") + return errors.New("error should be unreachable") } }, nil, }, diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 7717b83d9d8..18d550f83a0 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -1,7 +1,9 @@ package v2_test import ( + "errors" "fmt" + "reflect" "time" errorsmod "cosmossdk.io/errors" @@ -41,35 +43,35 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { func() { _ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, nil, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, maxCallbackGas) }, - fmt.Errorf("write acknowledgement wrapper cannot be nil"), + errors.New("write acknowledgement wrapper cannot be nil"), }, { "panics with nil underlying app", func() { _ = v2.NewIBCMiddleware(nil, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, maxCallbackGas) }, - fmt.Errorf("underlying application does not implement %T", (*types.CallbacksCompatibleModule)(nil)), + errors.New("underlying application does not implement " + reflect.TypeOf((*types.CallbacksCompatibleModule)(nil)).String()), }, { "panics with nil contract keeper", func() { _ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, nil, &channelkeeperv2.Keeper{}, maxCallbackGas) }, - fmt.Errorf("contract keeper cannot be nil"), + errors.New("contract keeper cannot be nil"), }, { "panics with nil channel v2 keeper", func() { _ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, nil, maxCallbackGas) }, - fmt.Errorf("channel keeper v2 cannot be nil"), + errors.New("channel keeper v2 cannot be nil"), }, { "panics with zero maxCallbackGas", func() { _ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, uint64(0)) }, - fmt.Errorf("maxCallbackGas cannot be zero"), + errors.New("maxCallbackGas cannot be zero"), }, } diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 3c4cb812b1b..3567d92b863 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -1,7 +1,7 @@ package types_test import ( - "fmt" + "errors" errorsmod "cosmossdk.io/errors" @@ -227,7 +227,7 @@ func (suite *TypesTestSuite) TestCodecTypeRegistration() { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 8d9b6333b2b..9e1d337b7cd 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -931,7 +931,7 @@ func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() { { "failure: invalid allowed client", types.NewMsgUpdateParams(signer, types.NewParams("")), - fmt.Errorf("client type 0 cannot be blank"), + errors.New("client type 0 cannot be blank"), }, } @@ -957,7 +957,7 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { expErr error }{ {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), nil}, - {"failure: nil address", nil, fmt.Errorf("empty address string is not allowed")}, + {"failure: nil address", nil, errors.New("empty address string is not allowed")}, } for _, tc := range testCases { diff --git a/modules/core/03-connection/types/codec_test.go b/modules/core/03-connection/types/codec_test.go index 931e8e23ba9..de2ccad22a3 100644 --- a/modules/core/03-connection/types/codec_test.go +++ b/modules/core/03-connection/types/codec_test.go @@ -1,7 +1,7 @@ package types_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -47,7 +47,7 @@ func TestCodecTypeRegistration(t *testing.T) { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 6a5ae8545a8..bd5c068ee76 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -1368,7 +1368,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { }, status.Error( codes.InvalidArgument, - fmt.Errorf("packet sequence 0 cannot be 0").Error(), + errors.New("packet sequence 0 cannot be 0").Error(), ), }, { diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 7e7daacd710..ebf49aa986d 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -2,7 +2,6 @@ package types_test import ( "errors" - "fmt" errorsmod "cosmossdk.io/errors" @@ -38,7 +37,7 @@ func (suite *TypesTestSuite) TestAcknowledgement() { }, { "valid failed ack", - types.NewErrorAcknowledgement(fmt.Errorf("error")), + types.NewErrorAcknowledgement(errors.New("error")), true, []byte(`{"error":"ABCI code: 1: error handling packet: see events for details"}`), false, @@ -52,7 +51,7 @@ func (suite *TypesTestSuite) TestAcknowledgement() { }, { "empty failed ack", - types.NewErrorAcknowledgement(fmt.Errorf(" ")), + types.NewErrorAcknowledgement(errors.New(" ")), true, []byte(`{"error":"ABCI code: 1: error handling packet: see events for details"}`), false, diff --git a/modules/core/04-channel/types/codec_test.go b/modules/core/04-channel/types/codec_test.go index 7b1f6e7fbd1..2bbc4d835ca 100644 --- a/modules/core/04-channel/types/codec_test.go +++ b/modules/core/04-channel/types/codec_test.go @@ -1,7 +1,7 @@ package types_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -77,7 +77,7 @@ func TestCodecTypeRegistration(t *testing.T) { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"), + errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"), }, } From 04f89a9dee06e51c1ef0bd312941a270d9dccaff Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 2 Apr 2025 17:12:11 +0700 Subject: [PATCH 08/10] linter cleanup --- .../controller/types/codec_test.go | 3 ++- .../host/ibc_module_test.go | 5 ++--- modules/apps/callbacks/ibc_middleware_test.go | 16 +++++++++------- .../callbacks/testing/simapp/params/proto.go | 1 - modules/apps/callbacks/v2/ibc_middleware_test.go | 2 +- modules/apps/transfer/keeper/mbt_relay_test.go | 4 ++-- modules/apps/transfer/keeper/relay_test.go | 4 ++-- modules/apps/transfer/types/denom_test.go | 6 +++--- modules/apps/transfer/types/token_test.go | 6 +++--- modules/core/02-client/keeper/keeper_test.go | 3 ++- modules/core/02-client/types/msgs_test.go | 5 ++--- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/types/codec_test.go b/modules/apps/27-interchain-accounts/controller/types/codec_test.go index a431249a989..45907f3d9a8 100644 --- a/modules/apps/27-interchain-accounts/controller/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/codec_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "fmt" "testing" @@ -37,7 +38,7 @@ func TestCodecTypeRegistration(t *testing.T) { { "type not registered on codec", "ibc.invalid.MsgTypeURL", - fmt.Errorf("unable to resolve type URL"), + errors.New("unable to resolve type URL"), }, } 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 9a5a2bb4fa6..4f9f4aef7cf 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -2,7 +2,6 @@ package host_test import ( "errors" - "fmt" "strconv" "testing" @@ -276,7 +275,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { suite.chainB.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenConfirm = func( ctx sdk.Context, portID, channelID string, ) error { - return fmt.Errorf("mock ica auth fails") + return errors.New("mock ica auth fails") } }, nil, }, @@ -410,7 +409,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { suite.chainB.GetSimApp().ICAAuthModule.IBCApp.OnRecvPacket = func( ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress, ) exported.Acknowledgement { - return channeltypes.NewErrorAcknowledgement(fmt.Errorf("failed OnRecvPacket mock callback")) + return channeltypes.NewErrorAcknowledgement(errors.New("failed OnRecvPacket mock callback")) } }, true, "failed OnRecvPacket mock callback", diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 4cc3b00c9c4..4bd5252aafc 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -2,7 +2,9 @@ package ibccallbacks_test import ( "encoding/json" + "errors" "fmt" + "reflect" errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" @@ -43,28 +45,28 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { func() { _ = ibccallbacks.NewIBCMiddleware(nil, &channelkeeper.Keeper{}, simapp.ContractKeeper{}, maxCallbackGas) }, - fmt.Errorf("underlying application does not implement %T", (*types.CallbacksCompatibleModule)(nil)), + errors.New("underlying application does not implement " + reflect.TypeOf((*types.CallbacksCompatibleModule)(nil)).String()), }, { "panics with nil contract keeper", func() { _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, &channelkeeper.Keeper{}, nil, maxCallbackGas) }, - fmt.Errorf("contract keeper cannot be nil"), + errors.New("contract keeper cannot be nil"), }, { "panics with nil ics4Wrapper", func() { _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, nil, simapp.ContractKeeper{}, maxCallbackGas) }, - fmt.Errorf("ICS4Wrapper cannot be nil"), + errors.New("ICS4Wrapper cannot be nil"), }, { "panics with zero maxCallbackGas", func() { _ = ibccallbacks.NewIBCMiddleware(ibcmock.IBCModule{}, &channelkeeper.Keeper{}, simapp.ContractKeeper{}, uint64(0)) }, - fmt.Errorf("maxCallbackGas cannot be zero"), + errors.New("maxCallbackGas cannot be zero"), }, } @@ -239,7 +241,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { userGasLimit uint64 ) - panicError := fmt.Errorf("panic error") + panicError := errors.New("panic error") testCases := []struct { name string @@ -582,7 +584,7 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { ) successAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - panicAck := channeltypes.NewErrorAcknowledgement(fmt.Errorf("panic")) + panicAck := channeltypes.NewErrorAcknowledgement(errors.New("panic")) testCases := []struct { name string @@ -855,7 +857,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() { expGasConsumed uint64 ) - callbackError := fmt.Errorf("callbackExecutor error") + callbackError := errors.New("callbackExecutor error") testCases := []struct { name string diff --git a/modules/apps/callbacks/testing/simapp/params/proto.go b/modules/apps/callbacks/testing/simapp/params/proto.go index 73702a15abf..b98ed8821b6 100644 --- a/modules/apps/callbacks/testing/simapp/params/proto.go +++ b/modules/apps/callbacks/testing/simapp/params/proto.go @@ -1,5 +1,4 @@ //go:build !test_amino -// +build !test_amino package params diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 18d550f83a0..6a805d4111a 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -238,7 +238,7 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { userGasLimit uint64 ) - panicError := fmt.Errorf("panic error") + panicError := errors.New("panic error") testCases := []struct { name string diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index def0d2977b8..98572eb8c80 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -382,9 +382,9 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { registerDenomFn() err = suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket( suite.chainB.GetContext(), packet.SourcePort, packet.SourceChannel, tc.packet.Data, - channeltypes.NewErrorAcknowledgement(fmt.Errorf("MBT Error Acknowledgement"))) + channeltypes.NewErrorAcknowledgement(errors.New("MBT Error Acknowledgement"))) default: - err = fmt.Errorf("Unknown handler: %s", tc.handler) + err = errors.New("Unknown handler: " + tc.handler) } if err != nil { suite.Require().False(tc.pass, err.Error()) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index a35ea4d7e2e..ac2b53f22a8 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -657,7 +657,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCT func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { var ( successAck = channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - failedAck = channeltypes.NewErrorAcknowledgement(fmt.Errorf("failed packet transfer")) + failedAck = channeltypes.NewErrorAcknowledgement(errors.New("failed packet transfer")) denom types.Denom amount sdkmath.Int path *ibctesting.Path @@ -796,7 +796,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacketSetsTotalEscrowAmountFo */ amount := defaultAmount - ack := channeltypes.NewErrorAcknowledgement(fmt.Errorf("failed packet transfer")) + ack := channeltypes.NewErrorAcknowledgement(errors.New("failed packet transfer")) // set up // 2 transfer channels between chain A and chain B diff --git a/modules/apps/transfer/types/denom_test.go b/modules/apps/transfer/types/denom_test.go index 6c2e6dfb5ce..4849f20daf2 100644 --- a/modules/apps/transfer/types/denom_test.go +++ b/modules/apps/transfer/types/denom_test.go @@ -1,7 +1,7 @@ package types_test import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -36,12 +36,12 @@ func (suite *TypesTestSuite) TestDenomsValidate() { types.NewDenom("uatom", types.NewHop("transfer", "channel-1"), types.NewHop("transfer", "channel-2")), types.NewDenom("uatom", types.NewHop("transfer", "channel-1"), types.NewHop("transfer", "channel-2")), }, - fmt.Errorf("duplicated denomination with hash"), + errors.New("duplicated denomination with hash"), }, { "empty base denom with trace", types.Denoms{types.NewDenom("", types.NewHop("transfer", "channel-1"))}, - fmt.Errorf("base denomination cannot be blank"), + errors.New("base denomination cannot be blank"), }, } diff --git a/modules/apps/transfer/types/token_test.go b/modules/apps/transfer/types/token_test.go index 929ba3b5f78..637aae0b096 100644 --- a/modules/apps/transfer/types/token_test.go +++ b/modules/apps/transfer/types/token_test.go @@ -1,7 +1,7 @@ package types import ( - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -126,7 +126,7 @@ func TestValidate(t *testing.T) { }, Amount: amount, }, - fmt.Errorf("invalid token denom: invalid trace: invalid hop source channel ID : identifier cannot be blank: invalid identifier"), + errors.New("invalid token denom: invalid trace: invalid hop source channel ID : identifier cannot be blank: invalid identifier"), }, { "failure: empty identifier in trace", @@ -137,7 +137,7 @@ func TestValidate(t *testing.T) { }, Amount: amount, }, - fmt.Errorf("invalid token denom: invalid trace: invalid hop source port ID : identifier cannot be blank: invalid identifier"), + errors.New("invalid token denom: invalid trace: invalid hop source port ID : identifier cannot be blank: invalid identifier"), }, } diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index ae27bba6ee3..10abcac54c6 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "errors" "fmt" "math/rand" "testing" @@ -623,7 +624,7 @@ func (suite *KeeperTestSuite) TestParams() { {"success: set default params", types.DefaultParams(), nil}, {"success: empty allowedClients", types.NewParams(), nil}, {"success: subset of allowedClients", types.NewParams(exported.Tendermint, exported.Localhost), nil}, - {"failure: contains a single empty string value as allowedClient", types.NewParams(exported.Localhost, ""), fmt.Errorf("client type 1 cannot be blank")}, + {"failure: contains a single empty string value as allowedClient", types.NewParams(exported.Localhost, ""), errors.New("client type 1 cannot be blank")}, } for _, tc := range testCases { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 9e1d337b7cd..312a5006b52 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -2,7 +2,6 @@ package types_test import ( "errors" - "fmt" "testing" "time" @@ -699,7 +698,7 @@ func TestMsgRecoverClientGetSigners(t *testing.T) { expError error }{ {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), nil}, - {"failure: nil address", nil, fmt.Errorf("empty address string is not allowed")}, + {"failure: nil address", nil, errors.New("empty address string is not allowed")}, } for _, tc := range testCases { @@ -778,7 +777,7 @@ func TestMsgIBCSoftwareUpgrade_GetSigners(t *testing.T) { { "failure: nil address", nil, - fmt.Errorf("empty address string is not allowed"), + errors.New("empty address string is not allowed"), }, } From 3a1f605cd44a4cccf7db452df7f1f8268287e3fe Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Thu, 3 Apr 2025 12:07:41 +0700 Subject: [PATCH 09/10] autofixes --- .golangci.yml | 2 +- .../controller/ibc_middleware_test.go | 14 ---------- .../controller/keeper/account_test.go | 2 -- .../controller/keeper/genesis_test.go | 2 -- .../controller/keeper/grpc_query_test.go | 2 -- .../controller/keeper/handshake_test.go | 6 ---- .../controller/keeper/keeper_test.go | 4 +-- .../controller/keeper/migrations_test.go | 2 -- .../controller/keeper/msg_server_test.go | 6 ---- .../controller/keeper/relay_test.go | 4 --- .../controller/types/codec_test.go | 2 -- .../controller/types/msgs_test.go | 1 - .../genesis/types/genesis_test.go | 6 ---- .../host/client/cli/tx_test.go | 2 +- .../host/ibc_module_test.go | 12 -------- .../host/keeper/genesis_test.go | 2 -- .../host/keeper/handshake_test.go | 4 --- .../host/keeper/keeper_test.go | 4 +-- .../host/keeper/migrations_test.go | 2 -- .../host/keeper/msg_server_test.go | 4 --- .../host/keeper/relay_test.go | 4 --- .../host/types/codec_test.go | 2 -- .../host/types/msgs_test.go | 6 ---- .../types/account_test.go | 3 -- .../types/codec_test.go | 4 --- .../types/metadata_test.go | 3 -- .../types/packet_test.go | 3 -- .../27-interchain-accounts/types/port_test.go | 1 - modules/apps/callbacks/ibc_middleware_test.go | 7 ----- modules/apps/callbacks/ica_test.go | 4 --- modules/apps/callbacks/replay_test.go | 7 ----- modules/apps/callbacks/transfer_test.go | 3 -- .../apps/callbacks/types/callbacks_test.go | 4 --- modules/apps/callbacks/types/events_test.go | 1 - .../apps/callbacks/v2/ibc_middleware_test.go | 6 ---- modules/apps/transfer/ibc_module_test.go | 9 ------ .../internal/types/legacy_denomtrace_test.go | 1 - .../apps/transfer/keeper/grpc_query_test.go | 4 --- modules/apps/transfer/keeper/keeper_test.go | 10 +------ .../apps/transfer/keeper/migrations_test.go | 5 ---- .../apps/transfer/keeper/msg_server_test.go | 5 ---- modules/apps/transfer/keeper/relay_test.go | 11 -------- .../apps/transfer/simulation/genesis_test.go | 1 - modules/apps/transfer/types/codec_test.go | 2 -- modules/apps/transfer/types/denom_test.go | 6 ---- modules/apps/transfer/types/genesis_test.go | 2 +- modules/apps/transfer/types/packet_test.go | 2 -- .../types/transfer_authorization_test.go | 4 --- modules/core/02-client/keeper/client_test.go | 6 ---- .../core/02-client/keeper/grpc_query_test.go | 17 ----------- modules/core/02-client/keeper/keeper_test.go | 5 ---- .../core/02-client/keeper/migrations_test.go | 1 - modules/core/02-client/types/client_test.go | 3 -- modules/core/02-client/types/codec_test.go | 11 +++----- modules/core/02-client/types/genesis_test.go | 2 +- modules/core/02-client/types/keys_test.go | 1 - modules/core/02-client/types/msgs_test.go | 11 -------- modules/core/02-client/types/params_test.go | 2 -- modules/core/02-client/types/router_test.go | 4 --- .../02-client/v2/keeper/grpc_query_test.go | 4 --- .../core/02-client/v2/types/config_test.go | 2 -- modules/core/02-client/v2/types/msgs_test.go | 2 -- .../03-connection/keeper/grpc_query_test.go | 10 ------- .../03-connection/keeper/handshake_test.go | 6 ---- .../core/03-connection/keeper/keeper_test.go | 2 -- .../03-connection/keeper/migrations_test.go | 1 - .../core/03-connection/keeper/verify_test.go | 12 -------- .../core/03-connection/types/codec_test.go | 2 -- .../03-connection/types/connection_test.go | 3 -- .../core/03-connection/types/genesis_test.go | 2 +- modules/core/03-connection/types/keys_test.go | 2 -- modules/core/03-connection/types/msgs_test.go | 6 ---- .../core/03-connection/types/params_test.go | 1 - .../core/03-connection/types/version_test.go | 3 -- modules/core/04-channel/keeper/ante_test.go | 1 - .../core/04-channel/keeper/grpc_query_test.go | 28 ------------------- .../core/04-channel/keeper/handshake_test.go | 6 ---- modules/core/04-channel/keeper/keeper_test.go | 1 - modules/core/04-channel/keeper/packet_test.go | 4 --- .../core/04-channel/keeper/timeout_test.go | 3 -- .../04-channel/types/acknowledgement_test.go | 4 --- modules/core/04-channel/types/channel_test.go | 3 -- modules/core/04-channel/types/codec_test.go | 2 -- modules/core/04-channel/types/genesis_test.go | 2 +- modules/core/04-channel/types/keys_test.go | 1 - modules/core/04-channel/types/msgs_test.go | 20 ------------- modules/core/04-channel/types/timeout_test.go | 4 --- .../04-channel/v2/keeper/grpc_query_test.go | 16 ----------- .../04-channel/v2/keeper/msg_server_test.go | 4 --- .../core/04-channel/v2/keeper/packet_test.go | 7 ----- .../v2/types/acknowledgement_test.go | 2 -- .../core/04-channel/v2/types/merkle_test.go | 2 -- .../core/23-commitment/types/codec_test.go | 2 -- .../core/23-commitment/types/merkle_test.go | 7 ++--- .../core/23-commitment/types/utils_test.go | 1 - modules/core/24-host/parse_test.go | 3 -- modules/core/24-host/validate_test.go | 4 --- modules/core/ante/ante_test.go | 4 --- modules/core/api/router_test.go | 2 -- modules/core/genesis_test.go | 5 +--- modules/core/keeper/keeper_test.go | 2 +- modules/core/keeper/msg_server_test.go | 18 +----------- .../06-solomachine/client_state_test.go | 2 -- .../06-solomachine/codec_test.go | 2 -- .../06-solomachine/consensus_state_test.go | 2 -- .../06-solomachine/header_test.go | 2 -- .../light_client_module_test.go | 22 --------------- .../06-solomachine/misbehaviour_test.go | 2 -- .../06-solomachine/proof_test.go | 2 -- .../07-tendermint/client_state_test.go | 1 - .../light-clients/07-tendermint/codec_test.go | 2 -- .../07-tendermint/consensus_state_test.go | 2 -- .../07-tendermint/header_test.go | 2 -- .../07-tendermint/light_client_module_test.go | 12 -------- .../07-tendermint/misbehaviour_handle_test.go | 4 --- .../07-tendermint/misbehaviour_test.go | 2 -- .../07-tendermint/proposal_handle_test.go | 6 ---- .../light-clients/07-tendermint/store_test.go | 2 -- .../07-tendermint/update_test.go | 5 ---- .../07-tendermint/upgrade_test.go | 2 -- .../09-localhost/light_client_module_test.go | 4 --- 121 files changed, 18 insertions(+), 542 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9d878bbbb3d..931fface71b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,7 @@ run: linters: default: none enable: + - copyloopvar - errcheck - exhaustive - goconst @@ -11,7 +12,6 @@ linters: - gosec - govet - ineffassign - - maintidx - misspell - nakedret - nolintlint 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 972df9ac2e1..64acba29059 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -171,8 +171,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset isNilApp = false @@ -326,8 +324,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset isNilApp = false @@ -455,8 +451,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset isNilApp = false @@ -502,8 +496,6 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -600,8 +592,6 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset isNilApp = false @@ -694,8 +684,6 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset isNilApp = false @@ -756,8 +744,6 @@ func (suite *InterchainAccountsTestSuite) TestSingleHostMultipleControllers() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { // reset suite.SetupTest() diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go index c130fd1109b..fe0c8ae7834 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go @@ -55,8 +55,6 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() 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 fff8a30c349..c75745020eb 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis_test.go @@ -47,8 +47,6 @@ func (suite *KeeperTestSuite) TestInitGenesis() { Ports: ports, } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() diff --git a/modules/apps/27-interchain-accounts/controller/keeper/grpc_query_test.go b/modules/apps/27-interchain-accounts/controller/keeper/grpc_query_test.go index f6b087eb483..7b56ad7beb1 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/grpc_query_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/grpc_query_test.go @@ -44,8 +44,6 @@ func (suite *KeeperTestSuite) TestQueryInterchainAccount() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() 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 b3976c7e2a1..554eb79dcb5 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -238,8 +238,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -399,8 +397,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -463,8 +459,6 @@ func (suite *KeeperTestSuite) TestOnChanCloseConfirm() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index 3bb16ce982c..f0b19afaeba 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -140,7 +140,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } for _, tc := range testCases { - tc := tc + suite.SetupTest() suite.Run(tc.name, func() { @@ -317,8 +317,6 @@ func (suite *KeeperTestSuite) TestSetAndGetParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() diff --git a/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go b/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go index ee4af56cb8d..a75752f3492 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/migrations_test.go @@ -42,8 +42,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go index 6a041c62152..f729b08f173 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go @@ -67,8 +67,6 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { expectedOrderding = ordering @@ -147,8 +145,6 @@ func (suite *KeeperTestSuite) TestSubmitTx() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -241,8 +237,6 @@ func (suite *KeeperTestSuite) TestUpdateParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() _, err := suite.chainA.GetSimApp().ICAControllerKeeper.UpdateParams(suite.chainA.GetContext(), tc.msg) 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 780404784f3..3c6e5ad8dfe 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -142,8 +142,6 @@ func (suite *KeeperTestSuite) TestSendTx() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset timeoutTimestamp = ^uint64(0) // default @@ -186,8 +184,6 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/controller/types/codec_test.go b/modules/apps/27-interchain-accounts/controller/types/codec_test.go index 45907f3d9a8..2b83b75ccaf 100644 --- a/modules/apps/27-interchain-accounts/controller/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/codec_test.go @@ -43,8 +43,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 2301ea23c5c..c5afe18d8e2 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -256,7 +256,6 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } for _, tc := range testCases { - tc := tc msg := types.MsgUpdateParams{ Signer: tc.address.String(), diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index 9d78e6bc935..4e1296647b4 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -66,8 +66,6 @@ func (suite *GenesisTypesTestSuite) TestValidateGenesisState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { genesisState = *genesistypes.DefaultGenesis() @@ -192,8 +190,6 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { genesisState = genesistypes.DefaultControllerGenesis() @@ -318,8 +314,6 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { genesisState = genesistypes.DefaultHostGenesis() diff --git a/modules/apps/27-interchain-accounts/host/client/cli/tx_test.go b/modules/apps/27-interchain-accounts/host/client/cli/tx_test.go index da102b8a5db..5ddd88fbce5 100644 --- a/modules/apps/27-interchain-accounts/host/client/cli/tx_test.go +++ b/modules/apps/27-interchain-accounts/host/client/cli/tx_test.go @@ -104,7 +104,7 @@ func TestGeneratePacketData(t *testing.T) { encodings := []string{icatypes.EncodingProtobuf, icatypes.EncodingProto3JSON} for _, encoding := range encodings { for _, tc := range tests { - tc := tc + ir := codectypes.NewInterfaceRegistry() if tc.registerInterfaceFn != nil { tc.registerInterfaceFn(ir) 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 4f9f4aef7cf..88ea85dd032 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -174,8 +174,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -288,8 +286,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenConfirm() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() path := NewICAPath(suite.chainA, suite.chainB, ordering) @@ -358,8 +354,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -424,8 +418,6 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -537,8 +529,6 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -589,8 +579,6 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go index 900a7ecb44d..91ac2c89c9f 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis_test.go @@ -61,8 +61,6 @@ func (suite *KeeperTestSuite) TestGenesisParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, TestPortID) 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 6b9a5720430..d08ed9bb045 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -251,8 +251,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -338,8 +336,6 @@ func (suite *KeeperTestSuite) TestOnChanOpenConfirm() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index ebc52d0cba7..e1442f5dede 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -180,7 +180,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } for _, tc := range testCases { - tc := tc + suite.SetupTest() suite.Run(tc.name, func() { @@ -376,8 +376,6 @@ func (suite *KeeperTestSuite) TestParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() diff --git a/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go b/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go index 01f44108b7f..22810abfcbd 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/migrations_test.go @@ -46,8 +46,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go index 66de5408927..5fa7cfaf476 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server_test.go @@ -124,8 +124,6 @@ func (suite *KeeperTestSuite) TestModuleQuerySafe() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -171,8 +169,6 @@ func (suite *KeeperTestSuite) TestUpdateParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index eadf92a166f..ef6606abbb0 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -500,8 +500,6 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { for _, ordering := range testedOrderings { for _, encoding := range testedEncodings { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset @@ -834,8 +832,6 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { for _, ordering := range []channeltypes.Order{channeltypes.UNORDERED, channeltypes.ORDERED} { for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/host/types/codec_test.go b/modules/apps/27-interchain-accounts/host/types/codec_test.go index ea2cd5c5763..a62332f4006 100644 --- a/modules/apps/27-interchain-accounts/host/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/host/types/codec_test.go @@ -36,8 +36,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/apps/27-interchain-accounts/host/types/msgs_test.go b/modules/apps/27-interchain-accounts/host/types/msgs_test.go index ba8e71b46a3..2cc03e92f58 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs_test.go @@ -40,7 +40,6 @@ func TestMsgUpdateParamsValidateBasic(t *testing.T) { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() if tc.expErr == nil { @@ -62,7 +61,6 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } for _, tc := range testCases { - tc := tc msg := types.NewMsgUpdateParams(tc.address.String(), types.DefaultParams()) encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) @@ -105,8 +103,6 @@ func TestMsgModuleQuerySafeValidateBasic(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() @@ -131,8 +127,6 @@ func TestMsgModuleQuerySafeGetSigners(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { msg := types.NewMsgModuleQuerySafe(tc.address.String(), []types.QueryRequest{}) encodingCfg := moduletestutil.MakeTestEncodingConfig(ica.AppModuleBasic{}) diff --git a/modules/apps/27-interchain-accounts/types/account_test.go b/modules/apps/27-interchain-accounts/types/account_test.go index ec6515e4dc7..8b87ea774fc 100644 --- a/modules/apps/27-interchain-accounts/types/account_test.go +++ b/modules/apps/27-interchain-accounts/types/account_test.go @@ -85,8 +85,6 @@ func (suite *TypesTestSuite) TestValidateAccountAddress() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := types.ValidateAccountAddress(tc.address) @@ -137,7 +135,6 @@ func (suite *TypesTestSuite) TestGenesisAccountValidate() { } for _, tc := range testCases { - tc := tc err := tc.acc.Validate() diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index 7b448153dfe..d89fb757256 100644 --- a/modules/apps/27-interchain-accounts/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/types/codec_test.go @@ -254,8 +254,6 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { for i, encoding := range testedEncodings { for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { tc.malleate() @@ -433,8 +431,6 @@ func (suite *TypesTestSuite) TestJSONDeserializeCosmosTx() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { msgs, errDeserialize := types.DeserializeCosmosTx(suite.chainA.Codec, tc.jsonBytes, types.EncodingProto3JSON) if tc.expError == nil { diff --git a/modules/apps/27-interchain-accounts/types/metadata_test.go b/modules/apps/27-interchain-accounts/types/metadata_test.go index dfb34d4c64f..bec7fa72731 100644 --- a/modules/apps/27-interchain-accounts/types/metadata_test.go +++ b/modules/apps/27-interchain-accounts/types/metadata_test.go @@ -114,7 +114,6 @@ func (suite *TypesTestSuite) TestIsPreviousMetadataEqual() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -265,7 +264,6 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -421,7 +419,6 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index 30de76101bf..1dd1075a887 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -69,7 +69,6 @@ func (suite *TypesTestSuite) TestValidateBasic() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -109,7 +108,6 @@ func (suite *TypesTestSuite) TestGetPacketSender() { } for _, tc := range testCases { - tc := tc packetData := types.InterchainAccountPacketData{} suite.Require().Equal(tc.expSender, packetData.GetPacketSender(tc.srcPortID)) @@ -177,7 +175,6 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { } for _, tc := range testCases { - tc := tc customData := tc.packetData.GetCustomPacketData("src_callback") suite.Require().Equal(tc.expCustomData, customData) diff --git a/modules/apps/27-interchain-accounts/types/port_test.go b/modules/apps/27-interchain-accounts/types/port_test.go index 87b50856512..b49c088fc20 100644 --- a/modules/apps/27-interchain-accounts/types/port_test.go +++ b/modules/apps/27-interchain-accounts/types/port_test.go @@ -34,7 +34,6 @@ func (suite *TypesTestSuite) TestNewControllerPortID() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 4bd5252aafc..9a61c19edd2 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -71,7 +71,6 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { if tc.expError == nil { s.Require().NotPanics(tc.instantiateFn, "unexpected panic: NewIBCMiddleware") @@ -169,7 +168,6 @@ func (s *CallbacksTestSuite) TestSendPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -313,7 +311,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -484,7 +481,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -656,7 +652,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -793,7 +788,6 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -935,7 +929,6 @@ func (s *CallbacksTestSuite) TestProcessCallback() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.setupChains() diff --git a/modules/apps/callbacks/ica_test.go b/modules/apps/callbacks/ica_test.go index e3fd5018b73..d26373a303e 100644 --- a/modules/apps/callbacks/ica_test.go +++ b/modules/apps/callbacks/ica_test.go @@ -78,8 +78,6 @@ func (s *CallbacksTestSuite) TestICACallbacks() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { icaAddr := s.SetupICATest() @@ -130,8 +128,6 @@ func (s *CallbacksTestSuite) TestICATimeoutCallbacks() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { icaAddr := s.SetupICATest() diff --git a/modules/apps/callbacks/replay_test.go b/modules/apps/callbacks/replay_test.go index 51dcb70e6f6..e87963bf7d1 100644 --- a/modules/apps/callbacks/replay_test.go +++ b/modules/apps/callbacks/replay_test.go @@ -26,7 +26,6 @@ func (s *CallbacksTestSuite) TestTransferTimeoutReplayProtection() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -91,7 +90,6 @@ func (s *CallbacksTestSuite) TestTransferTimeoutReplayProtection() { // expected is not a malicious amount s.Require().Equal(initialBalance.Amount, afterBalance.Amount) }) - } } @@ -107,7 +105,6 @@ func (s *CallbacksTestSuite) TestTransferErrorAcknowledgementReplayProtection() } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -169,7 +166,6 @@ func (s *CallbacksTestSuite) TestTransferErrorAcknowledgementReplayProtection() // expected is not a malicious amount s.Require().Equal(expBalance.Amount, afterBalance.Amount) }) - } } @@ -185,7 +181,6 @@ func (s *CallbacksTestSuite) TestTransferSuccessAcknowledgementReplayProtection( } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -238,7 +233,6 @@ func (s *CallbacksTestSuite) TestTransferSuccessAcknowledgementReplayProtection( // expected is not a malicious amount s.Require().Equal(expBalance.Amount, afterBalance.Amount) }) - } } @@ -254,7 +248,6 @@ func (s *CallbacksTestSuite) TestTransferRecvPacketReplayProtection() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() diff --git a/modules/apps/callbacks/transfer_test.go b/modules/apps/callbacks/transfer_test.go index d626494eb7f..c2dc5a09c16 100644 --- a/modules/apps/callbacks/transfer_test.go +++ b/modules/apps/callbacks/transfer_test.go @@ -103,7 +103,6 @@ func (s *CallbacksTestSuite) TestTransferCallbacks() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() @@ -165,14 +164,12 @@ func (s *CallbacksTestSuite) TestTransferTimeoutCallbacks() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTransferTest() s.ExecuteTransferTimeout(tc.transferMemo) s.AssertHasExecutedExpectedCallback(tc.expCallback, tc.expSuccess) }) - } } diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index 0ff3139df13..d8ac06d5c46 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -346,7 +346,6 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -458,7 +457,6 @@ func (s *CallbacksTypesTestSuite) TestGetDestSourceCallbackDataTransfer() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -590,7 +588,6 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackAddress() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) @@ -712,7 +709,6 @@ func (s *CallbacksTypesTestSuite) TestUserDefinedGasLimit() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { callbackData, ok := tc.packetData.GetCustomPacketData(types.SourceCallbackKey).(map[string]any) s.Require().Equal(ok, callbackData != nil) diff --git a/modules/apps/callbacks/types/events_test.go b/modules/apps/callbacks/types/events_test.go index b6f9a1509a7..1142ed1fe24 100644 --- a/modules/apps/callbacks/types/events_test.go +++ b/modules/apps/callbacks/types/events_test.go @@ -217,7 +217,6 @@ func (s *CallbacksTypesTestSuite) TestEvents() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { newCtx := sdk.Context{}.WithEventManager(sdk.NewEventManager()) switch tc.callbackType { diff --git a/modules/apps/callbacks/v2/ibc_middleware_test.go b/modules/apps/callbacks/v2/ibc_middleware_test.go index 6a805d4111a..6130575db2a 100644 --- a/modules/apps/callbacks/v2/ibc_middleware_test.go +++ b/modules/apps/callbacks/v2/ibc_middleware_test.go @@ -76,7 +76,6 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { if tc.expError == nil { s.Require().NotPanics(tc.instantiateFn, "unexpected panic: NewIBCMiddleware") @@ -165,7 +164,6 @@ func (s *CallbacksTestSuite) TestSendPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -305,7 +303,6 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -465,7 +462,6 @@ func (s *CallbacksTestSuite) TestOnTimeoutPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -636,7 +632,6 @@ func (s *CallbacksTestSuite) TestOnRecvPacket() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() @@ -778,7 +773,6 @@ func (s *CallbacksTestSuite) TestWriteAcknowledgement() { } for _, tc := range testCases { - tc := tc s.Run(tc.name, func() { s.SetupTest() diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index b521b766361..b9e342e7854 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -74,8 +74,6 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewTransferPath(suite.chainA, suite.chainB) @@ -155,8 +153,6 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -214,8 +210,6 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -432,7 +426,6 @@ func (suite *TransferTestSuite) TestOnAcknowledgePacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -527,7 +520,6 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -625,7 +617,6 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { tc.malleate() diff --git a/modules/apps/transfer/internal/types/legacy_denomtrace_test.go b/modules/apps/transfer/internal/types/legacy_denomtrace_test.go index db16c0c054a..39a89c33d5a 100644 --- a/modules/apps/transfer/internal/types/legacy_denomtrace_test.go +++ b/modules/apps/transfer/internal/types/legacy_denomtrace_test.go @@ -19,7 +19,6 @@ func TestDenomTrace_IBCDenom(t *testing.T) { } for _, tc := range testCases { - tc := tc denom := tc.trace.IBCDenom() require.Equal(t, tc.expDenom, denom, tc.name) diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index f5a94f0b3af..ce3e16bde62 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -144,7 +144,6 @@ func (suite *KeeperTestSuite) TestQueryDenoms() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset @@ -210,7 +209,6 @@ func (suite *KeeperTestSuite) TestQueryDenomHash() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset @@ -287,7 +285,6 @@ func (suite *KeeperTestSuite) TestEscrowAddress() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset path = ibctesting.NewTransferPath(suite.chainA, suite.chainB) @@ -380,7 +377,6 @@ func (suite *KeeperTestSuite) TestTotalEscrowForDenom() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/apps/transfer/keeper/keeper_test.go b/modules/apps/transfer/keeper/keeper_test.go index 4457af9bd5d..2d42075d272 100644 --- a/modules/apps/transfer/keeper/keeper_test.go +++ b/modules/apps/transfer/keeper/keeper_test.go @@ -95,7 +95,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } for _, tc := range testCases { - tc := tc + suite.SetupTest() suite.Run(tc.name, func() { @@ -151,8 +151,6 @@ func (suite *KeeperTestSuite) TestSetGetTotalEscrowForDenom() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset expAmount = sdkmath.NewInt(100) @@ -264,8 +262,6 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -304,8 +300,6 @@ func (suite *KeeperTestSuite) TestParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() @@ -377,8 +371,6 @@ func (suite *KeeperTestSuite) TestIsBlockedAddr() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.Require().Equal(tc.expBlock, suite.chainA.GetSimApp().TransferKeeper.IsBlockedAddr(tc.addr)) }) diff --git a/modules/apps/transfer/keeper/migrations_test.go b/modules/apps/transfer/keeper/migrations_test.go index 64c70bca0ae..dda0358803d 100644 --- a/modules/apps/transfer/keeper/migrations_test.go +++ b/modules/apps/transfer/keeper/migrations_test.go @@ -33,7 +33,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("case %s", tc.msg), func() { suite.SetupTest() // reset @@ -168,7 +167,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateDenomTraceToDenom() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset @@ -213,7 +211,6 @@ func (suite *KeeperTestSuite) TestMigratorMigrateDenomTraceToDenomCorruptionDete }, } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -284,8 +281,6 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 312f8557925..a0718a78670 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -97,8 +97,6 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -241,8 +239,6 @@ func (suite *KeeperTestSuite) TestMsgTransferIBCV2() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -343,7 +339,6 @@ func (suite *KeeperTestSuite) TestUpdateParams() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() _, err := suite.chainA.GetSimApp().TransferKeeper.UpdateParams(suite.chainA.GetContext(), tc.msg) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index ac2b53f22a8..abfd882da54 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -180,8 +180,6 @@ func (suite *KeeperTestSuite) TestSendTransfer() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -372,8 +370,6 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -502,8 +498,6 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -720,8 +714,6 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -941,8 +933,6 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1122,7 +1112,6 @@ func (suite *KeeperTestSuite) TestPacketForwardsCompatibility() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset packetData = nil diff --git a/modules/apps/transfer/simulation/genesis_test.go b/modules/apps/transfer/simulation/genesis_test.go index bbb5fda0877..a3133112436 100644 --- a/modules/apps/transfer/simulation/genesis_test.go +++ b/modules/apps/transfer/simulation/genesis_test.go @@ -80,7 +80,6 @@ func TestRandomizedGenState1(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { require.Panicsf(t, func() { simulation.RandomizedGenState(&tc.simState) }, tc.panicMsg) }) diff --git a/modules/apps/transfer/types/codec_test.go b/modules/apps/transfer/types/codec_test.go index 84635c0257d..8c07532dfa3 100644 --- a/modules/apps/transfer/types/codec_test.go +++ b/modules/apps/transfer/types/codec_test.go @@ -57,8 +57,6 @@ func (suite *TypesTestSuite) TestCodecTypeRegistration() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { encodingCfg := moduletestutil.MakeTestEncodingConfig(transfer.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/apps/transfer/types/denom_test.go b/modules/apps/transfer/types/denom_test.go index 4849f20daf2..1b57da5b252 100644 --- a/modules/apps/transfer/types/denom_test.go +++ b/modules/apps/transfer/types/denom_test.go @@ -46,7 +46,6 @@ func (suite *TypesTestSuite) TestDenomsValidate() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := tc.denoms.Validate() if tc.expError == nil { @@ -112,7 +111,6 @@ func (suite *TypesTestSuite) TestPath() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.Require().Equal(tc.expPath, tc.denom.Path()) }) @@ -181,7 +179,6 @@ func (suite *TypesTestSuite) TestSort() { }, } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.Require().Equal(tc.expDenoms, tc.denoms.Sort()) }) @@ -265,7 +262,6 @@ func (suite *TypesTestSuite) TestDenomChainSource() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.Require().Equal(tc.expHasPrefix, tc.denom.HasPrefix(tc.sourcePort, tc.sourceChannel)) }) @@ -291,7 +287,6 @@ func TestValidateIBCDenom(t *testing.T) { } for _, tc := range testCases { - tc := tc err := types.ValidateIBCDenom(tc.denom) if tc.expError { @@ -331,7 +326,6 @@ func TestExtractDenomFromPath(t *testing.T) { } for _, tc := range testCases { - tc := tc denom := types.ExtractDenomFromPath(tc.fullPath) require.Equal(t, tc.expDenom, denom, tc.name) diff --git a/modules/apps/transfer/types/genesis_test.go b/modules/apps/transfer/types/genesis_test.go index 0f1ee589948..4ce38dc67d9 100644 --- a/modules/apps/transfer/types/genesis_test.go +++ b/modules/apps/transfer/types/genesis_test.go @@ -37,7 +37,7 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { - tc := tc + err := tc.genState.Validate() if tc.expErr == nil { require.NoError(t, err, tc.name) diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index f643bfb072d..6fb542decc1 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -43,7 +43,6 @@ func TestFungibleTokenPacketDataValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.packetData.ValidateBasic() if tc.expErr == nil { @@ -135,7 +134,6 @@ func (suite *TypesTestSuite) TestPacketDataProvider() { } for _, tc := range testCases { - tc := tc customData := tc.packetData.GetCustomPacketData("src_callback") suite.Require().Equal(tc.expCustomData, customData) diff --git a/modules/apps/transfer/types/transfer_authorization_test.go b/modules/apps/transfer/types/transfer_authorization_test.go index 0290a07e337..acdf5ace502 100644 --- a/modules/apps/transfer/types/transfer_authorization_test.go +++ b/modules/apps/transfer/types/transfer_authorization_test.go @@ -212,8 +212,6 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -369,8 +367,6 @@ func (suite *TypesTestSuite) TestTransferAuthorizationValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { transferAuthz = types.TransferAuthorization{ Allocations: []types.Allocation{ diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index d1a05eb1c69..9153ddb75f0 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -74,8 +74,6 @@ func (suite *KeeperTestSuite) TestCreateClient() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset clientState, consensusState = []byte{}, []byte{} @@ -274,7 +272,6 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { } for _, tc := range cases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -470,7 +467,6 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() @@ -640,8 +636,6 @@ func (suite *KeeperTestSuite) TestRecoverClient() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index abfe6546af3..0254617c560 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -79,8 +79,6 @@ func (suite *KeeperTestSuite) TestQueryClientState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -161,8 +159,6 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset tc.malleate() @@ -275,8 +271,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -380,8 +374,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -475,8 +467,6 @@ func (suite *KeeperTestSuite) TestQueryConsensusStateHeights() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -583,8 +573,6 @@ func (suite *KeeperTestSuite) TestQueryClientStatus() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -760,8 +748,6 @@ func (suite *KeeperTestSuite) TestQueryUpgradedConsensusStates() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -834,8 +820,6 @@ func (suite *KeeperTestSuite) TestQueryCreator() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -1011,7 +995,6 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 10abcac54c6..a8272afa9ab 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -334,7 +334,6 @@ func (suite *KeeperTestSuite) TestIterateClientStates() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { var clientIDs []string suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.IterateClientStates(suite.chainA.GetContext(), tc.prefix, func(clientID string, _ exported.ClientState) bool { @@ -628,8 +627,6 @@ func (suite *KeeperTestSuite) TestParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() @@ -696,8 +693,6 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset oldPlan.Height = 0 // reset diff --git a/modules/core/02-client/keeper/migrations_test.go b/modules/core/02-client/keeper/migrations_test.go index 21265b4deb5..f4f64df34d5 100644 --- a/modules/core/02-client/keeper/migrations_test.go +++ b/modules/core/02-client/keeper/migrations_test.go @@ -26,7 +26,6 @@ func (suite *KeeperTestSuite) TestMigrateParams() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index d4d835c53fa..4b187b10ed1 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -39,8 +39,6 @@ func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -76,7 +74,6 @@ func TestValidateClientType(t *testing.T) { } for _, tc := range testCases { - tc := tc err := types.ValidateClientType(tc.clientType) diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 3567d92b863..88d3324ee98 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -48,7 +48,7 @@ func (suite *TypesTestSuite) TestPackClientState() { testCasesAny := []caseAny{} for _, tc := range testCases { - tc := tc + protoAny, err := types.PackClientState(tc.clientState) if tc.expErr == nil { suite.Require().NoError(err, tc.name) @@ -99,7 +99,7 @@ func (suite *TypesTestSuite) TestPackConsensusState() { testCasesAny := []caseAny{} for _, tc := range testCases { - tc := tc + protoAny, err := types.PackConsensusState(tc.consensusState) if tc.expErr == nil { suite.Require().NoError(err, tc.name) @@ -110,7 +110,6 @@ func (suite *TypesTestSuite) TestPackConsensusState() { } for i, tc := range testCasesAny { - tc := tc cs, err := types.UnpackConsensusState(tc.any) if tc.expErr == nil { @@ -149,7 +148,7 @@ func (suite *TypesTestSuite) TestPackClientMessage() { testCasesAny := []caseAny{} for _, tc := range testCases { - tc := tc + protoAny, err := types.PackClientMessage(tc.clientMessage) if tc.expErr == nil { suite.Require().NoError(err, tc.name) @@ -161,7 +160,7 @@ func (suite *TypesTestSuite) TestPackClientMessage() { } for i, tc := range testCasesAny { - tc := tc + cs, err := types.UnpackClientMessage(tc.any) if tc.expErr == nil { suite.Require().NoError(err, tc.name) @@ -232,8 +231,6 @@ func (suite *TypesTestSuite) TestCodecTypeRegistration() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { msg, err := suite.chainA.GetSimApp().AppCodec().InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index bf95db56055..f49dd0c0f13 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -477,7 +477,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { } for _, tc := range testCases { - tc := tc + err := tc.genState.Validate() if tc.expError == nil { suite.Require().NoError(err, tc.name) diff --git a/modules/core/02-client/types/keys_test.go b/modules/core/02-client/types/keys_test.go index a1de3673ab3..af9b63bd254 100644 --- a/modules/core/02-client/types/keys_test.go +++ b/modules/core/02-client/types/keys_test.go @@ -47,7 +47,6 @@ func TestParseClientIdentifier(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { clientType, seq, err := types.ParseClientIdentifier(tc.clientID) valid := types.IsValidClientID(tc.clientID) diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 312a5006b52..39e071cf89c 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -78,8 +78,6 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -232,8 +230,6 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -365,8 +361,6 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -459,7 +453,6 @@ func (suite *TypesTestSuite) TestMsgUpgradeClient_ValidateBasic() { } for _, tc := range cases { - tc := tc clientState := ibctm.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath) consState := &ibctm.ConsensusState{NextValidatorsHash: []byte("nextValsHash")} @@ -511,8 +504,6 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -935,7 +926,6 @@ func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() if tc.expErr == nil { @@ -960,7 +950,6 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } for _, tc := range testCases { - tc := tc msg := types.MsgUpdateParams{ Signer: tc.address.String(), diff --git a/modules/core/02-client/types/params_test.go b/modules/core/02-client/types/params_test.go index 67193b934a0..79bf5f3a2a6 100644 --- a/modules/core/02-client/types/params_test.go +++ b/modules/core/02-client/types/params_test.go @@ -25,7 +25,6 @@ func TestIsAllowedClient(t *testing.T) { } for _, tc := range testCases { - tc := tc require.Equal(t, tc.expPass, tc.params.IsAllowedClient(tc.clientType), tc.name) } } @@ -45,7 +44,6 @@ func TestValidateParams(t *testing.T) { } for _, tc := range testCases { - tc := tc err := tc.params.Validate() if tc.expError == nil { diff --git a/modules/core/02-client/types/router_test.go b/modules/core/02-client/types/router_test.go index fb098aa5892..9b3efcc7e2b 100644 --- a/modules/core/02-client/types/router_test.go +++ b/modules/core/02-client/types/router_test.go @@ -49,8 +49,6 @@ func (suite *TypesTestSuite) TestAddRoute() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() cdc := suite.chainA.App.AppCodec() @@ -105,8 +103,6 @@ func (suite *TypesTestSuite) TestHasGetRoute() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() cdc := suite.chainA.App.AppCodec() diff --git a/modules/core/02-client/v2/keeper/grpc_query_test.go b/modules/core/02-client/v2/keeper/grpc_query_test.go index 8c9c86a8e51..42ff13c7c97 100644 --- a/modules/core/02-client/v2/keeper/grpc_query_test.go +++ b/modules/core/02-client/v2/keeper/grpc_query_test.go @@ -67,8 +67,6 @@ func (suite *KeeperTestSuite) TestQueryCounterPartyInfo() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset tc.malleate() @@ -143,8 +141,6 @@ func (suite *KeeperTestSuite) TestQueryConfig() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset tc.malleate() diff --git a/modules/core/02-client/v2/types/config_test.go b/modules/core/02-client/v2/types/config_test.go index 0ce33a9f557..37004ba1436 100644 --- a/modules/core/02-client/v2/types/config_test.go +++ b/modules/core/02-client/v2/types/config_test.go @@ -25,7 +25,6 @@ func TestIsAllowedRelayer(t *testing.T) { } for _, tc := range testCases { - tc := tc require.Equal(t, tc.expPass, tc.config.IsAllowedRelayer(tc.relayer), tc.name) } } @@ -49,7 +48,6 @@ func TestValidateConfig(t *testing.T) { } for _, tc := range testCases { - tc := tc err := tc.config.Validate() if tc.expPass { diff --git a/modules/core/02-client/v2/types/msgs_test.go b/modules/core/02-client/v2/types/msgs_test.go index ed10fbe5abc..7f77db443e9 100644 --- a/modules/core/02-client/v2/types/msgs_test.go +++ b/modules/core/02-client/v2/types/msgs_test.go @@ -101,7 +101,6 @@ func TestMsgRegisterCounterpartyValidateBasic(t *testing.T) { }, } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.expError == nil { @@ -217,7 +216,6 @@ func TestMsgUpdateClientConfigValidateBasic(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.expError == nil { diff --git a/modules/core/03-connection/keeper/grpc_query_test.go b/modules/core/03-connection/keeper/grpc_query_test.go index 2b1a74b9358..5221df91e44 100644 --- a/modules/core/03-connection/keeper/grpc_query_test.go +++ b/modules/core/03-connection/keeper/grpc_query_test.go @@ -76,8 +76,6 @@ func (suite *KeeperTestSuite) TestQueryConnection() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -170,8 +168,6 @@ func (suite *KeeperTestSuite) TestQueryConnections() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -255,8 +251,6 @@ func (suite *KeeperTestSuite) TestQueryClientConnections() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -352,8 +346,6 @@ func (suite *KeeperTestSuite) TestQueryConnectionClientState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -462,8 +454,6 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index a9fd9a0f19f..d461784ccf0 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -61,7 +61,6 @@ func (suite *KeeperTestSuite) TestConnOpenInit() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset emptyConnBID = false // must be explicitly changed @@ -143,8 +142,6 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset versions = types.GetCompatibleVersions() // may be changed in malleate @@ -277,7 +274,6 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { suite.SetupTest() // reset version = types.GetCompatibleVersions()[0] // must be explicitly changed in malleate @@ -345,8 +341,6 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/core/03-connection/keeper/keeper_test.go b/modules/core/03-connection/keeper/keeper_test.go index d7824115f11..6d18de9c18d 100644 --- a/modules/core/03-connection/keeper/keeper_test.go +++ b/modules/core/03-connection/keeper/keeper_test.go @@ -150,8 +150,6 @@ func (suite *KeeperTestSuite) TestSetAndGetParams() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() diff --git a/modules/core/03-connection/keeper/migrations_test.go b/modules/core/03-connection/keeper/migrations_test.go index beb2e6ae541..3192453e4f4 100644 --- a/modules/core/03-connection/keeper/migrations_test.go +++ b/modules/core/03-connection/keeper/migrations_test.go @@ -25,7 +25,6 @@ func (suite *KeeperTestSuite) TestMigrateParams() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index 2676bc088fe..dd902140407 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -48,8 +48,6 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { } for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -108,8 +106,6 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { } for _, tc := range cases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.name), func() { suite.SetupTest() // reset @@ -183,8 +179,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { } for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -272,8 +266,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { } for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset ack = ibcmock.MockAcknowledgement // must be explicitly changed @@ -375,8 +367,6 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { } for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -474,8 +464,6 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { } for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/core/03-connection/types/codec_test.go b/modules/core/03-connection/types/codec_test.go index de2ccad22a3..65bce2ecea0 100644 --- a/modules/core/03-connection/types/codec_test.go +++ b/modules/core/03-connection/types/codec_test.go @@ -52,8 +52,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/core/03-connection/types/connection_test.go b/modules/core/03-connection/types/connection_test.go index e27017a2cef..9066e0b62b5 100644 --- a/modules/core/03-connection/types/connection_test.go +++ b/modules/core/03-connection/types/connection_test.go @@ -56,7 +56,6 @@ func TestConnectionValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.connection.ValidateBasic() if tc.expError == nil { @@ -80,7 +79,6 @@ func TestCounterpartyValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.counterparty.ValidateBasic() if tc.expError == nil { @@ -110,7 +108,6 @@ func TestIdentifiedConnectionValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.connection.ValidateBasic() if tc.expError == nil { diff --git a/modules/core/03-connection/types/genesis_test.go b/modules/core/03-connection/types/genesis_test.go index 7dfe60ed64a..c75e492fc40 100644 --- a/modules/core/03-connection/types/genesis_test.go +++ b/modules/core/03-connection/types/genesis_test.go @@ -139,7 +139,7 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { - tc := tc + err := tc.genState.Validate() if tc.expError == nil { require.NoError(t, err, tc.name) diff --git a/modules/core/03-connection/types/keys_test.go b/modules/core/03-connection/types/keys_test.go index 08a2a2d8e95..6bb6202f0e9 100644 --- a/modules/core/03-connection/types/keys_test.go +++ b/modules/core/03-connection/types/keys_test.go @@ -35,8 +35,6 @@ func TestParseConnectionSequence(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { seq, err := types.ParseConnectionSequence(tc.connectionID) valid := types.IsValidConnectionID(tc.connectionID) diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index 590600d53f3..e9c7f743357 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -108,7 +108,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() @@ -143,7 +142,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() @@ -170,7 +168,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() @@ -195,7 +192,6 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() @@ -233,7 +229,6 @@ func (suite *MsgTestSuite) TestMsgUpdateParamsValidateBasic() { } for _, tc := range testCases { - tc := tc err := tc.msg.ValidateBasic() if tc.expError == nil { @@ -256,7 +251,6 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } for _, tc := range testCases { - tc := tc msg := types.MsgUpdateParams{ Signer: tc.address.String(), diff --git a/modules/core/03-connection/types/params_test.go b/modules/core/03-connection/types/params_test.go index d6b8a413583..56b61c3aa97 100644 --- a/modules/core/03-connection/types/params_test.go +++ b/modules/core/03-connection/types/params_test.go @@ -21,7 +21,6 @@ func TestValidateParams(t *testing.T) { } for _, tc := range testCases { - tc := tc err := tc.params.Validate() if tc.expError == nil { diff --git a/modules/core/03-connection/types/version_test.go b/modules/core/03-connection/types/version_test.go index dc4e0fff8c9..934daffaca3 100644 --- a/modules/core/03-connection/types/version_test.go +++ b/modules/core/03-connection/types/version_test.go @@ -58,8 +58,6 @@ func TestIsSupportedVersion(t *testing.T) { } for _, tc := range testCases { - tc := tc - require.Equal(t, tc.expPass, types.IsSupportedVersion(types.GetCompatibleVersions(), tc.version)) } } @@ -81,7 +79,6 @@ func TestFindSupportedVersion(t *testing.T) { } for i, tc := range testCases { - tc := tc version, found := types.FindSupportedVersion(tc.version, tc.supportedVersions) if tc.expFound { diff --git a/modules/core/04-channel/keeper/ante_test.go b/modules/core/04-channel/keeper/ante_test.go index d7c1d49e4d2..b9cd3888316 100644 --- a/modules/core/04-channel/keeper/ante_test.go +++ b/modules/core/04-channel/keeper/ante_test.go @@ -39,7 +39,6 @@ func (suite *KeeperTestSuite) TestRecvPacketReCheckTx() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index bd5c068ee76..9f9610f752c 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -102,8 +102,6 @@ func (suite *KeeperTestSuite) TestQueryChannel() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -202,8 +200,6 @@ func (suite *KeeperTestSuite) TestQueryChannels() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -326,8 +322,6 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -470,8 +464,6 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -629,8 +621,6 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -783,8 +773,6 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -879,8 +867,6 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1011,8 +997,6 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1146,8 +1130,6 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1269,8 +1251,6 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1517,8 +1497,6 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1675,8 +1653,6 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1790,8 +1766,6 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -1907,8 +1881,6 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index d980326f57e..460a1c47447 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -78,7 +78,6 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { // run test for all types of ordering for _, order := range []types.Order{types.UNORDERED, types.ORDERED} { @@ -183,7 +182,6 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset heightDiff = 0 // must be explicitly changed in malleate @@ -327,7 +325,6 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset counterpartyChannelID = "" // must be explicitly changed in malleate @@ -444,7 +441,6 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset heightDiff = 0 // must be explicitly changed @@ -538,7 +534,6 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -618,7 +613,6 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { } for _, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset heightDiff = 0 // must explicitly be changed diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index dc7f2100da6..45d571cd99a 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -131,7 +131,6 @@ func (suite *KeeperTestSuite) TestGetAllChannelsWithPortPrefix() { } for _, tc := range tests { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 586974f7a5d..85b992d7215 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -194,7 +194,6 @@ func (suite *KeeperTestSuite) TestSendPacket() { } for i, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -482,7 +481,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -596,7 +594,6 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { }, } for i, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -984,7 +981,6 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset // reset ack diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 3de41970409..0580e21252c 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -194,7 +194,6 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.msg, func() { var ( proof []byte @@ -279,7 +278,6 @@ func (suite *KeeperTestSuite) TestTimeoutExecuted() { } for i, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -440,7 +438,6 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { } for i, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { var proof []byte diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index ebf49aa986d..2b444a97869 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -68,8 +68,6 @@ func (suite *TypesTestSuite) TestAcknowledgement() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -166,8 +164,6 @@ func (suite *TypesTestSuite) TestAcknowledgementWithCodespace() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.Require().Equal(tc.expBytes, tc.ack.Acknowledgement()) }) diff --git a/modules/core/04-channel/types/channel_test.go b/modules/core/04-channel/types/channel_test.go index 25f97f1d649..6136b2746dd 100644 --- a/modules/core/04-channel/types/channel_test.go +++ b/modules/core/04-channel/types/channel_test.go @@ -25,7 +25,6 @@ func TestChannelValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.channel.ValidateBasic() if tc.expErr == nil { @@ -49,7 +48,6 @@ func TestCounterpartyValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc err := tc.counterparty.ValidateBasic() if tc.expErr == nil { @@ -88,7 +86,6 @@ func TestIdentifiedChannelValidateBasic(t *testing.T) { } for _, tc := range testCases { - tc := tc err := tc.identifiedChannel.ValidateBasic() require.ErrorIs(t, err, tc.expErr) diff --git a/modules/core/04-channel/types/codec_test.go b/modules/core/04-channel/types/codec_test.go index 2bbc4d835ca..f3c782dab1c 100644 --- a/modules/core/04-channel/types/codec_test.go +++ b/modules/core/04-channel/types/codec_test.go @@ -82,8 +82,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/core/04-channel/types/genesis_test.go b/modules/core/04-channel/types/genesis_test.go index c58217ae6c4..682af38ba94 100644 --- a/modules/core/04-channel/types/genesis_test.go +++ b/modules/core/04-channel/types/genesis_test.go @@ -216,7 +216,7 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { - tc := tc + err := tc.genState.Validate() if tc.expErr == nil { require.NoError(t, err, tc.name) diff --git a/modules/core/04-channel/types/keys_test.go b/modules/core/04-channel/types/keys_test.go index 4f2d239dfd0..982f56174c8 100644 --- a/modules/core/04-channel/types/keys_test.go +++ b/modules/core/04-channel/types/keys_test.go @@ -33,7 +33,6 @@ func TestParseChannelSequence(t *testing.T) { } for _, tc := range testCases { - tc := tc seq, err := types.ParseChannelSequence(tc.channelID) valid := types.IsValidChannelID(tc.channelID) diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 7304351ab2a..b10c85b8563 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -238,8 +238,6 @@ func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -409,8 +407,6 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTryValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -519,8 +515,6 @@ func (suite *TypesTestSuite) TestMsgChannelOpenAckValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -613,8 +607,6 @@ func (suite *TypesTestSuite) TestMsgChannelOpenConfirmValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -702,8 +694,6 @@ func (suite *TypesTestSuite) TestMsgChannelCloseInitValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -801,8 +791,6 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -857,8 +845,6 @@ func (suite *TypesTestSuite) TestMsgRecvPacketValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -918,8 +904,6 @@ func (suite *TypesTestSuite) TestMsgTimeoutValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -989,8 +973,6 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() @@ -1050,8 +1032,6 @@ func (suite *TypesTestSuite) TestMsgAcknowledgementValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() diff --git a/modules/core/04-channel/types/timeout_test.go b/modules/core/04-channel/types/timeout_test.go index 03e62378fd5..4a4d0190c76 100644 --- a/modules/core/04-channel/types/timeout_test.go +++ b/modules/core/04-channel/types/timeout_test.go @@ -46,7 +46,6 @@ func (suite *TypesTestSuite) TestIsValid() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { tc.malleate() @@ -127,7 +126,6 @@ func (suite *TypesTestSuite) TestElapsed() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { elapsed := tc.timeout.Elapsed(height, timestamp) suite.Require().Equal(tc.expElapsed, elapsed) @@ -186,7 +184,6 @@ func (suite *TypesTestSuite) TestErrTimeoutElapsed() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := tc.timeout.ErrTimeoutElapsed(height, timestamp) suite.Require().Equal(tc.expError.Error(), err.Error()) @@ -225,7 +222,6 @@ func (suite *TypesTestSuite) TestErrTimeoutNotReached() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := tc.timeout.ErrTimeoutNotReached(height, timestamp) suite.Require().Equal(tc.expError.Error(), err.Error()) diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 997a662691e..5b9c7426f55 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -84,8 +84,6 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -188,8 +186,6 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -282,8 +278,6 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -386,8 +380,6 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -481,8 +473,6 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -552,8 +542,6 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -692,8 +680,6 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset @@ -804,8 +790,6 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 0cdb223907a..a7e73c5a142 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -100,8 +100,6 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -239,8 +237,6 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/core/04-channel/v2/keeper/packet_test.go b/modules/core/04-channel/v2/keeper/packet_test.go index de4c2ee3545..aad5fd9c200 100644 --- a/modules/core/04-channel/v2/keeper/packet_test.go +++ b/modules/core/04-channel/v2/keeper/packet_test.go @@ -95,7 +95,6 @@ func (suite *KeeperTestSuite) TestSendPacket() { } for i, tc := range testCases { - tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.name, i, len(testCases)), func() { suite.SetupTest() // reset @@ -202,8 +201,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -300,7 +297,6 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -408,7 +404,6 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -556,8 +551,6 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // initialize freezeClient to false diff --git a/modules/core/04-channel/v2/types/acknowledgement_test.go b/modules/core/04-channel/v2/types/acknowledgement_test.go index cc0cd7f2d00..458e0c6b2e5 100644 --- a/modules/core/04-channel/v2/types/acknowledgement_test.go +++ b/modules/core/04-channel/v2/types/acknowledgement_test.go @@ -34,8 +34,6 @@ func (s *TypesTestSuite) Test_ValidateAcknowledgement() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { s.SetupTest() diff --git a/modules/core/04-channel/v2/types/merkle_test.go b/modules/core/04-channel/v2/types/merkle_test.go index 465d3bf23a5..a05b8eeb8d4 100644 --- a/modules/core/04-channel/v2/types/merkle_test.go +++ b/modules/core/04-channel/v2/types/merkle_test.go @@ -55,8 +55,6 @@ func (s *TypesTestSuite) TestBuildMerklePath() { } for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { if tc.expPanics == nil { merklePath := types.BuildMerklePath(tc.prefix, tc.path) diff --git a/modules/core/23-commitment/types/codec_test.go b/modules/core/23-commitment/types/codec_test.go index 239bd9f8db1..540fd00ba92 100644 --- a/modules/core/23-commitment/types/codec_test.go +++ b/modules/core/23-commitment/types/codec_test.go @@ -40,8 +40,6 @@ func (suite *MerkleTestSuite) TestCodecTypeRegistration() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { encodingCfg := moduletestutil.MakeTestEncodingConfig(ibc.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index fc3949d6f1e..e321452b615 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -54,7 +54,6 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { } for i, tc := range cases { - tc := tc suite.Run(tc.name, func() { tc.malleate() @@ -64,10 +63,10 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { err := proof.VerifyMembership(types.GetSDKSpecs(), &root, path, tc.value) if tc.shouldPass { - //nolint: scopelint + // nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - //nolint: scopelint + // nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } }) @@ -115,8 +114,6 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { } for i, tc := range cases { - tc := tc - suite.Run(tc.name, func() { tc.malleate() diff --git a/modules/core/23-commitment/types/utils_test.go b/modules/core/23-commitment/types/utils_test.go index d2ef603bc50..48314d32318 100644 --- a/modules/core/23-commitment/types/utils_test.go +++ b/modules/core/23-commitment/types/utils_test.go @@ -84,7 +84,6 @@ func (suite *MerkleTestSuite) TestConvertProofs() { } for _, tc := range testcases { - tc := tc tc.malleate() diff --git a/modules/core/24-host/parse_test.go b/modules/core/24-host/parse_test.go index a1df8f3777b..72c1a13a443 100644 --- a/modules/core/24-host/parse_test.go +++ b/modules/core/24-host/parse_test.go @@ -38,7 +38,6 @@ func TestParseIdentifier(t *testing.T) { } for _, tc := range testCases { - tc := tc seq, err := host.ParseIdentifier(tc.identifier, tc.prefix) require.Equal(t, tc.expSeq, seq) @@ -67,8 +66,6 @@ func TestMustParseClientStatePath(t *testing.T) { } for _, tc := range testCases { - tc := tc - if tc.expErr == nil { require.NotPanics(t, func() { clientID := host.MustParseClientStatePath(tc.path) diff --git a/modules/core/24-host/validate_test.go b/modules/core/24-host/validate_test.go index e94b8e69aa4..c8130813f9f 100644 --- a/modules/core/24-host/validate_test.go +++ b/modules/core/24-host/validate_test.go @@ -35,7 +35,6 @@ func TestDefaultIdentifierValidator(t *testing.T) { } for _, tc := range testCases { - tc := tc err := ClientIdentifierValidator(tc.id) err1 := ConnectionIdentifierValidator(tc.id) @@ -72,7 +71,6 @@ func TestPortIdentifierValidator(t *testing.T) { } for _, tc := range testCases { - tc := tc err := PortIdentifierValidator(tc.id) if tc.expErr == nil { @@ -106,7 +104,6 @@ func TestPathValidator(t *testing.T) { } for _, tc := range testCases { - tc := tc f := NewPathValidator(func(path string) error { return nil @@ -144,7 +141,6 @@ func TestCustomPathValidator(t *testing.T) { } for _, tc := range testCases { - tc := tc err := validateFn(tc.id) if tc.expErr == nil { diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 250eee3ff2d..382d4a48176 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -604,8 +604,6 @@ func (suite *AnteTestSuite) TestAnteDecoratorCheckTx() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { // reset suite suite.SetupTest() @@ -713,8 +711,6 @@ func (suite *AnteTestSuite) TestAnteDecoratorReCheckTx() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { // reset suite suite.SetupTest() diff --git a/modules/core/api/router_test.go b/modules/core/api/router_test.go index ae6c25f758a..9e0e8be5921 100644 --- a/modules/core/api/router_test.go +++ b/modules/core/api/router_test.go @@ -57,8 +57,6 @@ func (suite *APITestSuite) TestRouter() { }, } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { router = api.NewRouter() diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 296c680eba6..7f9e27b0b03 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -281,7 +281,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { } for _, tc := range testCases { - tc := tc + err := tc.genState.Validate() if tc.expError == nil { suite.Require().NoError(err, tc.name) @@ -418,7 +418,6 @@ func (suite *IBCTestSuite) TestInitGenesis() { } for _, tc := range testCases { - tc := tc app := simapp.Setup(suite.T(), false) @@ -446,8 +445,6 @@ func (suite *IBCTestSuite) TestExportGenesis() { } for _, tc := range testCases { - tc := tc - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index bbc554184fc..ceb0458d792 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { } for _, tc := range testCases { - tc := tc + suite.SetupTest() suite.Run(tc.name, func() { diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index dfdc63b6ba7..8af56f9ee3d 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -65,7 +65,6 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { }, } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -209,8 +208,6 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -311,7 +308,6 @@ func (suite *KeeperTestSuite) TestUpdateClient() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -362,7 +358,6 @@ func (suite *KeeperTestSuite) TestRecoverClient() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -516,8 +511,6 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -675,8 +668,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -854,8 +845,6 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -979,7 +968,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { } for _, tc := range cases { - tc := tc + path = ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() @@ -1060,7 +1049,6 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) path.SetupClients() @@ -1143,7 +1131,6 @@ func (suite *KeeperTestSuite) TestUpdateClientParams() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() _, err := suite.chainA.App.GetIBCKeeper().UpdateClientParams(suite.chainA.GetContext(), tc.msg) @@ -1195,7 +1182,6 @@ func (suite *KeeperTestSuite) TestUpdateConnectionParams() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() _, err := suite.chainA.App.GetIBCKeeper().UpdateConnectionParams(suite.chainA.GetContext(), tc.msg) @@ -1285,7 +1271,6 @@ func (suite *KeeperTestSuite) TestUpdateClientConfig() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -1368,7 +1353,6 @@ func (suite *KeeperTestSuite) TestDeleteClientCreator() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/light-clients/06-solomachine/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go index bb62e065a7e..76215c6b7de 100644 --- a/modules/light-clients/06-solomachine/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -57,8 +57,6 @@ func (suite *SoloMachineTestSuite) TestClientStateValidate() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.clientState.Validate() diff --git a/modules/light-clients/06-solomachine/codec_test.go b/modules/light-clients/06-solomachine/codec_test.go index 2de1912c4cb..e4cfb97cb1c 100644 --- a/modules/light-clients/06-solomachine/codec_test.go +++ b/modules/light-clients/06-solomachine/codec_test.go @@ -46,8 +46,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(solomachine.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/light-clients/06-solomachine/consensus_state_test.go b/modules/light-clients/06-solomachine/consensus_state_test.go index 20500feee04..64710efe1c5 100644 --- a/modules/light-clients/06-solomachine/consensus_state_test.go +++ b/modules/light-clients/06-solomachine/consensus_state_test.go @@ -59,8 +59,6 @@ func (suite *SoloMachineTestSuite) TestConsensusStateValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.consensusState.ValidateBasic() diff --git a/modules/light-clients/06-solomachine/header_test.go b/modules/light-clients/06-solomachine/header_test.go index fa19011256f..5eb56f9432d 100644 --- a/modules/light-clients/06-solomachine/header_test.go +++ b/modules/light-clients/06-solomachine/header_test.go @@ -69,8 +69,6 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { suite.Require().Equal(exported.Solomachine, header.ClientType()) for _, tc := range cases { - tc := tc - suite.Run(tc.name, func() { err := tc.header.ValidateBasic() diff --git a/modules/light-clients/06-solomachine/light_client_module_test.go b/modules/light-clients/06-solomachine/light_client_module_test.go index 50a903699fe..f5ee73865bd 100644 --- a/modules/light-clients/06-solomachine/light_client_module_test.go +++ b/modules/light-clients/06-solomachine/light_client_module_test.go @@ -59,8 +59,6 @@ func (suite *SoloMachineTestSuite) TestStatus() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { clientID = suite.solomachine.ClientID @@ -115,8 +113,6 @@ func (suite *SoloMachineTestSuite) TestGetTimestampAtHeight() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { clientID = suite.solomachine.ClientID clientState := suite.solomachine.ClientState() @@ -188,8 +184,6 @@ func (suite *SoloMachineTestSuite) TestInitialize() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() clientID := sm.ClientID @@ -624,8 +618,6 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() testingPath = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -849,8 +841,6 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -968,7 +958,6 @@ func (suite *SoloMachineTestSuite) TestRecoverClient() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -1057,8 +1046,6 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -1150,8 +1137,6 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -1207,8 +1192,6 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() clientID = sm.ClientID @@ -1384,8 +1367,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() clientID = sm.ClientID @@ -1629,8 +1610,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() clientID = sm.ClientID @@ -1688,7 +1667,6 @@ func (suite *SoloMachineTestSuite) TestLatestHeight() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() clientID = suite.solomachine.ClientID diff --git a/modules/light-clients/06-solomachine/misbehaviour_test.go b/modules/light-clients/06-solomachine/misbehaviour_test.go index 54d3f69d2ca..e8f85476358 100644 --- a/modules/light-clients/06-solomachine/misbehaviour_test.go +++ b/modules/light-clients/06-solomachine/misbehaviour_test.go @@ -116,8 +116,6 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { misbehaviour := sm.CreateMisbehaviour() tc.malleateMisbehaviour(misbehaviour) diff --git a/modules/light-clients/06-solomachine/proof_test.go b/modules/light-clients/06-solomachine/proof_test.go index 7d11f8a5c95..bbc8fb1e2bb 100644 --- a/modules/light-clients/06-solomachine/proof_test.go +++ b/modules/light-clients/06-solomachine/proof_test.go @@ -54,8 +54,6 @@ func (suite *SoloMachineTestSuite) TestVerifySignature() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := solomachine.VerifySignature(tc.publicKey, signBytes, tc.sigData) diff --git a/modules/light-clients/07-tendermint/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go index f113b7b2358..fe25b6b2800 100644 --- a/modules/light-clients/07-tendermint/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -121,7 +121,6 @@ func (suite *TendermintTestSuite) TestValidate() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { err := tc.clientState.Validate() diff --git a/modules/light-clients/07-tendermint/codec_test.go b/modules/light-clients/07-tendermint/codec_test.go index 49621b040d9..c33e628ec7d 100644 --- a/modules/light-clients/07-tendermint/codec_test.go +++ b/modules/light-clients/07-tendermint/codec_test.go @@ -46,8 +46,6 @@ func TestCodecTypeRegistration(t *testing.T) { } for _, tc := range testCases { - tc := tc - t.Run(tc.name, func(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(tendermint.AppModuleBasic{}) msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL) diff --git a/modules/light-clients/07-tendermint/consensus_state_test.go b/modules/light-clients/07-tendermint/consensus_state_test.go index 137c2d0f07d..e460e5451a4 100644 --- a/modules/light-clients/07-tendermint/consensus_state_test.go +++ b/modules/light-clients/07-tendermint/consensus_state_test.go @@ -72,8 +72,6 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { } for i, tc := range testCases { - tc := tc - suite.Run(tc.msg, func() { // check just to increase coverage suite.Require().Equal(exported.Tendermint, tc.consensusState.ClientType()) diff --git a/modules/light-clients/07-tendermint/header_test.go b/modules/light-clients/07-tendermint/header_test.go index a17ff892dc9..6c98b832cd2 100644 --- a/modules/light-clients/07-tendermint/header_test.go +++ b/modules/light-clients/07-tendermint/header_test.go @@ -62,8 +62,6 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { suite.Require().Equal(exported.Tendermint, suite.header.ClientType()) for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() diff --git a/modules/light-clients/07-tendermint/light_client_module_test.go b/modules/light-clients/07-tendermint/light_client_module_test.go index 03e4e8af1dc..16bff624a41 100644 --- a/modules/light-clients/07-tendermint/light_client_module_test.go +++ b/modules/light-clients/07-tendermint/light_client_module_test.go @@ -73,7 +73,6 @@ func (suite *TendermintTestSuite) TestInitialize() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() path := ibctesting.NewPath(suite.chainA, suite.chainB) @@ -140,7 +139,6 @@ func (suite *TendermintTestSuite) TestVerifyClientMessage() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -478,8 +476,6 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset testingpath = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -706,8 +702,6 @@ func (suite *TendermintTestSuite) TestVerifyNonMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset testingpath = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -799,7 +793,6 @@ func (suite *TendermintTestSuite) TestStatus() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -818,7 +811,6 @@ func (suite *TendermintTestSuite) TestStatus() { status := lightClientModule.Status(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().Equal(tc.expStatus, status) }) - } } @@ -849,7 +841,6 @@ func (suite *TendermintTestSuite) TestLatestHeight() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -904,7 +895,6 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() @@ -990,7 +980,6 @@ func (suite *TendermintTestSuite) TestRecoverClient() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset ctx := suite.chainA.GetContext() @@ -1138,7 +1127,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgradeAndUpdateState() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle_test.go b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go index e2ed15ef338..69f8f3080e3 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go @@ -360,8 +360,6 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -670,8 +668,6 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/light-clients/07-tendermint/misbehaviour_test.go b/modules/light-clients/07-tendermint/misbehaviour_test.go index e4951e4fb97..9ffa7804cdc 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_test.go @@ -224,8 +224,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { } for i, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { err := tc.malleateMisbehaviour(tc.misbehaviour) suite.Require().NoError(err) diff --git a/modules/light-clients/07-tendermint/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go index e2893ba87cd..78fbe3ee6cc 100644 --- a/modules/light-clients/07-tendermint/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/proposal_handle_test.go @@ -40,8 +40,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset subjectPath := ibctesting.NewPath(suite.chainA, suite.chainB) @@ -85,8 +83,6 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset @@ -224,8 +220,6 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() // reset diff --git a/modules/light-clients/07-tendermint/store_test.go b/modules/light-clients/07-tendermint/store_test.go index ad842893340..26df63bc2ce 100644 --- a/modules/light-clients/07-tendermint/store_test.go +++ b/modules/light-clients/07-tendermint/store_test.go @@ -53,8 +53,6 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index 67239f8439c..d170ee8b475 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -293,7 +293,6 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() path = ibctesting.NewPath(suite.chainA, suite.chainB) @@ -508,7 +507,6 @@ func (suite *TendermintTestSuite) TestUpdateState() { }, } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { suite.SetupTest() // reset pruneHeight = clienttypes.ZeroHeight() @@ -880,7 +878,6 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { } for _, tc := range testCases { - tc := tc suite.Run(tc.name, func() { // reset suite to create fresh application state suite.SetupTest() @@ -932,8 +929,6 @@ func (suite *TendermintTestSuite) TestUpdateStateOnMisbehaviour() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { // reset suite to create fresh application state suite.SetupTest() diff --git a/modules/light-clients/07-tendermint/upgrade_test.go b/modules/light-clients/07-tendermint/upgrade_test.go index e28e7deb987..16489488f0c 100644 --- a/modules/light-clients/07-tendermint/upgrade_test.go +++ b/modules/light-clients/07-tendermint/upgrade_test.go @@ -530,8 +530,6 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { // reset suite suite.SetupTest() diff --git a/modules/light-clients/09-localhost/light_client_module_test.go b/modules/light-clients/09-localhost/light_client_module_test.go index 4bc976dc701..fb5b814ce6b 100644 --- a/modules/light-clients/09-localhost/light_client_module_test.go +++ b/modules/light-clients/09-localhost/light_client_module_test.go @@ -231,8 +231,6 @@ func (suite *LocalhostTestSuite) TestVerifyMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() @@ -310,8 +308,6 @@ func (suite *LocalhostTestSuite) TestVerifyNonMembership() { } for _, tc := range testCases { - tc := tc - suite.Run(tc.name, func() { suite.SetupTest() From cd593e9de08d44eb2390d1e31d971a80f6a692dc Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Thu, 3 Apr 2025 12:12:10 +0700 Subject: [PATCH 10/10] temporarily disable nolintlint --- .golangci.yml | 1 - modules/core/23-commitment/types/merkle_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 931fface71b..334c2472a4f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,7 +14,6 @@ linters: - ineffassign - misspell - nakedret - - nolintlint - revive - staticcheck - thelper diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index e321452b615..1e21c1f8f1d 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -63,10 +63,10 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { err := proof.VerifyMembership(types.GetSDKSpecs(), &root, path, tc.value) if tc.shouldPass { - // nolint: scopelint + //nolint: scopelint suite.Require().NoError(err, "test case %d should have passed", i) } else { - // nolint: scopelint + //nolint: scopelint suite.Require().Error(err, "test case %d should have failed", i) } })