Apply PR feedback from @michaelsproul

This commit is contained in:
Hsiao-Wei Wang 2022-09-02 20:41:55 +08:00
parent ac717b106a
commit 0f8b5ae6bd
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
2 changed files with 9 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import sys
import json
from typing import Iterable, AnyStr, Any, Callable
import traceback
from ruamel.yaml import (
YAML,
)
@ -98,6 +97,11 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
yaml = YAML(pure=True)
yaml.default_flow_style = None
def _represent_none(self, _):
return self.represent_scalar('tag:yaml.org,2002:null', 'null')
yaml.representer.add_representer(type(None), _represent_none)
# Spec config is using a YAML subset
cfg_yaml = YAML(pure=True)
cfg_yaml.default_flow_style = False # Emit separate line for each key

View File

@ -42,9 +42,9 @@ class PayloadStatusV1:
@property
def formatted_output(self):
return {
'status': str(self.status),
'latest_valid_hash': encode_hex(self.latest_valid_hash) if self.latest_valid_hash is not None else 'null',
'validation_error': str(self.validation_error) if self.validation_error is not None else 'null'
'status': str(self.status.value),
'latest_valid_hash': encode_hex(self.latest_valid_hash) if self.latest_valid_hash is not None else None,
'validation_error': str(self.validation_error) if self.validation_error is not None else None
}
@ -95,6 +95,7 @@ def add_optimistic_block(spec, mega_store, signed_block, test_steps,
mega_store.block_payload_statuses[block_root] = payload_status
test_steps.append({
'block_hash': encode_hex(el_block_hash),
'payload_status': payload_status.formatted_output,
})