Skip to content

Commit

Permalink
fix: panic when unstake due to total stakings is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybxyz committed Sep 16, 2021
1 parent 3760c11 commit 33b41ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions x/farming/client/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build norace

package cli_test

import (
Expand All @@ -20,8 +22,6 @@ import (
farmingtypes "github.com/tendermint/farming/x/farming/types"
)

// // +build norace

type IntegrationTestSuite struct {
suite.Suite

Expand Down
4 changes: 3 additions & 1 deletion x/farming/keeper/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ func (k Keeper) Unstake(ctx sdk.Context, farmerAcc sdk.AccAddress, amount sdk.Co
k.DeleteQueuedStaking(ctx, coin.Denom, farmerAcc)
}

k.DecreaseTotalStakings(ctx, coin.Denom, removedFromStaking)
if removedFromStaking.IsPositive() {
k.DecreaseTotalStakings(ctx, coin.Denom, removedFromStaking)
}
}

if err := k.ReleaseStakingCoins(ctx, farmerAcc, amount); err != nil {
Expand Down

0 comments on commit 33b41ad

Please sign in to comment.