Skip to content
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

e2e: adding simd controller msg server tests #2572

Merged
merged 13 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/e2e-manual-icad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
required: true
type: choice
options:
- TestInterchainAccountsTestSuite
- TestIncentivizedInterchainAccountsTestSuite
- TestInterTxTestSuite
- TestIncentivizedInterTxTestSuite
chain-image:
description: 'The image to use for chain A'
required: true
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/e2e-manual-simd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
options:
- TestTransferTestSuite
- TestIncentivizedTransferTestSuite
- TestInterchainAccountsTestSuite
- TestInterchainAccountsGroupsTestSuite
- TestIncentivizedInterchainAccountsTestSuite
chain-image:
description: 'The image to use for chain A'
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
relayer-tag: "v2.0.0"
chain-binary: "simd"
# on regular PRs we won't run interchain account or upgrade tests.
test-exclusions: "TestInterchainAccountsTestSuite,TestIncentivizedInterchainAccountsTestSuite,TestUpgradeTestSuite"
test-exclusions: "TestInterTxTestSuite,TestIncentivizedInterTxTestSuite,TestUpgradeTestSuite"
88 changes: 53 additions & 35 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package interchain_accounts
import (
"context"
"testing"
"time"

ibctest "github.com/strangelove-ventures/ibctest/v6"
"github.com/strangelove-ventures/ibctest/v6/chain/cosmos"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/stretchr/testify/suite"
"golang.org/x/mod/semver"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types"
Expand All @@ -19,9 +21,11 @@ import (
"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"
feetypes "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
)

func TestInterchainAccountsTestSuite(t *testing.T) {
Expand Down Expand Up @@ -60,7 +64,7 @@ func getICAVersion(chainAVersion, chainBVersion string) string {
return icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)
}

func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer() {
func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() {
t := s.T()
ctx := context.TODO()

Expand All @@ -75,11 +79,13 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer() {
chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
var hostAccount string

t.Run("register interchain account", func(t *testing.T) {
t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) {
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -88,7 +94,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer() {

t.Run("verify interchain account", func(t *testing.T) {
var err error
hostAccount, err = s.QueryInterchainAccountLegacy(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
s.Require().NoError(err)
s.Require().NotZero(len(hostAccount))

Expand All @@ -108,30 +114,34 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer() {
s.Require().NoError(err)
})

t.Run("broadcast MsgSubmitTx", func(t *testing.T) {
t.Run("broadcast MsgSendTx", func(t *testing.T) {
// assemble bank transfer message from host account to user account on host chain
msgSend := &banktypes.MsgSend{
FromAddress: hostAccount,
ToAddress: chainBAccount.Bech32Address(chainB.Config().Bech32Prefix),
Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
}

// assemble submitMessage tx for intertx
msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(
msgSend,
ibctesting.FirstConnectionID,
controllerAccount.Bech32Address(chainA.Config().Bech32Prefix),
)
cfg := simappparams.MakeTestEncodingConfig()
banktypes.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)

bz, err := icatypes.SerializeCosmosTx(cdc, []sdk.Msg{msgSend})
s.Require().NoError(err)

// broadcast submitMessage tx from controller account on chain A
// this message should trigger the sending of an ICA packet over channel-1 (channel created between controller and host)
// this ICA packet contains the assembled bank transfer message from above, which will be executed by the host account on the host chain.
packetData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: bz,
Memo: "e2e",
}

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
msgSubmitTx,
msgSendTx,
)

s.AssertValidTxResponse(resp)
Expand All @@ -153,7 +163,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer() {
})
}

func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_FailedTransfer_InsufficientFunds() {
func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientFunds() {
t := s.T()
ctx := context.TODO()

Expand All @@ -168,11 +178,13 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_FailedTransfer_Insufficien
chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
var hostAccount string

t.Run("register interchain account", func(t *testing.T) {
t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) {
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -181,7 +193,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_FailedTransfer_Insufficien

t.Run("verify interchain account", func(t *testing.T) {
var err error
hostAccount, err = s.QueryInterchainAccountLegacy(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
s.Require().NoError(err)
s.Require().NotZero(len(hostAccount))

Expand All @@ -197,34 +209,40 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_FailedTransfer_Insufficien
s.Require().Zero(hostAccountBalance)
})

t.Run("broadcast MsgSubmitTx", func(t *testing.T) {
t.Run("broadcast MsgSendTx", func(t *testing.T) {
// assemble bank transfer message from host account to user account on host chain
transferMsg := &banktypes.MsgSend{
msgSend := &banktypes.MsgSend{
FromAddress: hostAccount,
ToAddress: chainBAccount.Bech32Address(chainB.Config().Bech32Prefix),
Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
}

// assemble submitMessage tx for intertx
submitMsg, err := intertxtypes.NewMsgSubmitTx(
transferMsg,
ibctesting.FirstConnectionID,
controllerAccount.Bech32Address(chainA.Config().Bech32Prefix),
)
cfg := simappparams.MakeTestEncodingConfig()
banktypes.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)

bz, err := icatypes.SerializeCosmosTx(cdc, []sdk.Msg{msgSend})
s.Require().NoError(err)

// broadcast submitMessage tx from controller account on chain A
// this message should trigger the sending of an ICA packet over channel-1 (channel created between controller and host)
// this ICA packet contains the assembled bank transfer message from above, which will be executed by the host account on the host chain.
resp, err := s.BroadcastMessages(
packetData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: bz,
Memo: "e2e",
}

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

txResp, err := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
submitMsg,
msgSendTx,
)

s.AssertValidTxResponse(resp)
s.AssertValidTxResponse(txResp)
s.Require().NoError(err)

s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
})

t.Run("verify balance is the same", func(t *testing.T) {
Expand Down
73 changes: 54 additions & 19 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ package interchain_accounts
import (
"context"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types"
ibctest "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/testconfig"
"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"
feetypes "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
)

func TestIncentivizedInterchainAccountsTestSuite(t *testing.T) {
Expand All @@ -25,7 +30,7 @@ type IncentivizedInterchainAccountsTestSuite struct {
InterchainAccountsTestSuite
}

func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBankSend_Incentivized() {
func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSend_Incentivized() {
t := s.T()
ctx := context.TODO()

Expand Down Expand Up @@ -60,11 +65,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank
controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)

t.Run("register interchain account", func(t *testing.T) {
version := "" // allow app to handle the version as appropriate.
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) {
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -74,7 +81,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank
var channelOutput ibc.ChannelOutput
t.Run("verify interchain account", func(t *testing.T) {
var err error
interchainAcc, err = s.QueryInterchainAccountLegacy(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
interchainAcc, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
s.Require().NoError(err)
s.Require().NotZero(len(interchainAcc))

Expand All @@ -84,6 +91,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank

// interchain accounts channel at index: 0
channelOutput = channels[0]

s.Require().NoError(test.WaitForBlocks(ctx, 2, chainA, chainB))
})

t.Run("execute interchain account bank send through controller", func(t *testing.T) {
Expand Down Expand Up @@ -119,7 +128,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank
s.StopRelayer(ctx, relayer)
})

t.Run("broadcast incentivized MsgSubmitTx", func(t *testing.T) {
t.Run("broadcast incentivized MsgSendTx", func(t *testing.T) {
msgPayPacketFee := &feetypes.MsgPayPacketFee{
Fee: testvalues.DefaultFee(chainADenom),
SourcePortId: channelOutput.PortID,
Expand All @@ -133,10 +142,22 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank
Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
}

msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(msgSend, ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix))
cfg := simappparams.MakeTestEncodingConfig()
banktypes.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)

bz, err := icatypes.SerializeCosmosTx(cdc, []sdk.Msg{msgSend})
s.Require().NoError(err)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
packetData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: bz,
Memo: "e2e",
}

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)

Expand Down Expand Up @@ -193,7 +214,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulBank
})
}

func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_FailedBankSend_Incentivized() {
func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_Incentivized() {
t := s.T()
ctx := context.TODO()

Expand Down Expand Up @@ -228,11 +249,13 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_FailedBankSend
controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)

t.Run("register interchain account", func(t *testing.T) {
version := "" // allow app to handle the version as appropriate.
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
t.Run("broadcast MsgRegisterInterchainAccount", func(t *testing.T) {
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -242,7 +265,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_FailedBankSend
var channelOutput ibc.ChannelOutput
t.Run("verify interchain account", func(t *testing.T) {
var err error
interchainAcc, err = s.QueryInterchainAccountLegacy(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
interchainAcc, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID)
s.Require().NoError(err)
s.Require().NotZero(len(interchainAcc))

Expand Down Expand Up @@ -280,7 +303,7 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_FailedBankSend
s.Require().NoError(err)
})

t.Run("broadcast incentivized MsgSubmitTx", func(t *testing.T) {
t.Run("broadcast incentivized MsgSendTx", func(t *testing.T) {
msgPayPacketFee := &feetypes.MsgPayPacketFee{
Fee: testvalues.DefaultFee(chainADenom),
SourcePortId: channelOutput.PortID,
Expand All @@ -294,10 +317,22 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSubmitTx_FailedBankSend
Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
}

msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(msgSend, ibctesting.FirstConnectionID, controllerAccount.Bech32Address(chainA.Config().Bech32Prefix))
cfg := simappparams.MakeTestEncodingConfig()
banktypes.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)

bz, err := icatypes.SerializeCosmosTx(cdc, []sdk.Msg{msgSend})
s.Require().NoError(err)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
packetData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: bz,
Memo: "e2e",
}

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.Bech32Address(chainA.Config().Bech32Prefix), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)

Expand Down
Loading