-
Notifications
You must be signed in to change notification settings - Fork 579
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 ICS27 e2e test with governance #2808
Merged
chatton
merged 23 commits into
main
from
cian/issue#2063-add-ics27-e2e-test-with-governance
Nov 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
df9f768
wip
chatton 426237b
wip
chatton f93b519
chore: merge main
chatton 527db9a
chore: uncommenting test
chatton 2a25091
chore: test correctly working
chatton 76ceb52
wip: e2e governance test not yet passing
chatton de2e56a
chore: sleep in test
chatton 67f3c1d
chore: adding configure factory opt to broadcaster
chatton 15dc975
chore: merging main
chatton 362cba9
chore: wip gov test
chatton d25eba7
test: performing second SendTx via governance
chatton 24b1348
chore: moving test into separate file
chatton 3c18482
chore: reverted changes to run-e2e.sh
chatton 409f205
chore: reverted temporary changing of validator number
chatton debea05
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton 0ce623d
chore: adding time between relayer start and ica account verification
chatton abb89a8
chore: bump default relayer version to v2.1.2
chatton 2cc5a14
chore: removing unused function
chatton b5954d9
chore: addressing PR feedback
chatton 5ab176b
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton b0eea6e
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton 192d19b
chore: addressing PR feedback
chatton a4ae2b3
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton 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
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
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 |
---|---|---|
|
@@ -4,14 +4,15 @@ import ( | |
"context" | ||
"errors" | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
grouptypes "github.com/cosmos/cosmos-sdk/x/group" | ||
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||
intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" | ||
|
@@ -34,7 +35,6 @@ import ( | |
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" | ||
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" | ||
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types" | ||
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params" | ||
) | ||
|
||
const ( | ||
|
@@ -76,8 +76,8 @@ type GRPCClients struct { | |
InterTxQueryClient intertxtypes.QueryClient | ||
|
||
// SDK query clients | ||
GovQueryClient govtypes.QueryClient | ||
GovQueryClientV1 govtypesv1.QueryClient | ||
GovQueryClient govtypesv1beta1.QueryClient | ||
GovQueryClientV1 govtypesv1.QueryClient | ||
GroupsQueryClient grouptypes.QueryClient | ||
ParamsQueryClient paramsproposaltypes.QueryClient | ||
AuthQueryClient authtypes.QueryClient | ||
|
@@ -386,7 +386,7 @@ func (s *E2ETestSuite) initGRPCClients(chain *cosmos.CosmosChain) { | |
FeeQueryClient: feetypes.NewQueryClient(grpcConn), | ||
ICAQueryClient: controllertypes.NewQueryClient(grpcConn), | ||
InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn), | ||
GovQueryClient: govtypes.NewQueryClient(grpcConn), | ||
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn), | ||
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn), | ||
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn), | ||
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn), | ||
|
@@ -457,12 +457,12 @@ func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibc.Walle | |
} | ||
|
||
// ExecuteGovProposal submits the given governance proposal using the provided user and uses all validators to vote yes on the proposal. | ||
// It ensure the proposal successfully passes. | ||
func (s *E2ETestSuite) ExecuteGovProposal(ctx context.Context, chain *cosmos.CosmosChain, user *ibc.Wallet, content govtypes.Content) { | ||
// It ensures the proposal successfully passes. | ||
func (s *E2ETestSuite) ExecuteGovProposal(ctx context.Context, chain *cosmos.CosmosChain, user *ibc.Wallet, content govtypesv1beta1.Content) { | ||
sender, err := sdk.AccAddressFromBech32(user.Bech32Address(chain.Config().Bech32Prefix)) | ||
s.Require().NoError(err) | ||
|
||
msgSubmitProposal, err := govtypes.NewMsgSubmitProposal(content, sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, govtypes.DefaultMinDepositTokens)), sender) | ||
msgSubmitProposal, err := govtypesv1beta1.NewMsgSubmitProposal(content, sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, govtypesv1beta1.DefaultMinDepositTokens)), sender) | ||
s.Require().NoError(err) | ||
|
||
txResp, err := s.BroadcastMessages(ctx, chain, user, msgSubmitProposal) | ||
|
@@ -474,56 +474,71 @@ func (s *E2ETestSuite) ExecuteGovProposal(ctx context.Context, chain *cosmos.Cos | |
|
||
proposal, err := s.QueryProposal(ctx, chain, 1) | ||
s.Require().NoError(err) | ||
s.Require().Equal(govtypes.StatusVotingPeriod, proposal.Status) | ||
s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposal.Status) | ||
|
||
err = chain.VoteOnProposalAllValidators(ctx, "1", cosmos.ProposalVoteYes) | ||
s.Require().NoError(err) | ||
|
||
// ensure voting period has not passed before validators finished voting | ||
proposal, err = s.QueryProposal(ctx, chain, 1) | ||
s.Require().NoError(err) | ||
s.Require().Equal(govtypes.StatusVotingPeriod, proposal.Status) | ||
s.Require().Equal(govtypesv1beta1.StatusVotingPeriod, proposal.Status) | ||
|
||
time.Sleep(testvalues.VotingPeriod) // pass proposal | ||
|
||
proposal, err = s.QueryProposal(ctx, chain, 1) | ||
s.Require().NoError(err) | ||
s.Require().Equal(govtypes.StatusPassed, proposal.Status) | ||
s.Require().Equal(govtypesv1beta1.StatusPassed, proposal.Status) | ||
} | ||
|
||
// ExecuteGovProposalV1 submits a governance proposal using the provided user and message and uses all validators | ||
// to vote yes on the proposal. It ensures the proposal successfully passes. | ||
func (s *E2ETestSuite) ExecuteGovProposalV1(ctx context.Context, msg sdk.Msg, chain *cosmos.CosmosChain, user *ibc.Wallet, proposalID uint64) { | ||
sender, err := sdk.AccAddressFromBech32(user.Bech32Address(chain.Config().Bech32Prefix)) | ||
s.Require().NoError(err) | ||
|
||
msgs := []sdk.Msg{msg} | ||
msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, govtypesv1.DefaultMinDepositTokens)), sender.String(), "") | ||
s.Require().NoError(err) | ||
|
||
resp, err := s.BroadcastMessages(ctx, chain, user, msgSubmitProposal) | ||
s.AssertValidTxResponse(resp) | ||
s.Require().NoError(err) | ||
|
||
s.Require().NoError(chain.VoteOnProposalAllValidators(ctx, strconv.Itoa(int(proposalID)), cosmos.ProposalVoteYes)) | ||
|
||
time.Sleep(testvalues.VotingPeriod) | ||
|
||
proposal, err := s.QueryProposalV1(ctx, chain, proposalID) | ||
s.Require().NoError(err) | ||
s.Require().Equal(govtypesv1.StatusPassed, proposal.Status) | ||
} | ||
Comment on lines
+496
to
+515
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @colin-axner added this helper function as suggested 👍 |
||
|
||
// QueryModuleAccountAddress returns the sdk.AccAddress of a given module name. | ||
func (s *E2ETestSuite) QueryModuleAccountAddress(ctx context.Context, moduleName string, chain *cosmos.CosmosChain) (sdk.AccAddress, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice addition :) |
||
authClient := s.GetChainGRCPClients(chain).AuthQueryClient | ||
|
||
moduleAccountsResponse, err := authClient.ModuleAccounts(ctx, &authtypes.QueryModuleAccountsRequest{}) | ||
resp, err := authClient.ModuleAccountByName(ctx, &authtypes.QueryModuleAccountByNameRequest{ | ||
Name: moduleName, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
cfg := simappparams.MakeTestEncodingConfig() | ||
authtypes.RegisterInterfaces(cfg.InterfaceRegistry) | ||
|
||
for _, acc := range moduleAccountsResponse.Accounts { | ||
var account authtypes.AccountI | ||
err := cfg.InterfaceRegistry.UnpackAny(acc, &account) | ||
if err != nil { | ||
return nil, err | ||
} | ||
moduleAccount, ok := account.(authtypes.ModuleAccountI) | ||
if !ok { | ||
return nil, errors.New(fmt.Sprintf("failed to cast account: %T as ModuleAccount", moduleAccount)) | ||
} | ||
cfg := EncodingConfig() | ||
|
||
if moduleAccount.GetName() == moduleName { | ||
return moduleAccount.GetAddress(), nil | ||
} | ||
var account authtypes.AccountI | ||
if err := cfg.InterfaceRegistry.UnpackAny(resp.Account, &account); err != nil { | ||
return nil, err | ||
} | ||
moduleAccount, ok := account.(authtypes.ModuleAccountI) | ||
if !ok { | ||
return nil, errors.New(fmt.Sprintf("failed to cast account: %T as ModuleAccount", moduleAccount)) | ||
} | ||
|
||
return nil, errors.New(fmt.Sprintf("failed to find address for module account: %s", moduleName)) | ||
return moduleAccount.GetAddress(), nil | ||
} | ||
|
||
|
||
// GetIBCToken returns the denomination of the full token denom sent to the receiving channel | ||
func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes.DenomTrace { | ||
return transfertypes.ParseDenomTrace(fmt.Sprintf("%s/%s/%s", portID, channelID, fullTokenDenom)) | ||
|
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.
nit on separation of imports
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.
Based on the three categories of imports stdlib / external libs / our libs, I would say that these imports are correctly grouped.
WDYT?