2021-03-09 02:11:31 +00:00
|
|
|
from importlib import reload
|
|
|
|
from typing import Iterable
|
|
|
|
|
2021-03-09 12:55:39 +00:00
|
|
|
from eth2spec.test.context import PHASE0, LIGHTCLIENT_PATCH, MINIMAL, MAINNET
|
2021-03-09 02:11:31 +00:00
|
|
|
from eth2spec.config import config_util
|
|
|
|
from eth2spec.test.lightclient_patch.fork import test_fork as test_altair_forks
|
|
|
|
from eth2spec.phase0 import spec as spec_phase0
|
2021-03-09 13:32:37 +00:00
|
|
|
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
|
2021-03-09 02:11:31 +00:00
|
|
|
|
|
|
|
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
|
|
|
|
from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests
|
|
|
|
|
|
|
|
|
2021-03-09 23:27:06 +00:00
|
|
|
def create_provider(tests_src, config_name: str, phase: str, fork_name: str) -> gen_typing.TestProvider:
|
2021-03-09 02:11:31 +00:00
|
|
|
|
|
|
|
def prepare_fn(configs_path: str) -> str:
|
|
|
|
config_util.prepare_config(configs_path, config_name)
|
2021-03-09 12:55:39 +00:00
|
|
|
reload(spec_phase0)
|
2021-03-09 13:32:37 +00:00
|
|
|
reload(spec_lightclient_patch)
|
2021-03-09 02:11:31 +00:00
|
|
|
return config_name
|
|
|
|
|
|
|
|
def cases_fn() -> Iterable[gen_typing.TestCase]:
|
|
|
|
return generate_from_tests(
|
2021-03-09 12:55:39 +00:00
|
|
|
runner_name='fork',
|
|
|
|
handler_name='fork',
|
2021-03-09 02:11:31 +00:00
|
|
|
src=tests_src,
|
2021-03-09 23:27:06 +00:00
|
|
|
fork_name=fork_name,
|
|
|
|
phase=phase,
|
2021-03-09 02:11:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
gen_runner.run_generator("forks", [
|
2021-03-09 23:27:06 +00:00
|
|
|
create_provider(test_altair_forks, MINIMAL, PHASE0, LIGHTCLIENT_PATCH),
|
|
|
|
create_provider(test_altair_forks, MAINNET, PHASE0, LIGHTCLIENT_PATCH),
|
2021-03-09 02:11:31 +00:00
|
|
|
])
|