コード例 #1
0
ファイル: main.py プロジェクト: zhangdilu/eth2.0-specs
    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
ファイル: conftest.py プロジェクト: zah/eth2.0-specs
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)
コード例 #7
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
コード例 #8
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]:
コード例 #9
0
ファイル: main.py プロジェクト: zigen/eth2.0-specs
 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
コード例 #10
0
def pycli(pre, post):
    presets = loader.load_presets('eth2.0-specs/configs/', 'minimal')
    spec.apply_constants_preset(presets)
コード例 #11
0
ファイル: harness.py プロジェクト: sigp/eth2.0-fuzzing
from eth2spec.phase0 import spec as spec
from preset_loader import loader
from ssz.exceptions import DeserializationError
presets = loader.load_presets(
    '/home/jhg/eth-2019/x/eth2.0-fuzzing/files/fuzzers/block/eth2.0-specs/configs',
    'minimal')
spec.apply_constants_preset(presets)

from eth2spec.fuzzing.decoder import translate_typ, translate_value

block_sedes = translate_typ(spec.BeaconBlock)


def FuzzerRunOne(FuzzerInput):
    try:
        obj = block_sedes.deserialize(FuzzerInput)
        serialized = block_sedes.serialize(obj)
        if serialized != FuzzerInput:
            print("original: " + str([FuzzerInput]))
            print("serialized: " + str([serialized]))
            raise Exception("")
    except DeserializationError:
        pass
コード例 #12
0
import os
import sys
from eth2spec.phase0 import spec as spec

# Apply 'minimal' template
from preset_loader import loader

configs_path = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
                            'eth2.0-specs/configs')
presets = loader.load_presets(configs_path, 'minimal')
spec.apply_constants_preset(presets)

import copy
from eth2spec.fuzzing.decoder import translate_typ, translate_value
from eth2spec.utils.ssz.ssz_typing import uint32, uint8
from eth2spec.utils.ssz.ssz_impl import serialize

from eth2spec.utils import bls

bls.bls_active = False


class StateBlock(spec.Container):
    stateID: uint32
    block: spec.BeaconBlock


state_block_sedes = translate_typ(StateBlock)


def load_prestates():
コード例 #13
0
def load_presets(configs_path, config_name):
    global presets
    presets = loader.load_presets(configs_path, config_name)