-
Notifications
You must be signed in to change notification settings - Fork 104
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
Return error with invalid length #180
Conversation
I deleted an outdated CI config file. If you can rebase CI will get past the error from gitleaks. |
da300af
to
f4ae3ee
Compare
Codecov Report
@@ Coverage Diff @@
## master #180 +/- ##
==========================================
+ Coverage 70.14% 70.41% +0.27%
==========================================
Files 37 37
Lines 1785 1768 -17
==========================================
- Hits 1252 1245 -7
+ Misses 338 334 -4
+ Partials 195 189 -6
Continue to review full report at Codecov.
|
@@ -542,6 +539,49 @@ func TestCompositePackingWithTags(t *testing.T) { | |||
require.EqualError(t, err, "failed to encode length: field length: 12 should be fixed: 6") | |||
}) | |||
|
|||
t.Run("Pack returns error when encoded data length is larger than specified variable max length", func(t *testing.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.
there was a test for fixed length, I added one for variable length.
// 11 byte limit imposed by the prefix. [011 | 10000100012] | ||
// Therefore, it won't be included in the packed bytes. | ||
|
||
packed := []byte("01110000100012") |
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.
this is proper packed data for the LLL
field:
- length - 011
- then the fields from 1 to 11 are unpacked
- fields 12, 13, 14 are not set
require.NoError(t, err) | ||
require.Equal(t, 14, read) | ||
|
||
packedBytes, err := composite.Pack() |
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.
Now we just pack it back. Unset fields will not be included in the packed value. It's just expected behavior.
So, test is removed as we don't test here anything. Or I'm missing something.
@adamdecaf please, take a look. @mfdeveloper508 did what we had to do: just removed the check. It packs and unpacks according to expectations:
I may miss some use-cases @Dakinola892 @cheukwing please review it as well. I removed some unnecessary code and added some tests. |
@louisheath I would be glad if you can check this change as well. |
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.
This seems fine to me. Did we need to combine changes for zero-length packing and overflow packing?
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.
Happy with these new changes
removed packed check, update composite field