2021-03-09 02:11:31 +00:00
|
|
|
from typing import Iterable
|
|
|
|
|
2022-10-13 19:53:40 +00:00
|
|
|
from eth2spec.test.helpers.constants import (
|
2024-04-24 12:08:56 +00:00
|
|
|
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA,
|
2022-10-13 19:53:40 +00:00
|
|
|
MINIMAL, MAINNET,
|
|
|
|
)
|
2021-05-18 16:29:24 +00:00
|
|
|
from eth2spec.test.helpers.typing import SpecForkName, PresetBaseName
|
2021-05-19 01:05:07 +00:00
|
|
|
from eth2spec.test.altair.fork import test_altair_fork_basic, test_altair_fork_random
|
2021-12-23 16:56:55 +00:00
|
|
|
from eth2spec.test.bellatrix.fork import test_bellatrix_fork_basic, test_bellatrix_fork_random
|
2022-10-13 19:53:40 +00:00
|
|
|
from eth2spec.test.capella.fork import test_capella_fork_basic, test_capella_fork_random
|
2023-01-23 14:08:34 +00:00
|
|
|
from eth2spec.test.deneb.fork import test_deneb_fork_basic, test_deneb_fork_random
|
2024-04-24 12:08:56 +00:00
|
|
|
from eth2spec.test.electra.fork import test_electra_fork_basic, test_electra_fork_random
|
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-05-18 16:29:24 +00:00
|
|
|
def create_provider(tests_src, preset_name: PresetBaseName,
|
|
|
|
phase: SpecForkName, fork_name: SpecForkName) -> gen_typing.TestProvider:
|
2021-03-09 02:11:31 +00:00
|
|
|
|
2021-05-18 16:29:24 +00:00
|
|
|
def prepare_fn() -> None:
|
|
|
|
return
|
2021-03-09 02:11:31 +00:00
|
|
|
|
|
|
|
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,
|
2021-05-18 16:29:24 +00:00
|
|
|
preset_name=preset_name,
|
2021-03-09 23:27:06 +00:00
|
|
|
phase=phase,
|
2021-03-09 02:11:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
|
|
|
|
|
|
|
|
2021-12-23 16:56:55 +00:00
|
|
|
def _get_fork_tests_providers():
|
|
|
|
for preset in [MINIMAL, MAINNET]:
|
|
|
|
yield create_provider(test_altair_fork_basic, preset, PHASE0, ALTAIR)
|
|
|
|
yield create_provider(test_altair_fork_random, preset, PHASE0, ALTAIR)
|
|
|
|
yield create_provider(test_bellatrix_fork_basic, preset, ALTAIR, BELLATRIX)
|
|
|
|
yield create_provider(test_bellatrix_fork_random, preset, ALTAIR, BELLATRIX)
|
2022-10-13 19:53:40 +00:00
|
|
|
yield create_provider(test_capella_fork_basic, preset, BELLATRIX, CAPELLA)
|
|
|
|
yield create_provider(test_capella_fork_random, preset, BELLATRIX, CAPELLA)
|
2023-01-23 14:08:34 +00:00
|
|
|
yield create_provider(test_deneb_fork_basic, preset, CAPELLA, DENEB)
|
|
|
|
yield create_provider(test_deneb_fork_random, preset, CAPELLA, DENEB)
|
2024-04-24 12:08:56 +00:00
|
|
|
yield create_provider(test_electra_fork_basic, preset, DENEB, ELECTRA)
|
|
|
|
yield create_provider(test_electra_fork_random, preset, DENEB, ELECTRA)
|
2021-12-23 16:56:55 +00:00
|
|
|
|
|
|
|
|
2021-03-09 02:11:31 +00:00
|
|
|
if __name__ == "__main__":
|
2021-12-23 16:56:55 +00:00
|
|
|
gen_runner.run_generator("forks", list(_get_fork_tests_providers()))
|