-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e: added ICS27 e2e test with governance. (#2808)
- Loading branch information
Showing
13 changed files
with
223 additions
and
25 deletions.
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
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
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
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,116 @@ | ||
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" | ||
"github.com/gogo/protobuf/proto" | ||
"github.com/strangelove-ventures/ibctest/v6" | ||
"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) | ||
|
||
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("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) { | ||
version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) | ||
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version) | ||
s.ExecuteGovProposalV1(ctx, msgRegisterAccount, chainA, controllerAccount, 1) | ||
}) | ||
|
||
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 registration success", func(t *testing.T) { | ||
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("execute proposal for MsgSendTx", func(t *testing.T) { | ||
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) | ||
s.ExecuteGovProposalV1(ctx, msgSendTx, chainA, controllerAccount, 2) | ||
}) | ||
|
||
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) | ||
}) | ||
}) | ||
} |
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
Oops, something went wrong.