-
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
validate address of contract indexer #3874
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3874 +/- ##
==========================================
+ Coverage 75.38% 75.54% +0.16%
==========================================
Files 303 325 +22
Lines 25923 27600 +1677
==========================================
+ Hits 19541 20850 +1309
- Misses 5360 5685 +325
- Partials 1022 1065 +43
... and 9 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
add invalid address in the test |
func NewContractStakingIndexer(kvStore db.KVStore, contractAddr string, contractDeployHeight uint64) (*Indexer, error) { | ||
if _, err := address.FromString(contractAddr); err != nil { | ||
return nil, errors.Wrapf(err, "invalid contract address %s", contractAddr) | ||
} |
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 simply panic("invalid system staking contract address")
, then no need to change other places
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.
also
if kv == nil {
panic("nil kvstore")
}
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.
I think that it is generally recommended to return an error in most error handling scenarios instead of panic. Excessive use of panic can make the code less maintainable and harder to write unit tests.
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.
ok, then check the kv == nil
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.
ok
068b301
to
f06e8de
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
validate address when
NewContractStakingIndexer
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: