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: Add ICA MsgSubmitTx tests (success + failure) #2021

Merged
merged 35 commits into from
Aug 17, 2022
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8f44301
feat(test): adding support for backwards compatibility testing
chatton Aug 8, 2022
f470bcf
Merge branch 'main' into cian/issue#1911-support-backwards-compatibil…
chatton Aug 8, 2022
2297280
chore: made names of variables more descriptive
chatton Aug 8, 2022
4c30485
Merge branch 'cian/issue#1911-support-backwards-compatibility-tests' …
chatton Aug 8, 2022
cd6363c
wip: adding demo interchain accounts test
chatton Aug 9, 2022
d87a711
wip
chatton Aug 9, 2022
a9ceda1
merge main
chatton Aug 10, 2022
2ec4c73
wip
chatton Aug 10, 2022
39eff2f
chore: merge main
chatton Aug 12, 2022
17d5840
chore: pass -p events to relayer
chatton Aug 12, 2022
1c79319
wip: temporarily setting env vars in the test
chatton Aug 12, 2022
1db8103
chore: adding Make command to run test
chatton Aug 12, 2022
57067fb
work in progress ICA test using s.BroadcastMessages
charleenfei Aug 15, 2022
6890de3
chore: refactoring register ica account to broadcast message
chatton Aug 15, 2022
d147af9
wip update to test host account
charleenfei Aug 15, 2022
917a6a5
chore: converting query interchain account to grpc query call
chatton Aug 15, 2022
27cd4f8
chore: specify empty version string explicitly
chatton Aug 15, 2022
4afd01e
merge sample-test branch
chatton Aug 15, 2022
f452e8b
wip
charleenfei Aug 15, 2022
e0e33f1
Merge branch 'cian/refactor-register-ica' into cian/issue#1941-add-in…
charleenfei Aug 15, 2022
eb4bcb5
wip bank transfer
charleenfei Aug 15, 2022
85370a8
wip
charleenfei Aug 15, 2022
d96c0d5
cleanup tests
charleenfei Aug 16, 2022
83eaa6f
rm init env versions, handle unhappy path
charleenfei Aug 16, 2022
5328362
setup env
charleenfei Aug 16, 2022
289af25
chore: adding comment to outline temprorary usage of setting env vars
chatton Aug 16, 2022
0094b36
chore: merge main
chatton Aug 16, 2022
bd9ebc4
chore: removing unused code
chatton Aug 16, 2022
61a444e
chore: exporting GetRelayerExecReporter method
chatton Aug 16, 2022
50c9375
chore: adding wait for blocks
chatton Aug 16, 2022
bb08d13
chore: updating names of test functions
chatton Aug 16, 2022
f9de6e6
chore: updating test name
chatton Aug 16, 2022
e688082
chore: corrected typo
chatton Aug 16, 2022
cf8a8bc
chrore: split test into two separate test cases
chatton Aug 16, 2022
609d93d
chore: addressing PR feedback
chatton Aug 17, 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
Prev Previous commit
Next Next commit
chore: refactoring register ica account to broadcast message
chatton committed Aug 15, 2022
commit 6890de3ca53219c0f3e5ca406b245a7e01ed6625
3 changes: 2 additions & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp
require (
github.com/cosmos/cosmos-sdk v0.46.0
github.com/cosmos/ibc-go/v5 v5.0.0-beta1
github.com/cosmos/interchain-accounts v0.3.0
github.com/docker/docker v20.10.17+incompatible
github.com/strangelove-ventures/ibctest v0.0.0-20220808203516-6cbd3743756d
github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.21.0
google.golang.org/grpc v1.48.0
gopkg.in/yaml.v2 v2.4.0
)

