Skip to content

Commit

Permalink
e2e: check that IBC tokens on destination chain have metadata (cosmos…
Browse files Browse the repository at this point in the history
…#4642)

* check that IBC tokens on destination chain have metadata

* typo

* add query function to retrieve account balances
  • Loading branch information
crodriguezvega committed Sep 15, 2023
1 parent acfe815 commit 242cb9f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {
s.Require().Equal(expected, actualBalance.Int64())
})

if testvalues.TokenMetadataFeatureReleases.IsSupported(chainBVersion) {
t.Run("metadata for token exists on chainB", func(t *testing.T) {
balances, err := s.QueryAllBalances(ctx, chainB, chainBAddress, true)
s.Require().NoError(err)

// balance for IBC token returns a human-readable denomination
s.Require().Equal(chainBIBCToken.GetFullDenomPath(), balances[1].Denom)
})
}

t.Run("non-native IBC token transfer from chainB to chainA, receiver is source of tokens", func(t *testing.T) {
transferTxResp := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBIBCToken.IBCDenom()), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "")
s.AssertTxSuccess(transferTxResp)
Expand Down
17 changes: 17 additions & 0 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
grouptypes "github.com/cosmos/cosmos-sdk/x/group"
Expand Down Expand Up @@ -47,6 +48,7 @@ type GRPCClients struct {
// InterTxQueryClient intertxtypes.QueryClient

// SDK query clients
BankQueryClient banktypes.QueryClient
GovQueryClient govtypesv1beta1.QueryClient
GovQueryClientV1 govtypesv1.QueryClient
GroupsQueryClient grouptypes.QueryClient
Expand Down Expand Up @@ -86,6 +88,7 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) {
ICAControllerQueryClient: controllertypes.NewQueryClient(grpcConn),
ICAHostQueryClient: hosttypes.NewQueryClient(grpcConn),
// InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn),
BankQueryClient: banktypes.NewQueryClient(grpcConn),
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
Expand Down Expand Up @@ -276,6 +279,20 @@ func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Cha
return res.CounterpartyPayee, nil
}

// QueryBalances returns all the balances on the given chain for the provided address.
func (s *E2ETestSuite) QueryAllBalances(ctx context.Context, chain ibc.Chain, address string, resolveDenom bool) (sdk.Coins, error) {
queryClient := s.GetChainGRCPClients(chain).BankQueryClient
res, err := queryClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{
Address: address,
ResolveDenom: resolveDenom,
})
if err != nil {
return sdk.Coins{}, err
}

return res.Balances, nil
}

// QueryProposalV1Beta1 queries the governance proposal on the given chain with the given proposal ID.
func (s *E2ETestSuite) QueryProposalV1Beta1(ctx context.Context, chain ibc.Chain, proposalID uint64) (govtypesv1beta1.Proposal, error) {
queryClient := s.GetChainGRCPClients(chain).GovQueryClient
Expand Down
5 changes: 5 additions & 0 deletions e2e/testvalues/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func SolomachineClientID(id int) string {
return fmt.Sprintf("06-solomachine-%d", id)
}

// TokenMetadataFeatureReleases represents the releases the token metadata was released in.
var TokenMetadataFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v8",
}

// GovGenesisFeatureReleases represents the releases the governance module genesis
// was upgraded from v1beta1 to v1.
var GovGenesisFeatureReleases = semverutil.FeatureReleases{
Expand Down

0 comments on commit 242cb9f

Please sign in to comment.