This repository was archived by the owner on Aug 2, 2022. It is now read-only.
fix bugs in abi_serializer variant to binary #5680
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes to
abi_serializer
:if (va.size() > 0)
check was removed fromabi_serializer::_variant_to_binary
since it caused a bug in which passing in an empty JSON array as the input for a struct causes the serialization of that struct to be entirely skipped._variant_to_binary
prior to throwing apack_exception
was removed. This happened when a required field of a struct was missing from the JSON. In the best case, the unnecessary call meant extra work was done before throwing the appropriate error. In the worst case, the serialization would fail with a misleading error message.Three new unit tests were added to test the cases related to the above bug fixes.
Also, the
abi_tests/abi_recursive_structs
unit test needed to be modified because it was relying on buggy behavior (which is now fixed in this PR) to generate the binary that it then feeds into thebinary_to_variant
call that would infinitely recurse (assuming no recursion limits or deadlines).