require (
@@ -153,6 +153,7 @@ require (
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.3.0 // indirect
lukechampine.com/uint128 v1.1.1 // indirect
2 changes: 2 additions & 0 deletions e2e/go.sum
Original file line number Diff line number Diff line change
@@ -256,6 +256,8 @@ github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps=
github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA=
github.com/cosmos/ibc-go/v5 v5.0.0-beta1 h1:YqC9giQlZId8Wui8xpaUFI+TpVmEupQZSoDlmxAu6yI=
github.com/cosmos/ibc-go/v5 v5.0.0-beta1/go.mod h1:9mmcbzuidgX7nhafIKng/XhXAHDEnRqDjGy/60W1cvg=
github.com/cosmos/interchain-accounts v0.3.0 h1:Zu9372ze/a6HhUy5Z4Mu+C+FcnNLGrQ15aPwr6lRTeI=
github.com/cosmos/interchain-accounts v0.3.0/go.mod h1:FYF1IiAz6M/LC1Gb3Jch042IaL0AXOfU+s1ZGvR4IqI=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
98 changes: 10 additions & 88 deletions e2e/interchain_accounts_test.go
Original file line number Diff line number Diff line change
@@ -2,23 +2,20 @@ package e2e

import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
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"
"github.com/strangelove-ventures/ibctest"
"github.com/strangelove-ventures/ibctest/chain/cosmos"
"github.com/strangelove-ventures/ibctest/ibc"
"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v2"

"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
)

func init() {
@@ -48,19 +45,15 @@ func (s *InterchainAccountsTestSuite) TestInterchainAccounts() {
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx)
chainA, chainB := s.GetChains()

_ = chainB
_ = relayer
_ = channelA

connectionId := "connection-0"
controllerWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)

t.Run("register interchain account", func(t *testing.T) {
account, err := s.RegisterICA(ctx, chainA, controllerWallet.KeyName, connectionId)
err := s.RegisterICA(ctx, chainA, controllerWallet, controllerWallet.Bech32Address(chainA.Config().Bech32Prefix), connectionId)
s.Require().NoError(err)
s.Require().NotEmpty(account)
s.T().Logf("account created: %s", account)
})

t.Run("start relayer", func(t *testing.T) {
@@ -89,54 +82,19 @@ func (s *InterchainAccountsTestSuite) TestInterchainAccounts() {

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

tokenOnChainBFromChainA := getIBCToken(chainA.Config().Denom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)

balance, err := chainB.GetBalance(ctx, chainBWallet.Bech32Address(chainB.Config().Bech32Prefix), tokenOnChainBFromChainA.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
s.Require().Equal(expected, balance)
})
}

// TODO: replace the below methods with transaction broadcasts.

type IBCTransferTx struct {
TxHash string `json:"txhash"`
}

// 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))
}

// RegisterICA will attempt to register an interchain account on the counterparty chain.
func (*InterchainAccountsTestSuite) RegisterICA(ctx context.Context, chain *cosmos.CosmosChain, address, connectionID string) (string, error) {
config := chain.Config()
node := chain.ChainNodes[0]
command := []string{config.Bin, "tx", "intertx", "register",
"--from", address,
"--connection-id", connectionID,
"--chain-id", config.ChainID,
"--home", node.HomeDir(),
"--node", fmt.Sprintf("tcp://%s:26657", node.HostName()),
"--keyring-backend", keyring.BackendTest,
"-y",
}

stdout, _, err := node.Exec(ctx, command, nil)
if err != nil {
return "", err
}
output := IBCTransferTx{}
err = yaml.Unmarshal(stdout, &output)
if err != nil {
return "", err
}
return output.TxHash, nil
func (s *InterchainAccountsTestSuite) RegisterICA(ctx context.Context, chain *cosmos.CosmosChain, user *ibctest.User, fromAddress, connectionID string) error {
msg := intertxtypes.NewMsgRegisterAccount(fromAddress, connectionID, "")
txResp, err := s.BroadcastMessages(ctx, chain, user, msg)
s.AssertValidTxResponse(txResp)
return err
}

// TODO: replace the below methods with transaction broadcasts.

// QueryICA will query for an interchain account controlled by the specified address on the counterparty chain.
func (*InterchainAccountsTestSuite) QueryICA(ctx context.Context, chain *cosmos.CosmosChain, connectionID, address string) (string, error) {
config := chain.Config()
@@ -160,39 +118,3 @@ func (*InterchainAccountsTestSuite) QueryICA(ctx context.Context, chain *cosmos.
}
return strings.TrimSpace(parts[1]), nil
}

// SendICABankTransfer builds a bank transfer message for a specified address and sends it to the specified
// interchain account.
func (*InterchainAccountsTestSuite) SendICABankTransfer(ctx context.Context, chain *cosmos.CosmosChain, connectionID string, amount ibc.WalletAmount, toAddr string) error {
config := chain.Config()
node := chain.ChainNodes[0]

msg, err := json.Marshal(map[string]any{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": amount.Address,
"to_address": toAddr,
"amount": []map[string]any{
{
"denom": amount.Denom,
"amount": amount.Amount,
},
},
})
if err != nil {
return err
}

command := []string{
config.Bin, "tx", "intertx", "submit", string(msg),
"--connection-id", connectionID,
"--from", amount.Address,
"--chain-id", node.Chain.Config().ChainID,
"--home", node.HomeDir(),
"--node", fmt.Sprintf("tcp://%s:26657", node.HostName()),
"--keyring-backend", keyring.BackendTest,
"-y",
}

_, _, err = node.Exec(ctx, command, nil)
return err
}