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

Add ICS27 e2e test with governance #2808

Merged
merged 23 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
df9f768
wip
chatton Sep 7, 2022
426237b
wip
chatton Sep 8, 2022
f93b519
chore: merge main
chatton Oct 13, 2022
527db9a
chore: uncommenting test
chatton Oct 13, 2022
2a25091
chore: test correctly working
chatton Oct 13, 2022
76ceb52
wip: e2e governance test not yet passing
chatton Oct 14, 2022
de2e56a
chore: sleep in test
chatton Oct 14, 2022
67f3c1d
chore: adding configure factory opt to broadcaster
chatton Oct 25, 2022
15dc975
chore: merging main
chatton Nov 21, 2022
362cba9
chore: wip gov test
chatton Nov 21, 2022
d25eba7
test: performing second SendTx via governance
chatton Nov 22, 2022
24b1348
chore: moving test into separate file
chatton Nov 22, 2022
3c18482
chore: reverted changes to run-e2e.sh
chatton Nov 22, 2022
409f205
chore: reverted temporary changing of validator number
chatton Nov 22, 2022
debea05
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton Nov 22, 2022
0ce623d
chore: adding time between relayer start and ica account verification
chatton Nov 22, 2022
abb89a8
chore: bump default relayer version to v2.1.2
chatton Nov 22, 2022
2cc5a14
chore: removing unused function
chatton Nov 22, 2022
b5954d9
chore: addressing PR feedback
chatton Nov 22, 2022
5ab176b
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton Nov 22, 2022
b0eea6e
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton Nov 22, 2022
192d19b
chore: addressing PR feedback
chatton Nov 23, 2022
a4ae2b3
Merge branch 'main' into cian/issue#2063-add-ics27-e2e-test-with-gove…
chatton Nov 23, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility-workflow-call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
CHAIN_A_TAG: "${{ matrix.chain-a }}"
CHAIN_B_TAG: "${{ matrix.chain-b }}"
CHAIN_BINARY: "${{ matrix.chain-binary }}"
RLY_TAG: "v2.0.0"
RLY_TAG: "v2.1.2"
Copy link
Contributor Author

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.

2 changes: 1 addition & 1 deletion .github/workflows/e2e-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Run e2e Test
env:
# see images here https://github.com/cosmos/relayer/pkgs/container/relayer/versions
RLY_TAG: "v2.0.0"
RLY_TAG: "v2.1.2"
run: |
cd e2e
make e2e-test entrypoint=${{ matrix.entrypoint }} test=${{ matrix.test }}
2 changes: 1 addition & 1 deletion .github/workflows/e2e-manual-icad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ on:
relayer-tag:
description: 'The tag to use for the relayer'
required: true
default: "v2.0.0"
default: "v2.1.2"
type: string


Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/e2e-manual-simd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- TestConnectionTestSuite
- TestInterchainAccountsTestSuite
- TestInterchainAccountsGroupsTestSuite
- TestInterchainAccountsGovTestSuite
- TestIncentivizedInterchainAccountsTestSuite
chain-image:
description: 'The image to use for chain A'
Expand Down Expand Up @@ -56,7 +57,7 @@ on:
relayer-tag:
description: 'The tag to use for the relayer'
required: true
default: "v2.0.0"
default: "v2.1.2"
type: string


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ on:
relayer-tag:
description: 'The tag to use for the relayer'
required: true
default: "v2.0.0"
default: "v2.1.2"
type: string
build-and-push-docker-image:
description: "Flag to specify if the docker image should be built and pushed beforehand"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-a-tag: "${{ needs.determine-image-tag.outputs.simd-tag }}"
chain-b-tag: "${{ needs.determine-image-tag.outputs.simd-tag }}"
relayer-tag: "v2.0.0"
relayer-tag: "v2.1.2"
chain-binary: "simd"
# on regular PRs we won't run interchain account or upgrade tests.
test-exclusions: "TestInterTxTestSuite,TestIncentivizedInterTxTestSuite,TestUpgradeTestSuite"
4 changes: 2 additions & 2 deletions e2e/scripts/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ ENTRY_POINT="${1}"
TEST="${2}"

