-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve checksum
package and increase its test coverage
#593
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #593 +/- ##
==========================================
+ Coverage 39.47% 39.56% +0.08%
==========================================
Files 147 147
Lines 17494 17496 +2
==========================================
+ Hits 6906 6922 +16
+ Misses 10213 10198 -15
- Partials 375 376 +1 ☔ View full report in Codecov by Sentry. |
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.
Conflicts.
checksum/checksum.go
Outdated
@@ -123,6 +119,7 @@ func Calculate(c *Checksum, t Type, v []byte) { | |||
case TZ: | |||
c.SetTillichZemor(tz.Sum(v)) | |||
default: | |||
panic(fmt.Errorf("unsupported checksum type %v", t)) |
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 am not sure it is good. we have discussed panics in SDK and i thought we do not use them anymore. if a wrong scheme must be (really?) noticed, i would prefer an 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.
panics are better than hidden bugs. We discussed this for functions which return an error. I'll make NewFromData
to return an error
done
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, i reopened this issue with some my thoughts: #390 (comment)
0a79ae2
to
101f214
Compare
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.
We should go further (but conflicts).
It teaches what a regular user should be freed from. Signed-off-by: Leonard Lyubich <[email protected]>
`Checksum` type instances are very lightweight, so setters do not provide much benefit while forcing user to explicitly declare a new var. It was also no convenient way to create an instance from stdlib `hash.Hash`. From now `Checksum` can be instantiated with less code using set of new constructors. Old functions are marked as deprecated. Refs #483. Signed-off-by: Leonard Lyubich <[email protected]>
Vary not only the value but also the type. Signed-off-by: Leonard Lyubich <[email protected]>
Previously, `Checksum.Type` method returned any unsupported value as zero. This led to a kind of value loss and the impossibility of forward compatibility - although at the type level it is possible. From now method returns underlying numeric value for unknown enum values. The stringer now also does not fallback. `Unknown` constant is no longer needed and deprecated. Signed-off-by: Leonard Lyubich <[email protected]>
Previously, protocol conversion method `Checksum.ReadFromV2` failed on any unsupported enum value. This didn't make much sense since type getter is provided, so callers can decide for themselves. From now method ignores checksum type. Signed-off-by: Leonard Lyubich <[email protected]>
Signed-off-by: Leonard Lyubich <[email protected]>
Signed-off-by: Leonard Lyubich <[email protected]>
Unlike SHA-256, this hash function is not so widely known. Signed-off-by: Leonard Lyubich <[email protected]>
resolved |
No description provided.