2019-05-23 13:53:11 +00:00
|
|
|
from typing import Callable, Iterable
|
|
|
|
|
2019-05-23 21:32:21 +00:00
|
|
|
from eth2spec.test.sanity import test_blocks, test_slots
|
2019-05-23 13:53:11 +00:00
|
|
|
|
|
|
|
from gen_base import gen_runner, gen_suite, gen_typing
|
|
|
|
from gen_from_tests.gen import generate_from_tests
|
|
|
|
from preset_loader import loader
|
|
|
|
from eth2spec.phase0 import spec
|
|
|
|
|
|
|
|
|
2019-05-23 21:32:21 +00:00
|
|
|
def create_suite(handler_name: str, config_name: str, get_cases: Callable[[], Iterable[gen_typing.TestCase]]) \
|
2019-05-23 13:53:11 +00:00
|
|
|
-> Callable[[str], gen_typing.TestSuiteOutput]:
|
|
|
|
def suite_definition(configs_path: str) -> gen_typing.TestSuiteOutput:
|
|
|
|
presets = loader.load_presets(configs_path, config_name)
|
|
|
|
spec.apply_constants_preset(presets)
|
|
|
|
|
2019-05-23 21:32:21 +00:00
|
|
|
return ("%sanity_s_%s" % (handler_name, config_name), handler_name, gen_suite.render_suite(
|
2019-05-23 13:53:11 +00:00
|
|
|
title="sanity testing",
|
2019-05-23 21:32:21 +00:00
|
|
|
summary="Sanity test suite, %s type, generated from pytests" % handler_name,
|
2019-05-23 13:53:11 +00:00
|
|
|
forks_timeline="testing",
|
|
|
|
forks=["phase0"],
|
|
|
|
config=config_name,
|
|
|
|
runner="sanity",
|
2019-05-23 21:32:21 +00:00
|
|
|
handler=handler_name,
|
2019-05-23 13:53:11 +00:00
|
|
|
test_cases=get_cases()))
|
|
|
|
return suite_definition
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
gen_runner.run_generator("sanity", [
|
2019-05-23 21:32:21 +00:00
|
|
|
create_suite('blocks', 'minimal', lambda: generate_from_tests(test_blocks)),
|
|
|
|
create_suite('blocks', 'mainnet', lambda: generate_from_tests(test_blocks)),
|
|
|
|
create_suite('slots', 'minimal', lambda: generate_from_tests(test_slots)),
|
|
|
|
create_suite('slots', 'mainnet', lambda: generate_from_tests(test_slots)),
|
2019-05-23 13:53:11 +00:00
|
|
|
])
|