mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-13 04:04:19 +00:00
remove yaml duplicates, compress SSZ test outputs
This commit is contained in:
parent
a64ae8137d
commit
4c90c357b7
@ -9,6 +9,7 @@ from ruamel.yaml import (
|
||||
)
|
||||
|
||||
from gen_base.gen_typing import TestProvider
|
||||
from snappy import compress
|
||||
|
||||
from eth2spec.test import context
|
||||
from eth2spec.test.exceptions import SkippedTest
|
||||
@ -180,7 +181,8 @@ def dump_yaml_fn(data: Any, name: str, file_mode: str, yaml_encoder: YAML):
|
||||
|
||||
def dump_ssz_fn(data: AnyStr, name: str, file_mode: str):
|
||||
def dump(case_path: Path):
|
||||
out_path = case_path / Path(name + '.ssz')
|
||||
out_path = case_path / Path(name + '.ssz_snappy')
|
||||
compressed = compress(data)
|
||||
with out_path.open(file_mode + 'b') as f: # write in raw binary mode
|
||||
f.write(data)
|
||||
f.write(compressed)
|
||||
return dump
|
||||
|
@ -1,3 +1,4 @@
|
||||
ruamel.yaml==0.16.5
|
||||
eth-utils==1.6.0
|
||||
pytest>=4.4
|
||||
python-snappy==0.5.4
|
||||
|
@ -7,5 +7,6 @@ setup(
|
||||
"ruamel.yaml==0.16.5",
|
||||
"eth-utils==1.6.0",
|
||||
"pytest>=4.4",
|
||||
"python-snappy==0.5.4",
|
||||
]
|
||||
)
|
||||
|
@ -39,24 +39,20 @@ def vector_test(description: str = None):
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(value, View):
|
||||
yield key, 'data', encode(value)
|
||||
yield key, 'ssz', serialize(value)
|
||||
elif isinstance(value, bytes):
|
||||
yield key, 'data', encode(value)
|
||||
yield key, 'ssz', value
|
||||
elif isinstance(value, list) and all([isinstance(el, (View, bytes)) for el in value]):
|
||||
for i, el in enumerate(value):
|
||||
if isinstance(el, View):
|
||||
yield f'{key}_{i}', 'data', encode(el)
|
||||
yield f'{key}_{i}', 'ssz', serialize(el)
|
||||
elif isinstance(el, bytes):
|
||||
yield f'{key}_{i}', 'data', encode(el)
|
||||
yield f'{key}_{i}', 'ssz', el
|
||||
yield f'{key}_count', 'meta', len(value)
|
||||
else:
|
||||
# Not a ssz value.
|
||||
# The data will now just be yielded as any python data,
|
||||
# something that should be encodeable by the generator runner.
|
||||
# something that should be encodable by the generator runner.
|
||||
yield key, 'data', value
|
||||
|
||||
# check generator mode, may be None/else.
|
||||
|
Loading…
x
Reference in New Issue
Block a user