Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo in val_state_change.go #728

Merged
merged 9 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/bankplus) [\#705](https://github.com/line/lbm-sdk/pull/705) add missing blockedAddr checking in bankplus
* (x/foundation) [\#712](https://github.com/line/lbm-sdk/pull/712) fix x/foundation EndBlocker
* (x/staking) [\#726](https://github.com/line/lbm-sdk/pull/726) check allowedList size in StakeAuthorization.Accept()
* (x/staking) [\#728](https://github.com/line/lbm-sdk/pull/728) fix typo in unbondingToUnbonded() panic

### Breaking Changes
* (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/val_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (k Keeper) unbondedToBonded(ctx sdk.Context, validator types.Validator) (ty
// UnbondingToUnbonded switches a validator from unbonding state to unbonded state
func (k Keeper) UnbondingToUnbonded(ctx sdk.Context, validator types.Validator) types.Validator {
if !validator.IsUnbonding() {
panic(fmt.Sprintf("bad state transition unbondingToBonded, validator: %v\n", validator))
panic(fmt.Sprintf("bad state transition unbondingToUnbonded, validator: %v\n", validator))
}

return k.completeUnbondingValidator(ctx, validator)
Expand Down
30 changes: 30 additions & 0 deletions x/staking/keeper/val_state_change_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package keeper_test

import (
"github.com/line/lbm-sdk/x/staking/keeper"
"github.com/line/lbm-sdk/x/staking/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestUnbondingToUnbondedPanic(t *testing.T) {
app, ctx, _, _, validators := initValidators(t, 100, 2, []int64{0, 100})

for i, validator := range validators {
validators[i] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, false)
}

assert.Equal(t, validators[0].Status, types.Unbonded)
assert.Equal(t, validators[1].Status, types.Bonded)

// unbond validator which is in unbonded status
require.Panics(t, func() {
app.StakingKeeper.UnbondingToUnbonded(ctx, validators[0])
})

// unbond validator which is in bonded status
require.Panics(t, func() {
app.StakingKeeper.UnbondingToUnbonded(ctx, validators[1])
})
}