Skip to content

Commit

Permalink
Move gen_helpers into a module of eth2spec package
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Feb 18, 2021
1 parent c7d9759 commit 9cc8567
Show file tree
Hide file tree
Showing 29 changed files with 43 additions and 44 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
YAML,
)

from gen_base.gen_typing import TestProvider

from eth2spec.test import context
from eth2spec.test.exceptions import SkippedTest

from .gen_typing import TestProvider


# Flag that the runner does NOT run test via pytest
context.is_pytest = False
Expand Down Expand Up @@ -119,10 +119,11 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):

print(f"generating tests with config '{config_name}' ...")
for test_case in tprov.make_cases():
case_dir = Path(output_dir) / Path(config_name) / Path(test_case.fork_name) \
/ Path(test_case.runner_name) / Path(test_case.handler_name) \
/ Path(test_case.suite_name) / Path(test_case.case_name)

case_dir = (
Path(output_dir) / Path(config_name) / Path(test_case.fork_name)
/ Path(test_case.runner_name) / Path(test_case.handler_name)
/ Path(test_case.suite_name) / Path(test_case.case_name)
)
if case_dir.exists():
if not args.force:
print(f'Skipping already existing test: {case_dir}')
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from eth2spec.config import config_util
from eth2spec.utils import bls

from eth2spec.test.context import ALL_CONFIGS, TESTGEN_FORKS, SpecForkName, ConfigName
from gen_base import gen_runner
from gen_base.gen_typing import TestCase, TestProvider

from eth2spec.gen_helpers.gen_base import gen_runner
from eth2spec.gen_helpers.gen_base.gen_typing import TestCase, TestProvider


def generate_from_tests(runner_name: str, handler_name: str, src: Any,
Expand Down Expand Up @@ -56,11 +56,12 @@ def get_provider(create_provider_fn: Callable[[SpecForkName, str, str, ConfigNam
handler_name=key,
tests_src_mod_name=mod_name,
config_name=config_name,
)
)


def get_create_provider_fn(runner_name: str, config_name: ConfigName, specs: Iterable[Any]
) -> Callable[[SpecForkName, str, str, ConfigName], TestProvider]:
def get_create_provider_fn(
runner_name: str, config_name: ConfigName, specs: Iterable[Any]
) -> Callable[[SpecForkName, str, str, ConfigName], TestProvider]:
def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name)
for spec in specs:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/generators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Write a `main.py` file. The shuffling test generator is a good minimal starting
```python
from eth2spec.phase0 import spec as spec
from eth_utils import to_tuple
from gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
from preset_loader import loader
from typing import Iterable

Expand Down
2 changes: 1 addition & 1 deletion tests/generators/bls/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from eth2spec.utils import bls
from eth2spec.test.context import PHASE0
from gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing


def to_bytes(i):
Expand Down
4 changes: 1 addition & 3 deletions tests/generators/bls/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
py_ecc==5.1.0
eth-utils==1.6.0
../../core/gen_helpers
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/epoch_processing/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1
Expand Down
4 changes: 2 additions & 2 deletions tests/generators/epoch_processing/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/finality/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1
Expand Down
4 changes: 2 additions & 2 deletions tests/generators/finality/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../
4 changes: 2 additions & 2 deletions tests/generators/genesis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from eth2spec.test.context import PHASE0
from eth2spec.test.phase0.genesis import test_initialization, test_validity

from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests
from eth2spec.phase0 import spec as spec
from importlib import reload
from eth2spec.config import config_util
Expand Down
4 changes: 2 additions & 2 deletions tests/generators/genesis/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/operations/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1
Expand Down
5 changes: 2 additions & 3 deletions tests/generators/operations/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
eth-utils==1.6.0
../../core/gen_helpers
../../../
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/rewards/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gen_from_tests.gen import run_state_test_generators
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1
Expand Down
4 changes: 2 additions & 2 deletions tests/generators/rewards/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../
3 changes: 2 additions & 1 deletion tests/generators/sanity/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH

from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators


specs = (spec_phase0, spec_lightclient_patch, spec_phase1)

Expand Down
4 changes: 2 additions & 2 deletions tests/generators/sanity/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/shuffling/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Iterable
from importlib import reload

from gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing

from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec
Expand Down
2 changes: 1 addition & 1 deletion tests/generators/ssz_generic/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Iterable
from gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
import ssz_basic_vector
import ssz_bitlist
import ssz_bitvector
Expand Down
3 changes: 1 addition & 2 deletions tests/generators/ssz_generic/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
eth-utils==1.6.0
../../core/gen_helpers
pytest>=4.4
../../../
2 changes: 1 addition & 1 deletion tests/generators/ssz_static/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from importlib import reload
from inspect import getmembers, isclass

from gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing

from eth2spec.debug import random_value, encode
from eth2spec.config import config_util
Expand Down
4 changes: 2 additions & 2 deletions tests/generators/ssz_static/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../core/gen_helpers
../../../
pytest>=4.4
../../../

0 comments on commit 9cc8567

Please sign in to comment.