From 33cd69be8b6122e0fe5e9aec7d008f379b097fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Aasted=20S=C3=B8rensen?= Date: Thu, 29 Sep 2022 16:03:05 +0200 Subject: [PATCH] Fix test of circulating supply query --- x/queries/grpc_query_test.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/x/queries/grpc_query_test.go b/x/queries/grpc_query_test.go index 62217a66..a9773a70 100644 --- a/x/queries/grpc_query_test.go +++ b/x/queries/grpc_query_test.go @@ -66,7 +66,7 @@ func TestCirculating(t *testing.T) { gotRsp, err := queryClient.Circulating(ctx, &types.QueryCirculatingRequest{}) require.NoError(t, err) - assert.Equal(t, mustParseCoins("154blx,3"+stakingDenom), gotRsp.Total) + assert.Equal(t, mustParseCoins("154blx,153"+stakingDenom), gotRsp.Total) } func TestMissedBlocks(t *testing.T) { @@ -122,6 +122,18 @@ type bankKeeperMock struct { vesting sdk.Coins } +func (b bankKeeperMock) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { + if bal, found := b.balances[addr.String()]; found { + for _, b := range bal { + if b.Denom == denom { + return b + } + } + } + + return sdk.NewCoin(denom, sdk.ZeroInt()) +} + func (b bankKeeperMock) SpendableCoins(_ sdk.Context, addr sdk.AccAddress) sdk.Coins { return b.balances[addr.String()] } @@ -136,21 +148,6 @@ func (b bankKeeperMock) GetSupply(_ sdk.Context) exported.SupplyI { return banktypes.NewSupply(supply) } -func (b bankKeeperMock) IterateAllBalances(_ sdk.Context, cb func(sdk.AccAddress, sdk.Coin) bool) { - for address, balance := range b.balances { - addr, err := sdk.AccAddressFromBech32(address) - if err != nil { - panic(err) - } - - for _, coin := range balance { - if cb(addr, coin) { - return - } - } - } -} - var ( _ AccountKeeper = &accountKeeperMock{} _ BankKeeper = &bankKeeperMock{}