Skip to content

Commit

Permalink
Merge pull request #587 from AlexKnauth/rlp-0x
Browse files Browse the repository at this point in the history
consistently use `0x` prefixes in RLP tests
  • Loading branch information
winsvega committed Feb 20, 2019
2 parents d505c07 + 28b77e5 commit 0494078
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion RLPTests/RandomRLPTests/example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"listsoflists2": {
"in": "VALID",
"out": "c7c0c1c0c3c0c1c0"
"out": "0xc7c0c1c0c3c0c1c0"
}
}
18 changes: 9 additions & 9 deletions RLPTests/invalidRLPTest.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
"int32Overflow": {
"in": "INVALID",
"out": "bf0f000000000000021111"
"out": "0xbf0f000000000000021111"
},

"int32Overflow2": {
"in": "INVALID",
"out": "ff0f000000000000021111"
"out": "0xff0f000000000000021111"
},

"wrongSizeList": {
"in": "INVALID",
"out": "f80180"
"out": "0xf80180"
},

"wrongSizeList2": {
"in": "INVALID",
"out": "f80100"
"out": "0xf80100"
},

"incorrectLengthInArray": {
"in": "INVALID",
"out": "b9002100dc2b275d0f74e8a53e6f4ec61b27f24278820be3f82ea2110e582081b0565df0"
"out": "0xb9002100dc2b275d0f74e8a53e6f4ec61b27f24278820be3f82ea2110e582081b0565df0"
},

"randomRLP": {
"in": "INVALID",
"out": "f861f83eb9002100dc2b275d0f74e8a53e6f4ec61b27f24278820be3f82ea2110e582081b0565df027b90015002d5ef8325ae4d034df55d4b58d0dfba64d61ddd17be00000b9001a00dae30907045a2f66fa36f2bb8aa9029cbb0b8a7b3b5c435ab331"
"out": "0xf861f83eb9002100dc2b275d0f74e8a53e6f4ec61b27f24278820be3f82ea2110e582081b0565df027b90015002d5ef8325ae4d034df55d4b58d0dfba64d61ddd17be00000b9001a00dae30907045a2f66fa36f2bb8aa9029cbb0b8a7b3b5c435ab331"
},

"bytesShouldBeSingleByte00": {
"in": "INVALID",
"out": "8100"
"out": "0x8100"
},

"bytesShouldBeSingleByte01": {
"in": "INVALID",
"out": "8101"
"out": "0x8101"
},

"bytesShouldBeSingleByte7F": {
"in": "INVALID",
"out": "817F"
"out": "0x817F"
}
}
17 changes: 13 additions & 4 deletions docs/test_types/rlp_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ Test Structure
{
"rlpTest": {
"in": "dog",
"out": "83646f67"
"out": "0x83646f67"
},

"multilist": {
"in": [ "zw", [ 4 ], 1 ],
"out": "c6827a77c10401"
"out": "0xc6827a77c10401"
},

"validRLP": {
"in": "VALID",
"out": "c7c0c1c0c3c0c1c0"
"out": "0xc7c0c1c0c3c0c1c0"
},

"invalidRLP": {
"in": "INVALID",
"out": "bf0f000000000000021111"
"out": "0xbf0f000000000000021111"
},
...
}
Expand All @@ -62,3 +62,12 @@ Sections

* ``in`` - json object (array, int, string) representation of the rlp byte stream (\*except values ``VALID`` and ``INVALID``)
* ``out`` - string of rlp bytes stream

When a json string starts with ``0x``, the rest of the string is interpreted as
hex bytes, and when one starts with ``#``, the rest is interpreted as a decimal
number. For example ``5050`` and ``"#5050"`` both represent the decimal number
``5050``. Strings with ``#`` prefixes should be used for numbers that would be
too big to represented as ``int`` values, and would require a "bigint"
representation.

The ``out`` strings normally start with ``0x`` to be interpreted as hex bytes.

0 comments on commit 0494078

Please sign in to comment.