-
Notifications
You must be signed in to change notification settings - Fork 628
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
Changes from 18 commits
df9f768
426237b
f93b519
527db9a
2a25091
76ceb52
de2e56a
67f3c1d
15dc975
362cba9
d25eba7
24b1348
3c18482
409f205
debea05
0ce623d
abb89a8
2cc5a14
b5954d9
5ab176b
b0eea6e
192d19b
a4ae2b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ const ( | |
defaultBinary = "simd" | ||
// defaultRlyTag is the tag that will be used if no relayer tag is specified. | ||
defaultRlyTag = "main" | ||
// defaultChainTag is the tag that will be used for the chains if none is specified. | ||
defaultChainTag = "main" | ||
) | ||
|
||
func getChainImage(binary string) string { | ||
|
@@ -69,7 +71,7 @@ func FromEnv() TestConfig { | |
|
||
chainATag, ok := os.LookupEnv(ChainATagEnv) | ||
if !ok { | ||
panic(fmt.Sprintf("must specify %s version for test with environment variable [%s]", chainBinary, ChainATagEnv)) | ||
chainATag = defaultChainTag | ||
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. this lets us run the tests without setting any env vars. The default config will use |
||
} | ||
|
||
chainBTag, ok := os.LookupEnv(ChainBTagEnv) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,149 @@ | ||||||
package interchain_accounts | ||||||
|
||||||
import ( | ||||||
"context" | ||||||
"testing" | ||||||
"time" | ||||||
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types" | ||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||||||
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||||||
"github.com/gogo/protobuf/proto" | ||||||
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. nit on separation of imports 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. Based on the three categories of imports stdlib / external libs / our libs, I would say that these imports are correctly grouped. WDYT? |
||||||
"github.com/strangelove-ventures/ibctest/v6" | ||||||
"github.com/strangelove-ventures/ibctest/v6/chain/cosmos" | ||||||
"github.com/strangelove-ventures/ibctest/v6/ibc" | ||||||
"github.com/strangelove-ventures/ibctest/v6/test" | ||||||
"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/v6/modules/apps/27-interchain-accounts/controller/types" | ||||||
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types" | ||||||
ibctesting "github.com/cosmos/ibc-go/v6/testing" | ||||||
) | ||||||
|
||||||
func TestInterchainAccountsGovTestSuite(t *testing.T) { | ||||||
suite.Run(t, new(InterchainAccountsGovTestSuite)) | ||||||
} | ||||||
|
||||||
type InterchainAccountsGovTestSuite struct { | ||||||
testsuite.E2ETestSuite | ||||||
} | ||||||
|
||||||
func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration() { | ||||||
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 | ||||||
relayer, _ := s.SetupChainsRelayerAndChannel(ctx) | ||||||
chainA, chainB := s.GetChains() | ||||||
controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||||||
controllerAddress := controllerAccount.Bech32Address(chainA.Config().Bech32Prefix) | ||||||
|
||||||
chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) | ||||||
chainBAddress := chainBAccount.Bech32Address(chainB.Config().Bech32Prefix) | ||||||
|
||||||
govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) | ||||||
s.Require().NoError(err) | ||||||
s.Require().NotNil(govModuleAddress) | ||||||
|
||||||
t.Run("create msg submit proposal", func(t *testing.T) { | ||||||
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.
Suggested change
|
||||||
version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) | ||||||
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) | ||||||
msgs := []sdk.Msg{msgRegisterAccount} | ||||||
msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(sdk.NewCoin(chainA.Config().Denom, govtypesv1.DefaultMinDepositTokens)), controllerAddress, "") | ||||||
s.Require().NoError(err) | ||||||
|
||||||
resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgSubmitProposal) | ||||||
s.AssertValidTxResponse(resp) | ||||||
s.Require().NoError(err) | ||||||
}) | ||||||
|
||||||
s.Require().NoError(chainA.VoteOnProposalAllValidators(ctx, "1", cosmos.ProposalVoteYes)) | ||||||
|
||||||
time.Sleep(testvalues.VotingPeriod) | ||||||
time.Sleep(5 * time.Second) | ||||||
|
||||||
proposal, err := s.QueryProposalV1(ctx, chainA, 1) | ||||||
s.Require().NoError(err) | ||||||
s.Require().Equal(govtypesv1.StatusPassed, proposal.Status) | ||||||
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. Should we group the code between voting the proposal and checking the status in something like |
||||||
|
||||||
t.Run("start relayer", func(t *testing.T) { | ||||||
s.StartRelayer(relayer) | ||||||
}) | ||||||
|
||||||
s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB)) | ||||||
|
||||||
var interchainAccAddr string | ||||||
t.Run("verify interchain account", func(t *testing.T) { | ||||||
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.
Suggested change
|
||||||
var err error | ||||||
interchainAccAddr, err = s.QueryInterchainAccount(ctx, chainA, govModuleAddress.String(), ibctesting.FirstConnectionID) | ||||||
s.Require().NoError(err) | ||||||
s.Require().NotZero(len(interchainAccAddr)) | ||||||
|
||||||
channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID) | ||||||
s.Require().NoError(err) | ||||||
s.Require().Equal(len(channels), 2) | ||||||
}) | ||||||
|
||||||
t.Run("interchain account executes a bank transfer on behalf of the corresponding owner account", func(t *testing.T) { | ||||||
t.Run("fund interchain account wallet", func(t *testing.T) { | ||||||
// fund the host account, so it has some $$ to send | ||||||
err := chainB.SendFunds(ctx, ibctest.FaucetAccountKeyName, ibc.WalletAmount{ | ||||||
Address: interchainAccAddr, | ||||||
Amount: testvalues.StartingTokenAmount, | ||||||
Denom: chainB.Config().Denom, | ||||||
}) | ||||||
s.Require().NoError(err) | ||||||
}) | ||||||
|
||||||
t.Run("create msg submit proposal", func(t *testing.T) { | ||||||
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.
Suggested change
|
||||||
msgBankSend := &banktypes.MsgSend{ | ||||||
FromAddress: interchainAccAddr, | ||||||
ToAddress: chainBAddress, | ||||||
Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), | ||||||
} | ||||||
|
||||||
cdc := testsuite.Codec() | ||||||
bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgBankSend}) | ||||||
s.Require().NoError(err) | ||||||
|
||||||
packetData := icatypes.InterchainAccountPacketData{ | ||||||
Type: icatypes.EXECUTE_TX, | ||||||
Data: bz, | ||||||
Memo: "e2e", | ||||||
} | ||||||
|
||||||
msgSendTx := controllertypes.NewMsgSendTx(govModuleAddress.String(), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData) | ||||||
msgs := []sdk.Msg{msgSendTx} | ||||||
msgSubmitProposal, err := govtypesv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(sdk.NewCoin(chainA.Config().Denom, govtypesv1.DefaultMinDepositTokens)), controllerAddress, "") | ||||||
s.Require().NoError(err) | ||||||
|
||||||
resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgSubmitProposal) | ||||||
s.AssertValidTxResponse(resp) | ||||||
s.Require().NoError(err) | ||||||
}) | ||||||
|
||||||
s.Require().NoError(chainA.VoteOnProposalAllValidators(ctx, "2", cosmos.ProposalVoteYes)) | ||||||
|
||||||
time.Sleep(testvalues.VotingPeriod) | ||||||
time.Sleep(5 * time.Second) | ||||||
|
||||||
proposal, err := s.QueryProposalV1(ctx, chainA, 2) | ||||||
s.Require().NoError(err) | ||||||
s.Require().Equal(govtypesv1.StatusPassed, proposal.Status) | ||||||
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. Similar to the previous comment: |
||||||
|
||||||
t.Run("verify tokens transferred", func(t *testing.T) { | ||||||
balance, err := chainB.GetBalance(ctx, chainBAccount.Bech32Address(chainB.Config().Bech32Prefix), chainB.Config().Denom) | ||||||
s.Require().NoError(err) | ||||||
|
||||||
_, err = chainB.GetBalance(ctx, interchainAccAddr, chainB.Config().Denom) | ||||||
s.Require().NoError(err) | ||||||
|
||||||
expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount | ||||||
s.Require().Equal(expected, balance) | ||||||
}) | ||||||
}) | ||||||
} |
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.
this test requires a bump in the default relayer version.