From b061b53911dfc2d6a18f7bfd0984884bc0315cc7 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 16 Jun 2023 13:28:56 +0300 Subject: [PATCH 1/3] Add e2e for changing controller params. --- e2e/tests/interchain_accounts/params_test.go | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 e2e/tests/interchain_accounts/params_test.go diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go new file mode 100644 index 00000000000..93349afc29d --- /dev/null +++ b/e2e/tests/interchain_accounts/params_test.go @@ -0,0 +1,92 @@ +package interchain_accounts + +import ( + "context" + "testing" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + + controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" + icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + + "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testvalues" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + "github.com/stretchr/testify/suite" +) + +func TestInterchainAccountsParamsTestSuite(t *testing.T) { + suite.Run(t, new(InterchainAccountsParamsTestSuite)) +} + +type InterchainAccountsParamsTestSuite struct { + testsuite.E2ETestSuite +} + +// QueryControllerParams queries the params for the controller +func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Context, chain ibc.Chain) controllertypes.Params { + queryClient := s.GetChainGRCPClients(chain).ICAControllerQueryClient + res, err := queryClient.Params(ctx, &controllertypes.QueryParamsRequest{}) + s.Require().NoError(err) + + return *res.Params +} + +func (s *InterchainAccountsParamsTestSuite) TestControllerParams() { + t := s.T() + ctx := context.TODO() + + // setup relayers and connection-0 between two chains + // channel-0 is a transfer channel but it will not be used in this test case + _, _ = s.SetupChainsRelayerAndChannel(ctx) + chainA, _ := s.GetChains() + chainAVersion := chainA.Config().Images[0].Version + + // setup 2 accounts: controller account on chain A, a second chain B account. + // host account will be created when the ICA is registered + controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + controllerAddress := controllerAccount.FormattedAddress() + + // Assert that default value for enabled is true. + t.Run("validate the controller is enabled by default", func(t *testing.T) { + params := s.QueryControllerParams(ctx, chainA) + s.Require().True(params.ControllerEnabled) + }) + + t.Run("disable controller", func(t *testing.T) { + if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { + authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) + s.Require().NoError(err) + s.Require().NotNil(authority) + + msg := controllertypes.MsgUpdateParams{ + Authority: authority.String(), + Params: controllertypes.NewParams(false), + } + s.ExecuteGovProposalV1(ctx, &msg, chainA, controllerAccount, 1) + } else { + changes := []paramsproposaltypes.ParamChange{ + paramsproposaltypes.NewParamChange(controllertypes.StoreKey, string(controllertypes.KeyControllerEnabled), "false"), + } + + proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes) + s.ExecuteGovProposal(ctx, chainA, controllerAccount, proposal) + } + }) + + t.Run("validate the param was successfully changed", func(t *testing.T) { + params := s.QueryControllerParams(ctx, chainA) + s.Require().False(params.ControllerEnabled) + }) + + t.Run("assert that broadcasting a MsgRegisterInterchainAccount now fails", func(t *testing.T) { + // explicitly set the version string because we don't want to use incentivized channels. + version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) + msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) + + txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) + s.AssertTxFailure(txResp, controllertypes.ErrControllerSubModuleDisabled) + }) +} From 2c79c4d71b5d04eafe9b09a4fc0f8b2a9978e037 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 19 Jun 2023 03:42:49 +0300 Subject: [PATCH 2/3] address feedback. --- e2e/tests/interchain_accounts/params_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 93349afc29d..6e3466f5e88 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -34,7 +34,8 @@ func (s *InterchainAccountsParamsTestSuite) QueryControllerParams(ctx context.Co return *res.Params } -func (s *InterchainAccountsParamsTestSuite) TestControllerParams() { +// TestControllerEnabledParam tests that changing the ControllerEnabled param works as expected +func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { t := s.T() ctx := context.TODO() @@ -44,18 +45,16 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerParams() { chainA, _ := s.GetChains() chainAVersion := chainA.Config().Images[0].Version - // setup 2 accounts: controller account on chain A, a second chain B account. - // host account will be created when the ICA is registered + // setup controller account on chainA controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) controllerAddress := controllerAccount.FormattedAddress() - // Assert that default value for enabled is true. - t.Run("validate the controller is enabled by default", func(t *testing.T) { + t.Run("ensure the controller is enabled", func(t *testing.T) { params := s.QueryControllerParams(ctx, chainA) s.Require().True(params.ControllerEnabled) }) - t.Run("disable controller", func(t *testing.T) { + t.Run("disable the controller", func(t *testing.T) { if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) { authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) s.Require().NoError(err) @@ -76,12 +75,12 @@ func (s *InterchainAccountsParamsTestSuite) TestControllerParams() { } }) - t.Run("validate the param was successfully changed", func(t *testing.T) { + t.Run("ensure controller is disabled", func(t *testing.T) { params := s.QueryControllerParams(ctx, chainA) s.Require().False(params.ControllerEnabled) }) - t.Run("assert that broadcasting a MsgRegisterInterchainAccount now fails", func(t *testing.T) { + t.Run("ensure that broadcasting a MsgRegisterInterchainAccount fails", func(t *testing.T) { // explicitly set the version string because we don't want to use incentivized channels. version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version) From ae360e06d9f5ab18b177929ed19cc362736b63dc Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 19 Jun 2023 19:27:38 +0300 Subject: [PATCH 3/3] Separate imports by source. --- e2e/tests/interchain_accounts/params_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/e2e/tests/interchain_accounts/params_test.go b/e2e/tests/interchain_accounts/params_test.go index 6e3466f5e88..7f33a2523d9 100644 --- a/e2e/tests/interchain_accounts/params_test.go +++ b/e2e/tests/interchain_accounts/params_test.go @@ -6,15 +6,14 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + "github.com/stretchr/testify/suite" + "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testvalues" controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" - - "github.com/cosmos/ibc-go/e2e/testsuite" - "github.com/cosmos/ibc-go/e2e/testvalues" - "github.com/strangelove-ventures/interchaintest/v7/ibc" - "github.com/stretchr/testify/suite" ) func TestInterchainAccountsParamsTestSuite(t *testing.T) {