Skip to content

Commit

Permalink
Fix test of circulating supply query
Browse files Browse the repository at this point in the history
  • Loading branch information
haasted committed Sep 29, 2022
1 parent 9603b15 commit 33cd69b
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions x/queries/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()]
}
Expand All @@ -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{}
Expand Down

0 comments on commit 33cd69b

Please sign in to comment.