Merge pull request #2210 from mpetrunic/mpetrunic/lc-ssz-static

Disable phase1/enable lightclient ssz static types tests generators
This commit is contained in:
Hsiao-Wei Wang 2021-02-23 22:26:13 +08:00 committed by GitHub
commit 63d3dae7a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -9,7 +9,8 @@ from eth2spec.debug import random_value, encode
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.test.context import PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, MINIMAL, MAINNET
from eth2spec.utils.ssz.ssz_typing import Container from eth2spec.utils.ssz.ssz_typing import Container
from eth2spec.utils.ssz.ssz_impl import ( from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root, hash_tree_root,
@ -64,6 +65,7 @@ def create_provider(fork_name, config_name: str, seed: int, mode: random_value.R
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_phase1) reload(spec_phase1)
reload(spec_lightclient_patch)
return config_name return config_name
def cases_fn() -> Iterable[gen_typing.TestCase]: def cases_fn() -> Iterable[gen_typing.TestCase]:
@ -71,6 +73,8 @@ def create_provider(fork_name, config_name: str, seed: int, mode: random_value.R
spec = spec_phase0 spec = spec_phase0
if fork_name == PHASE1: if fork_name == PHASE1:
spec = spec_phase1 spec = spec_phase1
if fork_name == LIGHTCLIENT_PATCH:
spec = spec_lightclient_patch
for (i, (name, ssz_type)) in enumerate(get_spec_ssz_types(spec)): for (i, (name, ssz_type)) in enumerate(get_spec_ssz_types(spec)):
yield from ssz_static_cases(fork_name, seed * 1000 + i, name, ssz_type, mode, chaos, count) yield from ssz_static_cases(fork_name, seed * 1000 + i, name, ssz_type, mode, chaos, count)
@ -83,14 +87,14 @@ if __name__ == "__main__":
settings = [] settings = []
seed = 1 seed = 1
for mode in random_value.RandomizationMode: for mode in random_value.RandomizationMode:
settings.append((seed, "minimal", mode, False, 30)) settings.append((seed, MINIMAL, mode, False, 30))
seed += 1 seed += 1
settings.append((seed, "minimal", random_value.RandomizationMode.mode_random, True, 30)) settings.append((seed, MINIMAL, random_value.RandomizationMode.mode_random, True, 30))
seed += 1 seed += 1
settings.append((seed, "mainnet", random_value.RandomizationMode.mode_random, False, 5)) settings.append((seed, MAINNET, random_value.RandomizationMode.mode_random, False, 5))
seed += 1 seed += 1
for fork in [PHASE0, PHASE1]: for fork in TESTGEN_FORKS:
gen_runner.run_generator("ssz_static", [ gen_runner.run_generator("ssz_static", [
create_provider(fork, config_name, seed, mode, chaos, cases_if_random) create_provider(fork, config_name, seed, mode, chaos, cases_if_random)
for (seed, config_name, mode, chaos, cases_if_random) in settings for (seed, config_name, mode, chaos, cases_if_random) in settings