-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add error handling in newHashKey #499
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #499 +/- ##
==========================================
+ Coverage 65.44% 65.60% +0.16%
==========================================
Files 278 278
Lines 37936 37995 +59
==========================================
+ Hits 24828 24928 +100
+ Misses 11305 11261 -44
- Partials 1803 1806 +3
|
7d91cd5
to
3ac5c86
Compare
This title and description don't appear to represent the modifications contained in this PR correctly. Is |
Separating certain functions into a package for the purpose of passing coverage seems to me to be out of line with module design and doesn't seem to be a good idea. And I'm also concerned about the project-local implicit rules that arise.
|
p2p/pex/addrbook.go
Outdated
@@ -20,6 +19,7 @@ import ( | |||
tmmath "github.com/line/ostracon/libs/math" | |||
tmrand "github.com/line/ostracon/libs/rand" | |||
"github.com/line/ostracon/libs/service" | |||
stdCryptoRand "github.com/line/ostracon/libs/std/crypto/rand" |
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 seems too assertive compared to other sources and golang's customary package alias. I think crand
, scrand
, or stdcrand
is enough.
@@ -0,0 +1,11 @@ | |||
package rand |
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.
No one looking at the source would know why this function is separated in this package. Any purpose or intent that can only be recognized outside of the source code should be noted in the comment.
@torao
The current option is selected because the layer where the error occurs is not at the application level but is connected to the test ignore. |
@Mdaiki0730 https://github.com/line/ostracon/blob/main/crypto/random.go#L9-L22 |
I think very good@@ |
I created another PR because we found a completely different solution than the this PR. |
Description
When calling the function newHashKey() if an error occurs while filling the new key with random data from the defined random source, the created hash key will be zeroed, which means, the content of the slice will be all 0's.
I think it's better to handle errors properly.