make ssz_static output roots to roots.yaml instead of meta

This commit is contained in:
protolambda 2019-08-01 22:03:40 +02:00
parent 18fc4edfd4
commit 8563dbf5c0
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
2 changed files with 9 additions and 8 deletions

View File

@ -18,16 +18,14 @@ 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: `meta.yaml`, `serialized.ssz`, `value.yaml`
The output parts are: `roots.yaml`, `serialized.ssz`, `value.yaml`
### `meta.yaml`
For non-container SSZ type:
### `roots.yaml`
```yaml
root: bytes32 -- string, hash-tree-root of the value, hex encoded, with prefix 0x
signing_root: bytes32 -- string, signing-root of the value, hex encoded, with prefix 0x.
Optional, present if type is a container and ends with a ``signature`` field.
*Optional*, present if type is a container and ends with a ``signature`` field.
```
### `serialized.ssz`

View File

@ -21,9 +21,12 @@ def create_test_case(rng: Random, typ, mode: random_value.RandomizationMode, cha
value = random_value.get_random_ssz_object(rng, typ, MAX_BYTES_LENGTH, MAX_LIST_LENGTH, mode, chaos)
yield "value", "data", encode.encode(value)
yield "serialized", "ssz", serialize(value)
yield "root", "meta", '0x' + hash_tree_root(value).hex()
if hasattr(value, "signature"):
yield "signing_root", "meta", '0x' + signing_root(value).hex()
roots_data = {
"root": '0x' + hash_tree_root(value).hex()
}
if isinstance(value, Container) and hasattr(value, "signature"):
roots_data["signing_root"] = '0x' + signing_root(value).hex()
yield "roots", "data", roots_data
def get_spec_ssz_types():