Ejemplo n.º 1
0
def _load_and_parse_test_suites(
    tests_path: Path,
    test_type: TestType[HandlerType],
    test_handler: TestHandler[Input, Output],
    config_type: ConfigType,
    fork_type: ForkType,
) -> Iterable[TestSuite]:
    test_handler_path = _build_test_handler_path(tests_path, test_type,
                                                 test_handler, config_type,
                                                 fork_type)

    test_suite_descriptors = _discover_test_suite_from(test_handler_path)

    if config_type.has_config():
        config_path = tests_path / Path(config_type.name) / Path(
            config_type.path)
        config = load_config_at_path(config_path)
        override_lengths(config)
    else:
        config = None

    for descriptor in test_suite_descriptors:
        yield TestSuite(
            descriptor.name,
            _parse_test_cases(config, test_handler,
                              descriptor.test_case_descriptors),
        )
Ejemplo n.º 2
0
def parse_test_suite(
    test_type: TestType[HandlerType],
    test_handler: TestHandler[Input, Output],
    config_type: Optional[ConfigType],
) -> TestSuite:
    project_root_dir = _find_project_root_dir(TESTS_ROOT_PATH)
    tests_path = project_root_dir / TESTS_ROOT_PATH / TESTS_PATH
    if config_type:
        config_path = project_root_dir / config_type.path
        config = load_config_at_path(config_path)
        override_lengths(config)
    else:
        config = None

    return _load_test_suite(tests_path, test_type, test_handler, config_type,
                            config)
Ejemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-ssz", type=str, required=True)
    parser.add_argument("-config", type=str, required=True)
    args = parser.parse_args()

    config_path = Path(args.config)
    minimal_config = load_config_at_path(config_path)
    override_lengths(minimal_config)

    with open(args.ssz, "rb") as f:
        encoded = f.read()
    state = ssz.decode(encoded, sedes=BeaconState)

    yaml = YAML(typ="unsafe")
    yaml.dump(to_formatted_dict(state), sys.stdout)
Ejemplo n.º 4
0
def _load_config(config):
    config_file_name = KEY_DIR / Path(f"config_{config.name}.yaml")
    return load_config_at_path(config_file_name)