From 2acb14b8e59d44fb03c769da58d4315c7ddf7d5f Mon Sep 17 00:00:00 2001 From: Austin Chandra Date: Tue, 28 Mar 2023 10:18:39 -0700 Subject: [PATCH] Revert changes to empty sdk.Coins{} return type --- testutil/vesting/mock_vesting_accounts.go | 7 +------ x/bank/keeper/keeper_test.go | 4 +++- x/bank/keeper/view.go | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/testutil/vesting/mock_vesting_accounts.go b/testutil/vesting/mock_vesting_accounts.go index a31aa8fd4805..d55dbd39ac2c 100644 --- a/testutil/vesting/mock_vesting_accounts.go +++ b/testutil/vesting/mock_vesting_accounts.go @@ -10,12 +10,7 @@ import ( // LockedCoinsFromDelegating prevents the mock vesting account from delegating // any unvested tokens. func (mvdva MockVestedDelegateVestingAccount) LockedCoinsFromDelegating(blockTime time.Time) sdk.Coins { - locked := mvdva.ContinuousVestingAccount.GetVestingCoins(blockTime) - if locked == nil { - return sdk.NewCoins() - } - - return locked + return mvdva.ContinuousVestingAccount.GetVestingCoins(blockTime) } func NewMockVestedDelegateVestingAccount(cva *types.ContinuousVestingAccount) *MockVestedDelegateVestingAccount { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index d0310f156b4b..0882eb3b8156 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -960,7 +960,9 @@ func (suite *IntegrationTestSuite) TestDelegatableCoins() { ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) suite.Require().NoError(keeper.DelegateCoins(ctx, testAddr, addrModule, delCoins)) - suite.Require().Equal(sdk.NewCoins(), keeper.DelegatableCoins(ctx, testAddr)) + + var emptyCoins sdk.Coins + suite.Require().Equal(emptyCoins, keeper.DelegatableCoins(ctx, testAddr)) suite.Require().Error(keeper.DelegateCoins(ctx, testAddr, addrModule, delCoins)) } diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index b17aceb3c388..1441a1aae776 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -221,7 +221,7 @@ func (k BaseViewKeeper) DelegatableCoins(ctx sdk.Context, addr sdk.AccAddress) s func (k BaseViewKeeper) unlockedCoins(total, locked sdk.Coins) (spendable sdk.Coins) { spendable, hasNeg := total.SafeSub(locked...) - if hasNeg || spendable == nil { + if hasNeg { spendable = sdk.NewCoins() return }