The goal of this type is to provide clients with a solid reference for how the known SSZ objects should be encoded. Each object described in the Phase 0 spec is covered. This is important, as many of the clients aiming to serialize/deserialize objects directly into structs/classes do not support (or have alternatives for) generic SSZ encoding/decoding.
This test-format ensures these direct serializations are covered.
Note that this test suite does not cover the invalid-encoding case: SSZ implementations should be hardened against invalid inputs with the other SSZ tests as guide, along with fuzzing.
Each SSZ type is a handler
, since the format is semantically different: the type of the data is different.
One can iterate over the handlers, and select the type based on the handler name. Suites are then the same format, but each specialized in one randomization mode. Some randomization modes may only produce a single test case (e.g. the all-zeroes case).
The output parts are: roots.yaml
, serialized.ssz_snappy
, value.yaml
root: bytes32 -- string, hash-tree-root of the value, hex encoded, with prefix 0x
The SSZ-snappy encoded bytes.
The same value as serialized.ssz_snappy
, represented as YAML.
A test-runner can implement the following assertions:
- If YAML decoding of SSZ objects is supported by the implementation:
- Serialization: After parsing the
value
, SSZ-serialize it: the output should matchserialized
- Deserialization: SSZ-deserialize the
serialized
value, and see if it matches the parsedvalue
- Serialization: After parsing the
- If YAML decoding of SSZ objects is not supported by the implementation:
- Serialization in 2 steps: deserialize
serialized
, then serialize the result, and verify if the bytes match the originalserialized
.
- Serialization in 2 steps: deserialize
- Hash-tree-root: After parsing the
value
(or deserializingserialized
), Hash-tree-root it: the output should matchroot
serialized
—SSZ serialization
root
—hash_tree_root function