Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
41 lines
1,021 B
Go
41 lines
1,021 B
Go
package cosmosclient_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"cosmossdk.io/math"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/query"
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClientBankBalances(t *testing.T) {
|
|
var (
|
|
ctx = context.Background()
|
|
address = "address"
|
|
pagination = &query.PageRequest{Offset: 1}
|
|
expectedBalances = sdk.NewCoins(
|
|
sdk.NewCoin("token", math.NewInt(1000)),
|
|
sdk.NewCoin("stake", math.NewInt(2000)),
|
|
)
|
|
)
|
|
c := newClient(t, func(s suite) {
|
|
req := &banktypes.QueryAllBalancesRequest{
|
|
Address: address,
|
|
Pagination: pagination,
|
|
}
|
|
|
|
s.bankQueryClient.EXPECT().AllBalances(ctx, req).
|
|
Return(&banktypes.QueryAllBalancesResponse{
|
|
Balances: expectedBalances,
|
|
}, nil)
|
|
})
|
|
|
|
balances, err := c.BankBalances(ctx, address, pagination)
|
|
|
|
require.NoError(t, err)
|
|
assert.Equal(t, expectedBalances, balances)
|
|
}
|