Skip to content

Commit

Permalink
R4R: Rename validator.GetJailed() to validator.IsJailed() #3245 (#4017)
Browse files Browse the repository at this point in the history
Closes: #3245
  • Loading branch information
Frank Yang authored and alessio committed Apr 2, 2019
1 parent ecd2bfa commit bc8d2d4
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/3245-Rename-validato
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3245 Rename validator.GetJailed() to validator.IsJailed()
2 changes: 1 addition & 1 deletion types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (b BondStatus) Equal(b2 BondStatus) bool {

// validator for a delegated proof of stake system
type Validator interface {
GetJailed() bool // whether the validator is jailed
IsJailed() bool // whether the validator is jailed
GetMoniker() string // moniker of the validator
GetStatus() BondStatus // status of the validator
GetOperator() ValAddress // operator address to receive/return validators coins
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) sdk.Result {
}

// cannot be unjailed if not jailed
if !validator.GetJailed() {
if !validator.IsJailed() {
return ErrValidatorNotJailed(k.codespace).Result()
}

Expand Down
4 changes: 2 additions & 2 deletions x/slashing/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestCannotUnjailUnlessMeetMinSelfDelegation(t *testing.T) {
undelegateMsg := staking.NewMsgUndelegate(sdk.AccAddress(addr), addr, unbondAmt)
got = staking.NewHandler(sk)(ctx, undelegateMsg)

require.True(t, sk.Validator(ctx, addr).GetJailed())
require.True(t, sk.Validator(ctx, addr).IsJailed())

// assert non-jailed validator can't be unjailed
got = slh(ctx, NewMsgUnjail(addr))
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestJailedValidatorDelegations(t *testing.T) {
// verify validator still exists and is jailed
validator, found := stakingKeeper.GetValidator(ctx, valAddr)
require.True(t, found)
require.True(t, validator.GetJailed())
require.True(t, validator.IsJailed())

// verify the validator cannot unjail itself
got = NewHandler(slashingKeeper)(ctx, NewMsgUnjail(valAddr))
Expand Down
4 changes: 2 additions & 2 deletions x/slashing/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio

// Jail validator if not already jailed
// begin unbonding validator if not already unbonding (tombstone)
if !validator.GetJailed() {
if !validator.IsJailed() {
k.validatorSet.Jail(ctx, consAddr)
}

Expand Down Expand Up @@ -172,7 +172,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
// if we are past the minimum height and the validator has missed too many blocks, punish them
if height > minHeight && signInfo.MissedBlocksCounter > maxMissed {
validator := k.validatorSet.ValidatorByConsAddr(ctx, consAddr)
if validator != nil && !validator.GetJailed() {
if validator != nil && !validator.IsJailed() {

// Downtime confirmed: slash and jail the validator
logger.Info(fmt.Sprintf("Validator %s past min height of %d and below signed blocks threshold of %d",
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestHandleDoubleSign(t *testing.T) {
keeper.handleDoubleSign(ctx, val.Address(), 0, time.Unix(0, 0), power)

// should be jailed
require.True(t, sk.Validator(ctx, operatorAddr).GetJailed())
require.True(t, sk.Validator(ctx, operatorAddr).IsJailed())

// tokens should be decreased
newTokens := sk.Validator(ctx, operatorAddr).GetTokens()
Expand Down
6 changes: 3 additions & 3 deletions x/staking/keeper/slash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ func TestRevocation(t *testing.T) {
// initial state
val, found := keeper.GetValidator(ctx, addr)
require.True(t, found)
require.False(t, val.GetJailed())
require.False(t, val.IsJailed())

// test jail
keeper.Jail(ctx, consAddr)
val, found = keeper.GetValidator(ctx, addr)
require.True(t, found)
require.True(t, val.GetJailed())
require.True(t, val.IsJailed())

// test unjail
keeper.Unjail(ctx, consAddr)
val, found = keeper.GetValidator(ctx, addr)
require.True(t, found)
require.False(t, val.GetJailed())
require.False(t, val.IsJailed())
}

// tests slashUnbondingDelegation
Expand Down
2 changes: 1 addition & 1 deletion x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (v Validator) PotentialTendermintPower() int64 {
var _ sdk.Validator = Validator{}

// nolint - for sdk.Validator
func (v Validator) GetJailed() bool { return v.Jailed }
func (v Validator) IsJailed() bool { return v.Jailed }
func (v Validator) GetMoniker() string { return v.Description.Moniker }
func (v Validator) GetStatus() sdk.BondStatus { return v.Status }
func (v Validator) GetOperator() sdk.ValAddress { return v.OperatorAddress }
Expand Down

0 comments on commit bc8d2d4

Please sign in to comment.