Use phase name constants for the fork names in test generators
This commit is contained in:
parent
3f87cea435
commit
523315bf4f
|
@ -13,6 +13,7 @@ from gen_base import gen_runner, gen_typing
|
||||||
from py_ecc import bls
|
from py_ecc import bls
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
||||||
|
from eth2spec.test.context import PHASE0
|
||||||
|
|
||||||
def hash(x):
|
def hash(x):
|
||||||
return sha256(x).digest()
|
return sha256(x).digest()
|
||||||
|
@ -202,7 +203,7 @@ def create_provider(handler_name: str,
|
||||||
print(data)
|
print(data)
|
||||||
(case_name, case_content) = data
|
(case_name, case_content) = data
|
||||||
yield gen_typing.TestCase(
|
yield gen_typing.TestCase(
|
||||||
fork_name='phase0',
|
fork_name=PHASE0,
|
||||||
runner_name='bls',
|
runner_name='bls',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
suite_name='small',
|
suite_name='small',
|
||||||
|
|
|
@ -13,6 +13,7 @@ from gen_base import gen_runner, gen_typing
|
||||||
from gen_from_tests.gen import generate_from_tests
|
from gen_from_tests.gen import generate_from_tests
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
from eth2spec.config import config_util
|
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:
|
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',
|
runner_name='epoch_processing',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
src=tests_src,
|
src=tests_src,
|
||||||
fork_name='phase0'
|
fork_name=PHASE0,
|
||||||
)
|
)
|
||||||
|
|
||||||
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
|
from eth2spec.test.context import PHASE0
|
||||||
from eth2spec.test.genesis import test_initialization, test_validity
|
from eth2spec.test.genesis import test_initialization, test_validity
|
||||||
|
|
||||||
from gen_base import gen_runner, gen_typing
|
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',
|
runner_name='genesis',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
src=tests_src,
|
src=tests_src,
|
||||||
fork_name='phase0'
|
fork_name=PHASE0,
|
||||||
)
|
)
|
||||||
|
|
||||||
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
||||||
|
|
|
@ -15,6 +15,7 @@ from importlib import reload
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider:
|
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',
|
runner_name='operations',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
src=tests_src,
|
src=tests_src,
|
||||||
fork_name='phase0'
|
fork_name=PHASE0,
|
||||||
)
|
)
|
||||||
|
|
||||||
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from importlib import reload
|
||||||
from gen_base import gen_runner, gen_typing
|
from gen_base import gen_runner, gen_typing
|
||||||
from gen_from_tests.gen import generate_from_tests
|
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.test.sanity import test_blocks, test_slots
|
||||||
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
|
||||||
|
@ -23,7 +24,7 @@ def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typin
|
||||||
runner_name='sanity',
|
runner_name='sanity',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
src=tests_src,
|
src=tests_src,
|
||||||
fork_name='phase0'
|
fork_name=PHASE0,
|
||||||
)
|
)
|
||||||
|
|
||||||
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from gen_base import gen_runner, gen_typing
|
||||||
|
|
||||||
from eth2spec.config import config_util
|
from eth2spec.config import config_util
|
||||||
from eth2spec.phase0 import spec as spec
|
from eth2spec.phase0 import spec as spec
|
||||||
|
from eth2spec.test.context import PHASE0
|
||||||
|
|
||||||
|
|
||||||
def shuffling_case_fn(seed, count):
|
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]:
|
def cases_fn() -> Iterable[gen_typing.TestCase]:
|
||||||
for (case_name, case_fn) in shuffling_test_cases():
|
for (case_name, case_fn) in shuffling_test_cases():
|
||||||
yield gen_typing.TestCase(
|
yield gen_typing.TestCase(
|
||||||
fork_name='phase0',
|
fork_name=PHASE0,
|
||||||
runner_name='shuffling',
|
runner_name='shuffling',
|
||||||
handler_name='core',
|
handler_name='core',
|
||||||
suite_name='shuffle',
|
suite_name='shuffle',
|
||||||
|
|
|
@ -6,6 +6,7 @@ import ssz_bitvector
|
||||||
import ssz_boolean
|
import ssz_boolean
|
||||||
import ssz_uints
|
import ssz_uints
|
||||||
import ssz_container
|
import ssz_container
|
||||||
|
from eth2spec.test.context import PHASE0
|
||||||
|
|
||||||
|
|
||||||
def create_provider(handler_name: str, suite_name: str, case_maker) -> gen_typing.TestProvider:
|
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]:
|
def cases_fn() -> Iterable[gen_typing.TestCase]:
|
||||||
for (case_name, case_fn) in case_maker():
|
for (case_name, case_fn) in case_maker():
|
||||||
yield gen_typing.TestCase(
|
yield gen_typing.TestCase(
|
||||||
fork_name='phase0',
|
fork_name=PHASE0,
|
||||||
runner_name='ssz_generic',
|
runner_name='ssz_generic',
|
||||||
handler_name=handler_name,
|
handler_name=handler_name,
|
||||||
suite_name=suite_name,
|
suite_name=suite_name,
|
||||||
|
|
|
@ -8,6 +8,7 @@ from gen_base import gen_runner, gen_typing
|
||||||
from eth2spec.debug import random_value, encode
|
from eth2spec.debug import random_value, encode
|
||||||
from eth2spec.config import config_util
|
from eth2spec.config import config_util
|
||||||
from eth2spec.phase0 import spec
|
from eth2spec.phase0 import spec
|
||||||
|
from eth2spec.test.context import PHASE0
|
||||||
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,
|
||||||
|
@ -44,7 +45,7 @@ def ssz_static_cases(seed: int, name, ssz_type, mode: random_value.Randomization
|
||||||
|
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
yield gen_typing.TestCase(
|
yield gen_typing.TestCase(
|
||||||
fork_name='phase0',
|
fork_name=PHASE0,
|
||||||
runner_name='ssz_static',
|
runner_name='ssz_static',
|
||||||
handler_name=name,
|
handler_name=name,
|
||||||
suite_name=f"ssz_{random_mode_name}{'_chaos' if chaos else ''}",
|
suite_name=f"ssz_{random_mode_name}{'_chaos' if chaos else ''}",
|
||||||
|
|
Loading…
Reference in New Issue