RLP Test

Location /RLPTests

Describes an RLP (https://github.com/ethereum/wiki/wiki/RLP) encoding using the .json file.

Test Implementation

The client should read the rlp byte stream, decode and check whether the contents match its json representation. Then it should try do it reverse - encode json rlp representation into rlp byte stream and check whether it matches the given rlp byte stream.

If it is an invalid RLP byte stream in the test, then ‘in’ field would contain string INVALID.

Some RLP byte streams are expected to be generated by fuzz test suite. For those examples ‘in’ field would contain string VALID as it means that rlp should be easily decoded.

Note

RLP tests are testing a single RLP object encoding and not a stream of RLP objects in one array.

Test Structure

{
   "rlpTest": {
        "in": "dog",
        "out": "0x83646f67"
   },

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

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

   "invalidRLP": {
        "in": "INVALID",
        "out": "0xbf0f000000000000021111"
   },
   ...
}

Fields

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.