-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add e2e for changing controller params. #3872
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b061b53
Add e2e for changing controller params.
DimitrisJim 2c79c4d
address feedback.
DimitrisJim ae360e0
Separate imports by source.
DimitrisJim 664ff49
Merge branch 'main' into add-controller-e2e-params-test
DimitrisJim 0ae4c17
Merge branch 'main' into add-controller-e2e-params-test
crodriguezvega File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
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" | ||
"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" | ||
) | ||
|
||
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 | ||
} | ||
|
||
DimitrisJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TestControllerEnabledParam tests that changing the ControllerEnabled param works as expected | ||
func (s *InterchainAccountsParamsTestSuite) TestControllerEnabledParam() { | ||
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 controller account on chainA | ||
controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||
controllerAddress := controllerAccount.FormattedAddress() | ||
|
||
t.Run("ensure the controller is enabled", func(t *testing.T) { | ||
params := s.QueryControllerParams(ctx, chainA) | ||
s.Require().True(params.ControllerEnabled) | ||
}) | ||
|
||
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) | ||
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("ensure controller is disabled", func(t *testing.T) { | ||
params := s.QueryControllerParams(ctx, chainA) | ||
s.Require().False(params.ControllerEnabled) | ||
}) | ||
|
||
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) | ||
|
||
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount) | ||
s.AssertTxFailure(txResp, controllertypes.ErrControllerSubModuleDisabled) | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we will need to add this to our compatibility test matrix