示例#1
0
    def ssz_suite(configs_path: str) -> gen_typing.TestSuiteOutput:
        # Apply changes to presets, this affects some of the vector types.
        presets = loader.load_presets(configs_path, config_name)
        spec.apply_constants_preset(presets)

        # Reproducible RNG
        rng = Random(seed)

        random_mode_name = mode.to_name()

        suite_name = f"ssz_{config_name}_{random_mode_name}{'_chaos' if chaos else ''}"

        count = cases_if_random if chaos or mode.is_changing() else 1
        print(
            f"generating SSZ-static suite ({count} cases per ssz type): {suite_name}"
        )

        return (
            suite_name, "core",
            gen_suite.render_suite(
                title=
                f"ssz testing, with {config_name} config, randomized with mode {random_mode_name}{' and with chaos applied' if chaos else ''}",
                summary="Test suite for ssz serialization and hash-tree-root",
                forks_timeline="testing",
                forks=["phase0"],
                config=config_name,
                runner="ssz",
                handler="static",
                test_cases=ssz_static_cases(rng, mode, chaos, count)))
示例#2
0
文件: main.py 项目: zah/eth2.0-specs
    def suite_definition(configs_path: str) -> gen_typing.TestSuiteOutput:
        presets = loader.load_presets(configs_path, config_name)
        spec.apply_constants_preset(presets)

        return ("%s_%s" % (transition_name, config_name), transition_name, gen_suite.render_suite(
            title="%s epoch processing" % transition_name,
            summary="Test suite for %s type epoch processing" % transition_name,
            forks_timeline="testing",
            forks=["phase0"],
            config=config_name,
            runner="epoch_processing",
            handler=transition_name,
            test_cases=get_cases()))
示例#3
0
def full_deposits_suite(configs_path: str) -> gen_typing.TestSuiteOutput:
    presets = loader.load_presets(configs_path, 'mainnet')
    spec.apply_constants_preset(presets)

    return ("deposit_full", "deposits",
            gen_suite.render_suite(
                title="deposit operation",
                summary="Test suite for deposit type operation processing",
                forks_timeline="mainnet",
                forks=["phase0"],
                config="mainnet",
                runner="operations",
                handler="deposits",
                test_cases=deposit_cases()))
示例#4
0
文件: main.py 项目: sigp/eth2.0-specs
    def suite_definition(configs_path: str) -> gen_typing.TestSuiteOutput:
        presets = loader.load_presets(configs_path, config_name)
        spec_phase0.apply_constants_preset(presets)
        spec_phase1.apply_constants_preset(presets)

        return ("sanity_%s_%s" % (handler_name, config_name), handler_name, gen_suite.render_suite(
            title="sanity testing",
            summary="Sanity test suite, %s type, generated from pytests" % handler_name,
            forks_timeline="testing",
            forks=["phase0"],
            config=config_name,
            runner="sanity",
            handler=handler_name,
            test_cases=get_cases()))
示例#5
0
def full_shuffling_suite(configs_path: str) -> gen_typing.TestSuiteOutput:
    presets = loader.load_presets(configs_path, 'mainnet')
    spec.apply_constants_preset(presets)

    return (
        "shuffling_full", "core",
        gen_suite.render_suite(
            title="Swap-or-Not Shuffling tests with mainnet config",
            summary=
            "Swap or not shuffling, with normal configured (secure) mainnet round-count",
            forks_timeline="mainnet",
            forks=["phase0"],
            config="mainnet",
            runner="shuffling",
            handler="core",
            test_cases=shuffling_test_cases()))
示例#6
0
def pyspec_transition(pre_state, pre_block):
    yaml = YAML(typ='base')
    loaded = yaml.load(Path('min.config.bak'))
    config_data = dict()
    for k, v in loaded.items():
        if v.startswith("0x"):
            config_data[k] = bytes.fromhex(v[2:])
        else:
            config_data[k] = int(v)

    spec.apply_constants_preset(config_data)

    spec_pre_state = decoder.translate_value(pre_state, spec.BeaconState)
    spec_pre_block = decoder.translate_value(pre_block, spec.BeaconBlock)

    spec_post_block = spec.state_transition(spec_pre_state, spec_pre_block,
                                            False)
    return spec_post_block
示例#7
0
def config(request):
    config_name = request.config.getoption("--config")
    from preset_loader import loader
    presets = loader.load_presets('../../configs/', config_name)
    spec.apply_constants_preset(presets)
示例#8
0
 def prepare_fn(configs_path: str) -> str:
     presets = loader.load_presets(configs_path, config_name)
     spec_phase0.apply_constants_preset(presets)
     spec_phase1.apply_constants_preset(presets)
     return config_name
示例#9
0
import typing

from eth2spec.fuzzing.decoder import translate_typ, translate_value
from eth2spec.phase0 import spec
from eth2spec.utils import bls
from eth2spec.utils.ssz.ssz_impl import serialize
from preset_loader import loader

# TODO(gnattishness) fix config path difficult to do unless we assume the eth2spec
# module is at a fixed position relative to the configs
# (i.e. it is inside a cloned eth2.0-specs repo)
configs_path = "/eth2/eth2.0-specs/configs"
# TODO allow this to be adjusted?
presets = loader.load_presets(configs_path, "mainnet")
spec.apply_constants_preset(presets)


class BlockHeaderTestCase(spec.Container):
    pre: spec.BeaconState
    block: spec.BeaconBlock


block_header_sedes = translate_typ(BlockHeaderTestCase)


def FuzzerInit(bls_disabled: bool) -> None:
    if bls_disabled:
        bls.bls_active = False


def FuzzerRunOne(input_data: bytes) -> typing.Optional[bytes]:
示例#10
0
 def prepare_fn(configs_path: str) -> str:
     # Apply changes to presets, this affects some of the vector types.
     presets = loader.load_presets(configs_path, config_name)
     spec.apply_constants_preset(presets)
     return config_name
示例#11
0
def pycli(pre, post):
    presets = loader.load_presets('eth2.0-specs/configs/', 'minimal')
    spec.apply_constants_preset(presets)