-
Notifications
You must be signed in to change notification settings - Fork 252
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
chore: improve nmt wrapper tests #1423
Conversation
This change broke for unexpected reasons. The error I observed is
The root cause was klauspost expects shards to have a length that are a multiple of 64 bytes. Update: improved error message in klauspost/reedsolomon#243 |
Codecov Report
@@ Coverage Diff @@
## main #1423 +/- ##
=======================================
Coverage 49.21% 49.21%
=======================================
Files 79 79
Lines 4482 4482
=======================================
Hits 2206 2206
Misses 2091 2091
Partials 185 185 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
// generateRandNamespacedRawData returns random data of length total. Each chunk | ||
// of random data is of size nidSize + leafSize. | ||
func generateRandNamespacedRawData(total int, nidSize int, leafSize int) [][]byte { |
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.
FWIW this could be simplified to:
func generateRandNamespacedRawData(numShares int, shareSize int) (data [][]byte) {
for i := 0; i < numShares; i++ {
share := make([]byte, shareSize)
_, err := rand.Read(share)
if err != nil {
panic(err)
}
data = append(data, share)
}
sortByteArrays(data)
return data
}
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.
There is just a slight difference and that is the final data
is sorted both based on namespace ID and their data whereas in the original implementation it is not the case.
// generateRandNamespacedRawData returns random data of length total. Each chunk | ||
// of random data is of size nidSize + leafSize. | ||
func generateRandNamespacedRawData(total int, nidSize int, leafSize int) [][]byte { |
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.
There is just a slight difference and that is the final data
is sorted both based on namespace ID and their data whereas in the original implementation it is not the case.
Closes #1422
Motivation: I was reading through nmt_wrapper.go to prepare an ADR and got confused by the usage of
appconsts.ContinuationSparseShareContentSize+1
. I made a few changes to the test file for clarity & maintainability.