Use phase name constants for the fork names in test generators

This commit is contained in:
Hsiao-Wei Wang 2020-04-02 15:23:20 +08:00
parent 3f87cea435
commit 523315bf4f
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
8 changed files with 16 additions and 8 deletions

View File

@ -13,6 +13,7 @@ from gen_base import gen_runner, gen_typing
from py_ecc import bls
from hashlib import sha256
from eth2spec.test.context import PHASE0
def hash(x):
return sha256(x).digest()
@ -202,7 +203,7 @@ def create_provider(handler_name: str,
print(data)
(case_name, case_content) = data
yield gen_typing.TestCase(
fork_name='phase0',
fork_name=PHASE0,
runner_name='bls',
handler_name=handler_name,
suite_name='small',

View File

@ -13,6 +13,7 @@ from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests
from importlib import reload
from eth2spec.config import config_util
from eth2spec.test.context import PHASE0
def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider:
@ -28,7 +29,7 @@ def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typin
runner_name='epoch_processing',
handler_name=handler_name,
src=tests_src,
fork_name='phase0'
fork_name=PHASE0,
)
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)

View File

@ -1,5 +1,6 @@
from typing import Iterable
from eth2spec.test.context import PHASE0
from eth2spec.test.genesis import test_initialization, test_validity
from gen_base import gen_runner, gen_typing
@ -21,7 +22,7 @@ def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typin
runner_name='genesis',
handler_name=handler_name,
src=tests_src,
fork_name='phase0'
fork_name=PHASE0,
)
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)

View File

@ -15,6 +15,7 @@ from importlib import reload
from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0
def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider:
@ -30,7 +31,7 @@ def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typin
runner_name='operations',
handler_name=handler_name,
src=tests_src,
fork_name='phase0'
fork_name=PHASE0,
)
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)

View File

@ -4,6 +4,7 @@ from importlib import reload
from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests
from eth2spec.test.context import PHASE0
from eth2spec.test.sanity import test_blocks, test_slots
from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0
@ -23,7 +24,7 @@ def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typin
runner_name='sanity',
handler_name=handler_name,
src=tests_src,
fork_name='phase0'
fork_name=PHASE0,
)
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)

View File

@ -6,6 +6,7 @@ from gen_base import gen_runner, gen_typing
from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec
from eth2spec.test.context import PHASE0
def shuffling_case_fn(seed, count):
@ -37,7 +38,7 @@ def create_provider(config_name: str) -> gen_typing.TestProvider:
def cases_fn() -> Iterable[gen_typing.TestCase]:
for (case_name, case_fn) in shuffling_test_cases():
yield gen_typing.TestCase(
fork_name='phase0',
fork_name=PHASE0,
runner_name='shuffling',
handler_name='core',
suite_name='shuffle',

View File

@ -6,6 +6,7 @@ import ssz_bitvector
import ssz_boolean
import ssz_uints
import ssz_container
from eth2spec.test.context import PHASE0
def create_provider(handler_name: str, suite_name: str, case_maker) -> gen_typing.TestProvider:
@ -16,7 +17,7 @@ def create_provider(handler_name: str, suite_name: str, case_maker) -> gen_typin
def cases_fn() -> Iterable[gen_typing.TestCase]:
for (case_name, case_fn) in case_maker():
yield gen_typing.TestCase(
fork_name='phase0',
fork_name=PHASE0,
runner_name='ssz_generic',
handler_name=handler_name,
suite_name=suite_name,

View File

@ -8,6 +8,7 @@ from gen_base import gen_runner, gen_typing
from eth2spec.debug import random_value, encode
from eth2spec.config import config_util
from eth2spec.phase0 import spec
from eth2spec.test.context import PHASE0
from eth2spec.utils.ssz.ssz_typing import Container
from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root,
@ -44,7 +45,7 @@ def ssz_static_cases(seed: int, name, ssz_type, mode: random_value.Randomization
for i in range(count):
yield gen_typing.TestCase(
fork_name='phase0',
fork_name=PHASE0,
runner_name='ssz_static',
handler_name=name,
suite_name=f"ssz_{random_mode_name}{'_chaos' if chaos else ''}",