Skip to content

Commit

Permalink
Merge branch 'main' into julien/add-go-mod-tidy-all
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim authored Oct 16, 2023
2 parents 01cdea5 + 0d524ec commit f0c3e18
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 56 deletions.
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
golang.org/x/mod v0.13.0
google.golang.org/grpc v1.58.2
google.golang.org/grpc v1.58.3
gopkg.in/yaml.v2 v2.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1662,8 +1662,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1)

actualBalance, err := chainA.GetBalance(ctx, chainAAddress, chainAIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom())

s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down
15 changes: 8 additions & 7 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() {
})

t.Run("verify tokens transferred", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

_, err = chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
_, err = s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down Expand Up @@ -179,7 +179,8 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF

t.Run("fail to execute bank transfer over ICA", func(t *testing.T) {
t.Run("verify empty host wallet", func(t *testing.T) {
hostAccountBalance, err := chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
hostAccountBalance, err := s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom)

s.Require().NoError(err)
s.Require().Zero(hostAccountBalance.Int64())
})
Expand Down Expand Up @@ -217,7 +218,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF
})

t.Run("verify balance is the same", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount
Expand Down Expand Up @@ -336,10 +337,10 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
})

t.Run("verify tokens not transferred", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

_, err = chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
_, err = s.QueryBalance(ctx, chainB, hostAccount, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount
Expand Down Expand Up @@ -399,7 +400,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
})

t.Run("verify tokens transferred", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/interchain_accounts/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration()
})

t.Run("verify tokens transferred", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

_, err = chainB.GetBalance(ctx, interchainAccAddr, chainB.Config().Denom)
_, err = s.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/interchain_accounts/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat

t.Run("verify tokens transferred", func(t *testing.T) {
s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks")
balance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainB.Config().Denom)

balance, err := chainB.GetBalance(ctx, chainBAddress, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
s.Require().Equal(expected, balance.Int64())

balance, err = chainB.GetBalance(ctx, interchainAccAddr, chainB.Config().Denom)
balance, err = s.QueryBalance(ctx, chainB, interchainAccAddr, chainB.Config().Denom)
s.Require().NoError(err)

expected = testvalues.StartingTokenAmount - testvalues.IBCTransferAmount
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe
})

t.Run("verify interchain account sent tokens", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

_, err = chainB.GetBalance(ctx, interchainAcc, chainB.Config().Denom)
_, err = s.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down Expand Up @@ -353,10 +353,10 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I
})

t.Run("verify interchain account did not send tokens", func(t *testing.T) {
balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom)
s.Require().NoError(err)

_, err = chainB.GetBalance(ctx, interchainAcc, chainB.Config().Denom)
_, err = s.QueryBalance(ctx, chainB, interchainAcc, chainB.Config().Denom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount
Expand Down
6 changes: 3 additions & 3 deletions e2e/tests/interchain_accounts/localhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost(
})

t.Run("verify tokens transferred", func(t *testing.T) {
balance, err := chainA.GetBalance(ctx, userBWallet.FormattedAddress(), chainADenom)
balance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down Expand Up @@ -408,7 +408,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan
s.Require().NoError(err)
s.Require().NotZero(len(interchainAccAddress))

balance, err := chainA.GetBalance(ctx, interchainAccAddress, chainADenom)
balance, err := s.QueryBalance(ctx, chainA, interchainAccAddress, chainADenom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount
Expand Down Expand Up @@ -467,7 +467,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan
t.Run("verify tokens transferred", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, controllerPortID, msgChanOpenInitRes.ChannelId, 1)

balance, err := chainA.GetBalance(ctx, userBWallet.FormattedAddress(), chainADenom)
balance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), chainADenom)
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
Expand Down
6 changes: 4 additions & 2 deletions e2e/tests/transfer/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() {

t.Run("verify receiver wallet amount", func(t *testing.T) {
chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)
actualBalance, err := chainB.GetBalance(ctx, receiverWalletAddress, chainBIBCToken.IBCDenom())
actualBalance, err := suite.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom())

suite.Require().NoError(err)
suite.Require().Equal(testvalues.IBCTransferAmount, actualBalance.Int64())
})
Expand Down Expand Up @@ -273,7 +274,8 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() {

t.Run("verify receiver wallet amount", func(t *testing.T) {
chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)
actualBalance, err := chainB.GetBalance(ctx, receiverWalletAddress, chainBIBCToken.IBCDenom())
actualBalance, err := suite.QueryBalance(ctx, chainB, receiverWalletAddress, chainBIBCToken.IBCDenom())

suite.Require().NoError(err)
suite.Require().Equal(int64(0), actualBalance.Int64())
})
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand All @@ -123,7 +123,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {
})

