-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refactor] Add bucket validation util functions #4019
Conversation
c1881e2
to
b51dac4
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #4019 +/- ##
==========================================
+ Coverage 75.38% 76.11% +0.73%
==========================================
Files 303 335 +32
Lines 25923 28525 +2602
==========================================
+ Hits 19541 21711 +2170
- Misses 5360 5716 +356
- Partials 1022 1098 +76 ☔ View full report in Codecov by Sentry. |
b51dac4
to
fc79ebf
Compare
bc370fd
to
8adcd5b
Compare
} | ||
|
||
func validateBucketStake(bucket *VoteBucket, isStaked bool) ReceiptError { | ||
if bucket.isUnstaked() == isStaked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it returns error for isStaked
= both true and false?
return nil | ||
} | ||
|
||
func validateBucketCandidate(bucket *VoteBucket, candidate address.Address) ReceiptError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this needed?
// endorsed bucket | ||
r.NoError(esm.Put(bktIdx, &Endorsement{ExpireHeight: endorsementNotExpireHeight})) | ||
r.Nil(validateBucketEndorsement(esm, bkt, (true), blkHeight)) | ||
r.ErrorContains(validateBucketEndorsement(esm, bkt, (false), blkHeight), "bucket is already endorsed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false
, not (false)
// unendorsing bucket | ||
r.NoError(esm.Put(bktIdx, &Endorsement{ExpireHeight: blkHeight + 1})) | ||
r.Nil(validateBucketEndorsement(esm, bkt, (true), blkHeight)) | ||
r.ErrorContains(validateBucketEndorsement(esm, bkt, (false), blkHeight), "bucket is already endorsed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
// endorse expired bucket | ||
r.NoError(esm.Put(bktIdx, &Endorsement{ExpireHeight: blkHeight})) | ||
r.Nil(validateBucketEndorsement(esm, bkt, (false), blkHeight)) | ||
r.ErrorContains(validateBucketEndorsement(esm, bkt, (true), blkHeight), "bucket is not endorsed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and these 2
850ed21
to
167189e
Compare
Quality Gate failedFailed conditions 3.4% Duplication on New Code (required ≤ 3%) |
Description
introduce batch of util functions to validate a bucket, reducing redundant code
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: