2019-07-27 20:31:04 +00:00
|
|
|
from typing import Iterable
|
2021-02-18 07:17:47 +00:00
|
|
|
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
|
2019-07-27 20:31:04 +00:00
|
|
|
import ssz_basic_vector
|
|
|
|
import ssz_bitlist
|
|
|
|
import ssz_bitvector
|
|
|
|
import ssz_boolean
|
|
|
|
import ssz_uints
|
2019-07-27 21:57:07 +00:00
|
|
|
import ssz_container
|
2020-04-02 07:23:20 +00:00
|
|
|
from eth2spec.test.context import PHASE0
|
2019-07-27 20:31:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def create_provider(handler_name: str, suite_name: str, case_maker) -> gen_typing.TestProvider:
|
|
|
|
|
|
|
|
def prepare_fn(configs_path: str) -> str:
|
|
|
|
return "general"
|
|
|
|
|
|
|
|
def cases_fn() -> Iterable[gen_typing.TestCase]:
|
|
|
|
for (case_name, case_fn) in case_maker():
|
|
|
|
yield gen_typing.TestCase(
|
2020-04-02 07:23:20 +00:00
|
|
|
fork_name=PHASE0,
|
2019-07-27 20:31:04 +00:00
|
|
|
runner_name='ssz_generic',
|
|
|
|
handler_name=handler_name,
|
|
|
|
suite_name=suite_name,
|
|
|
|
case_name=case_name,
|
|
|
|
case_fn=case_fn
|
|
|
|
)
|
|
|
|
|
|
|
|
return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)
|
2019-03-27 16:32:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-07-27 20:31:04 +00:00
|
|
|
gen_runner.run_generator("ssz_generic", [
|
|
|
|
create_provider("basic_vector", "valid", ssz_basic_vector.valid_cases),
|
|
|
|
create_provider("basic_vector", "invalid", ssz_basic_vector.invalid_cases),
|
|
|
|
create_provider("bitlist", "valid", ssz_bitlist.valid_cases),
|
|
|
|
create_provider("bitlist", "invalid", ssz_bitlist.invalid_cases),
|
|
|
|
create_provider("bitvector", "valid", ssz_bitvector.valid_cases),
|
|
|
|
create_provider("bitvector", "invalid", ssz_bitvector.invalid_cases),
|
|
|
|
create_provider("boolean", "valid", ssz_boolean.valid_cases),
|
|
|
|
create_provider("boolean", "invalid", ssz_boolean.invalid_cases),
|
|
|
|
create_provider("uints", "valid", ssz_uints.valid_cases),
|
|
|
|
create_provider("uints", "invalid", ssz_uints.invalid_cases),
|
2019-07-27 21:57:07 +00:00
|
|
|
create_provider("containers", "valid", ssz_container.valid_cases),
|
|
|
|
create_provider("containers", "invalid", ssz_container.invalid_cases),
|
2019-07-27 20:31:04 +00:00
|
|
|
])
|