forked from tendermint/go-amino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap basic types in a struct (tendermint#270)
* First stab on tendermint#204: disallow direct encoding of basic types * fix some tests and disallow defined types on decoding (but allow interfaces on decoding) * fix remaining tests and introduce a new error type (instead of panicing) * remove code: condition is always 'false' because 'err' is always 'nil' * WIP: add `(field_number << 3) | wire_type` with field_number == 1 if the passed type is not a struct to simulate protobuf message {} Still missing: - proper table driven tests - decoding (will basically be skipping over the first bytes if non struct type is passed) * remove unused type aliases (use types defined in tests package instead) * Some cleanup: - table driven tests - use helper method `writeFieldIfNotEmpty` where it makes sense - remove a bunch of comments & debug output * Added a more complex test case (currently fails), some lengthy debugging session revealed another minor difference between amino and proto3 (see the two added FIXMEs); also: - renamed some proto3 types - some minor cleanup * Do not prepend with list of structs with field tag (will be handled internally) * WIP: First stab on decoding -> a few failing tests * Fix one of the failing tests: TestBasicTypes * Fix all remaining tests * Fix unfinished comment & remove debug output Signed-off-by: Ismail Khoffi <[email protected]> * remove unsed var Signed-off-by: Ismail Khoffi <[email protected]> * delete debug output and comment Signed-off-by: Ismail Khoffi <[email protected]> * delete debug output and obsolete TODOs and some minot cleanups Signed-off-by: Ismail Khoffi <[email protected]> * Add another test case (type PrimitivesStructAr [2]PrimitivesStruct) and fix implementation: - Additionally to the fieldnum and wiretag we need a size prefix (not bare) in case the typ3 isn't of ByteLength. - add helper methods as Bez suggested: check if struct and check if pointer to struct - fix tests due to changes Signed-off-by: Ismail Khoffi <[email protected]>
- Loading branch information
Showing
17 changed files
with
682 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.