Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Jan 30, 2024
1 parent 49e2fdd commit 22da849
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions action/protocol/staking/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ const (

// Errors
var (
ErrWithdrawnBucket = errors.New("the bucket is already withdrawn")
TotalBucketKey = append([]byte{_const}, []byte("totalBucket")...)
ErrWithdrawnBucket = errors.New("the bucket is already withdrawn")
ErrEndorsementNotExist = errors.New("the endorsement does not exist")
TotalBucketKey = append([]byte{_const}, []byte("totalBucket")...)
)

var (
Expand Down Expand Up @@ -489,10 +490,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead
}
vb, err := csr.getBucket(cand.SelfStakeBucketIdx)
if err != nil {

Check warning on line 492 in action/protocol/staking/protocol.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L491-L492

Added lines #L491 - L492 were not covered by tests
if errors.Is(err, state.ErrStateNotExist) {
return false, nil
}
return false, err
return false, errors.Wrapf(err, "failed to get bucket %d", cand.SelfStakeBucketIdx)
}
// bucket is self-owned
if address.Equal(vb.Owner, cand.Owner) {
Expand All @@ -513,7 +511,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead
return false, err
default:

Check warning on line 512 in action/protocol/staking/protocol.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L512

Added line #L512 was not covered by tests
// endorsement does not exist
return false, errors.New("endorsement does not exist")
return false, errors.Wrapf(ErrEndorsementNotExist, "bucket index %d", cand.SelfStakeBucketIdx)

Check warning on line 514 in action/protocol/staking/protocol.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L514

Added line #L514 was not covered by tests
}
return true, nil

Check warning on line 516 in action/protocol/staking/protocol.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L516

Added line #L516 was not covered by tests
}
Expand Down

0 comments on commit 22da849

Please sign in to comment.