t.Run("tokens are escrowed", func(t *testing.T) {
actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

s.Require().Equal(sdkmath.ZeroInt(), actualBalance)
Expand Down Expand Up @@ -362,8 +362,8 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() {

t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1)
actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom())

actualBalance, err := chainA.GetBalance(ctx, chainAAddress, chainAIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down Expand Up @@ -481,8 +481,8 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() {

t.Run("packets relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

if testvalues.MemoFeatureReleases.IsSupported(chainBVersion) {
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/transfer/localhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() {
s.AssertPacketRelayed(ctx, chainA, transfertypes.PortID, msgChanOpenInitRes.ChannelId, 1)

ibcToken := testsuite.GetIBCToken(chainADenom, transfertypes.PortID, msgChanOpenTryRes.ChannelId)
actualBalance, err := chainA.GetBalance(ctx, userBWallet.FormattedAddress(), ibcToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainA, userBWallet.FormattedAddress(), ibcToken.IBCDenom())

s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/upgrades/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func (s *GenesisTestSuite) TestIBCGenesis() {
t.Run("ics20: packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())

s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down
20 changes: 11 additions & 9 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())

s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand All @@ -171,8 +172,8 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() {

t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 2)
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount * 2
Expand All @@ -190,7 +191,8 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1)

actualBalance, err := chainA.GetBalance(ctx, chainAAddress, chainAIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom())

s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down Expand Up @@ -220,7 +222,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
})

t.Run("verify tokens sent", func(t *testing.T) {
balance, err := chain.GetBalance(ctx, userWalletAddr, chain.Config().Denom)
balance, err := s.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount * 2
Expand All @@ -244,7 +246,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
})

t.Run("verify tokens sent", func(t *testing.T) {
balance, err := chain.GetBalance(ctx, userWalletAddr, chain.Config().Denom)
balance, err := s.QueryBalance(ctx, chain, userWalletAddr, chain.Config().Denom)
s.Require().NoError(err)

expected := testvalues.StartingTokenAmount * 3
Expand Down Expand Up @@ -356,7 +358,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down Expand Up @@ -397,7 +399,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
t.Run("packets are relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount * 2
Expand Down Expand Up @@ -451,7 +453,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() {
t.Run("packet is relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down Expand Up @@ -542,7 +544,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() {
t.Run("packet is relayed", func(t *testing.T) {
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
actualBalance, err := s.QueryBalance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
Expand Down
15 changes: 15 additions & 0 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
Expand Down Expand Up @@ -262,6 +263,20 @@ func (s *E2ETestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Cha
return res.CounterpartyPayee, nil
}

// QueryBalance returns the balance of a specific denomination for a given account by address.
func (s *E2ETestSuite) QueryBalance(ctx context.Context, chain ibc.Chain, address string, denom string) (math.Int, error) {
queryClient := s.GetChainGRCPClients(chain).BankQueryClient
res, err := queryClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: address,
Denom: denom,
})
if err != nil {
return math.Int{}, err
}

return res.Balance.Amount, 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
22 changes: 11 additions & 11 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,22 @@ func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) ibc
// GetChainANativeBalance gets the balance of a given user on chain A.
func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) {
chainA, _ := s.GetChains()
return GetNativeChainBalance(ctx, chainA, user)

balance, err := s.QueryBalance(ctx, chainA, user.FormattedAddress(), chainA.Config().Denom)
if err != nil {
return 0, err
}
return balance.Int64(), nil
}

// GetChainBNativeBalance gets the balance of a given user on chain B.
func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user ibc.Wallet) (int64, error) {
_, chainB := s.GetChains()
return GetNativeChainBalance(ctx, chainB, user)
balance, err := s.QueryBalance(ctx, chainB, user.FormattedAddress(), chainB.Config().Denom)
if err != nil {
return -1, err
}
return balance.Int64(), nil
}

// GetChainGRCPClients gets the GRPC clients associated with the given chain.
Expand Down Expand Up @@ -397,15 +406,6 @@ func (s *E2ETestSuite) GetTimeoutHeight(ctx context.Context, chain *cosmos.Cosmo
return clienttypes.NewHeight(clienttypes.ParseChainID(chain.Config().ChainID), height+1000)
}

// GetNativeChainBalance returns the balance of a specific user on a chain using the native denom.
func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user ibc.Wallet) (int64, error) {
bal, err := chain.GetBalance(ctx, user.FormattedAddress(), chain.Config().Denom)
if err != nil {
return -1, err
}
return bal.Int64(), nil
}

// 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))
Expand Down
Loading

0 comments on commit f0c3e18

Please sign in to comment.