export CHAIN_A_TAG="${CHAIN_A_TAG:-latest}"
export CHAIN_A_IMAGE="${CHAIN_A_IMAGE:-ibc-go-simd}"
export CHAIN_IMAGE="${CHAIN_IMAGE:-ibc-go-simd}"
export CHAIN_BINARY="${CHAIN_BINARY:-simd}"

# In CI, the docker images will be built separately.
# context for building the image is one directory up.
if [ "${CI:-}" != "true" ]
then
(cd ..; docker build . -t "${CHAIN_A_IMAGE}:${CHAIN_A_TAG}")
(cd ..; docker build . -t "${CHAIN_IMAGE}:${CHAIN_A_TAG}")
fi

go test -v ./tests/... --run ${ENTRY_POINT} -testify.m ^${TEST}$
4 changes: 3 additions & 1 deletion e2e/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 simd images tagged with main. And the go relayer at main as well.

}

chainBTag, ok := os.LookupEnv(ChainBTagEnv)
Expand Down
1 change: 0 additions & 1 deletion e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/cosmos/ibc-go/e2e/testconfig"
"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"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
Expand Down
149 changes: 149 additions & 0 deletions e2e/tests/interchain_accounts/gov_test.go
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"
Copy link
Contributor

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

Copy link
Contributor Author

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?

"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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Run("create msg submit proposal", func(t *testing.T) {
t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) {

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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("vote on proposal for MsgRegisterInterchainAccount", ...)?


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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Run("verify interchain account", func(t *testing.T) {
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("create msg submit proposal", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Run("create msg submit proposal", func(t *testing.T) {
t.Run("submit 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)
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous comment: t.Run("vote on proposal for MsgSendTx", ...)?


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)
})
})
}
2 changes: 2 additions & 0 deletions e2e/testsuite/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testsuite

import (
"github.com/cosmos/cosmos-sdk/codec"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

Expand All @@ -12,6 +13,7 @@ func Codec() *codec.ProtoCodec {
cfg := simappparams.MakeTestEncodingConfig()
banktypes.RegisterInterfaces(cfg.InterfaceRegistry)
govv1beta1.RegisterInterfaces(cfg.InterfaceRegistry)
authtypes.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)
return cdc
}
21 changes: 17 additions & 4 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package testsuite
import (
"context"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesbeta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types"
"github.com/strangelove-ventures/ibctest/v6/chain/cosmos"
"github.com/strangelove-ventures/ibctest/v6/ibc"
Expand Down Expand Up @@ -120,14 +121,26 @@ func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Cha
}

// QueryProposal queries the governance proposal on the given chain with the given proposal ID.
func (s *E2ETestSuite) QueryProposal(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypes.Proposal, error) {
func (s *E2ETestSuite) QueryProposal(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypesbeta1.Proposal, error) {
queryClient := s.GetChainGRCPClients(chain).GovQueryClient
res, err := queryClient.Proposal(ctx, &govtypes.QueryProposalRequest{
res, err := queryClient.Proposal(ctx, &govtypesbeta1.QueryProposalRequest{
ProposalId: proposalID,
})
if err != nil {
return govtypes.Proposal{}, err
return govtypesbeta1.Proposal{}, err
}

return res.Proposal, nil
}

func (s *E2ETestSuite) QueryProposalV1(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypesv1.Proposal, error) {
queryClient := s.GetChainGRCPClients(chain).GovQueryClientV1
res, err := queryClient.Proposal(ctx, &govtypesv1.QueryProposalRequest{
ProposalId: proposalID,
})
if err != nil {
return govtypesv1.Proposal{}, err
}

return *res.Proposal, nil
}
Loading