-
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
[staking] Cannot withdraw endorsement if it is withdrawing #4179
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4179 +/- ##
==========================================
+ Coverage 75.38% 76.11% +0.73%
==========================================
Files 303 340 +37
Lines 25923 29229 +3306
==========================================
+ Hits 19541 22248 +2707
- Misses 5360 5872 +512
- Partials 1022 1109 +87 ☔ View full report in Codecov by Sentry. |
return validateBucketEndorsementByStatus(esm, bucket, status, height) | ||
} | ||
|
||
func validateBucketEndorsementByStatus(esm *EndorsementStateManager, bucket *VoteBucket, status EndorsementStatus, height uint64) 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.
Efficiency is not the first thing to consider in this case, thus this refactor is not suggested.
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.
reverted
return &handleError{ | ||
err: errors.New("bucket is already endorsed"), | ||
err: errors.Errorf("bucket endorsement is not in status %d", status), |
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.
it is very confusing especially in this return error.
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.
add EndorsementStatus.String()
method to improve readability
@@ -118,14 +118,14 @@ func TestValidateBucket(t *testing.T) { | |||
// 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") | |||
r.ErrorContains(validateBucketEndorsement(esm, bkt, false, blkHeight), "bucket endorsement is not in status 9") |
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.
for example, 9
is not straightforward to understand
failureStatus: iotextypes.ReceiptStatus_ErrUnknown, | ||
} | ||
} | ||
if status != Endorsed && status != UnEndorsing { |
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.
Can be simplified if status == EndorseExpired
Quality Gate failedFailed conditions |
Description
PR includes the following changes:
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: