Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Jan 25, 2024
1 parent 3b16390 commit d646bb2
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 @@ -485,10 +486,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead
}
vb, err := csr.getBucket(cand.SelfStakeBucketIdx)
if err != nil {

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

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L487-L488

Added lines #L487 - L488 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 @@ -509,7 +507,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead
return false, err
default:

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

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L508

Added line #L508 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 510 in action/protocol/staking/protocol.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/staking/protocol.go#L510

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

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
}
Expand Down

0 comments on commit d646bb2

Please sign in to comment.