diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dd5b0af65..10f0a01cf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/foundation) [\#712](https://github.com/line/lbm-sdk/pull/712) fix x/foundation EndBlocker * (baseapp) [\#724](https://github.com/line/lbm-sdk/pull/724) add checking pubkey type from validator params * (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 * (x/foundation) [\#732](https://github.com/line/lbm-sdk/pull/732) add verification on accounts into x/foundation Grants cli ### Breaking Changes diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index bc8b6cbcb6..1a6ced8914 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -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) diff --git a/x/staking/keeper/val_state_change_test.go b/x/staking/keeper/val_state_change_test.go new file mode 100644 index 0000000000..5abed36e23 --- /dev/null +++ b/x/staking/keeper/val_state_change_test.go @@ -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]) + }) +}