From 6f2493fb5449443ffe14286b37d2105c3075deda Mon Sep 17 00:00:00 2001 From: Vishal Potpelliwar <71565171+vishal-kanna@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:33:46 +0530 Subject: [PATCH] feat: check if controller enabled or not in `sendTx` (#5343) * checked if controller enabled or not * added the test case * rename test case * extra line * Update modules/apps/27-interchain-accounts/controller/keeper/relay_test.go Co-authored-by: DimitrisJim * make lint-fix --------- Co-authored-by: Carlos Rodriguez Co-authored-by: DimitrisJim --- .../27-interchain-accounts/controller/keeper/relay.go | 5 +++++ .../controller/keeper/relay_test.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index 54fce59e4fe..f728455e646 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" @@ -27,6 +28,10 @@ func (k Keeper) SendTx(ctx sdk.Context, _ *capabilitytypes.Capability, connectio } func (k Keeper) sendTx(ctx sdk.Context, connectionID, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) { + if !k.GetParams(ctx).ControllerEnabled { + return 0, types.ErrControllerSubModuleDisabled + } + activeChannelID, found := k.GetOpenActiveChannel(ctx, connectionID, portID) if !found { return 0, errorsmod.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel on connection %s for port %s", connectionID, portID) 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 872c041b4c4..f1fe089bb57 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" @@ -113,6 +114,13 @@ func (suite *KeeperTestSuite) TestSendTx() { }, false, }, + { + "controller submodule disabled", + func() { + suite.chainA.GetSimApp().ICAControllerKeeper.SetParams(suite.chainA.GetContext(), types.NewParams(false)) + }, + false, + }, { "timeout timestamp is not in the future", func() {