From 8563dbf5c0b21c76b41b0c473911bc19313e5204 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 1 Aug 2019 22:03:40 +0200 Subject: [PATCH] make ssz_static output roots to roots.yaml instead of meta --- specs/test_formats/ssz_static/core.md | 8 +++----- test_generators/ssz_static/main.py | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/specs/test_formats/ssz_static/core.md b/specs/test_formats/ssz_static/core.md index 1816e7d4d..a7301a3c8 100644 --- a/specs/test_formats/ssz_static/core.md +++ b/specs/test_formats/ssz_static/core.md @@ -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` diff --git a/test_generators/ssz_static/main.py b/test_generators/ssz_static/main.py index c9c45a5a0..32178cfe0 100644 --- a/test_generators/ssz_static/main.py +++ b/test_generators/ssz_static/main.py @@ -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():