Skip to content

Commit

Permalink
fix tests and add stringer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Nov 30, 2023
1 parent a3bf1da commit 2408dd4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/integration/staking/keeper/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestSlashToZeroPowerRemoved(t *testing.T) {
applyValidatorSetUpdates(t, f.sdkCtx, f.stakingKeeper, -1)
// validator should be unbonding
validator, _ = f.stakingKeeper.GetValidator(f.sdkCtx, addrVals[0])
assert.Equal(t, validator.GetStatus(), types.Unbonding)
assert.Equal(t, validator.GetStatus(), sdk.Unbonding)
}

// test how the validators are sorted, tests GetBondedValidatorsByPower
Expand Down
12 changes: 12 additions & 0 deletions types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ const (
Bonded BondStatus = 3
)

// BondStatus_name is the string representation of BondStatus.
var bondStatus_name = map[int32]string{
0: "BOND_STATUS_UNSPECIFIED",
1: "BOND_STATUS_UNBONDED",
2: "BOND_STATUS_UNBONDING",
3: "BOND_STATUS_BONDED",
}

func (x BondStatus) String() string {
return bondStatus_name[int32(x)]
}

// DelegationI delegation bond for a delegated proof of stake system
type DelegationI interface {
GetDelegatorAddr() string // delegator string for the bond
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (k Querier) Validators(ctx context.Context, req *types.QueryValidatorsReque
valStore := prefix.NewStore(store, types.ValidatorsKey)

validators, pageRes, err := query.GenericFilteredPaginate(k.cdc, valStore, req.Pagination, func(key []byte, val *types.Validator) (*types.Validator, error) {
if req.Status != "" && !strings.EqualFold(string(val.GetStatus()), req.Status) { // TODO test
if req.Status != "" && !strings.EqualFold(val.GetStatus().String(), req.Status) {
return nil, nil
}

Expand Down

0 comments on commit 2408dd4

Please sign in to comment.