Exemplo n.º 1
0
                                                                      Any]]]]
) -> gen_typing.TestProvider:
    def prepare_fn(configs_path: str) -> str:
        # Nothing to load / change in spec. Maybe in future forks.
        # Put the tests into the general config category, to not require any particular configuration.
        return 'general'

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        for data in test_case_fn():
            print(data)
            (case_name, case_content) = data
            yield gen_typing.TestCase(
                fork_name='phase0',
                runner_name='bls',
                handler_name=handler_name,
                suite_name='small',
                case_name=case_name,
                case_fn=lambda: [('data', 'data', case_content)])

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("bls", [
        create_provider('sign', case01_sign),
        create_provider('verify', case02_verify),
        create_provider('aggregate', case03_aggregate),
        create_provider('fast_aggregate_verify', case04_fast_aggregate_verify),
        create_provider('aggregate_verify', case05_aggregate_verify),
    ])
Exemplo n.º 2
0
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.utils import bls


def create_provider(handler_name: str, tests_src,
                    config_name: str) -> gen_typing.TestProvider:
    def prepare_fn(configs_path: str) -> str:
        config_util.prepare_config(configs_path, config_name)
        reload(spec_phase0)
        reload(spec_phase1)
        bls.use_milagro()
        return config_name

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='finality',
            handler_name=handler_name,
            src=tests_src,
            fork_name=PHASE0,
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("finality", [
        create_provider('finality', test_finality, 'minimal'),
        create_provider('finality', test_finality, 'mainnet'),
    ])
Exemplo n.º 3
0
    for seed in [
            spec.hash(seed_init_value.to_bytes(length=4, byteorder='little'))
            for seed_init_value in range(30)
    ]:
        for count in [0, 1, 2, 3, 5, 10, 33, 100, 1000, 9999]:
            yield shuffling_case(seed, count)


def create_provider(config_name: str) -> gen_typing.TestProvider:
    def prepare_fn(configs_path: str) -> str:
        config_util.prepare_config(configs_path, config_name)
        reload(spec)
        return config_name

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        for (case_name, case_fn) in shuffling_test_cases():
            yield gen_typing.TestCase(fork_name='phase0',
                                      runner_name='shuffling',
                                      handler_name='core',
                                      suite_name='shuffle',
                                      case_name=case_name,
                                      case_fn=case_fn)

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator(
        "shuffling", [create_provider("minimal"),
                      create_provider("mainnet")])
Exemplo n.º 4
0
        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)))

    return ssz_suite


if __name__ == "__main__":
    # [(seed, config name, randomization mode, chaos on/off, cases_if_random)]
    settings = []
    seed = 1
    for mode in random_value.RandomizationMode:
        settings.append((seed, "minimal", mode, False, 30))
        seed += 1
    settings.append((seed, "minimal", random_value.RandomizationMode.mode_random, True, 30))
    seed += 1
    settings.append((seed, "mainnet", random_value.RandomizationMode.mode_random, False, 5))
    seed += 1

    gen_runner.run_generator("ssz_static", [
        get_ssz_suite(seed, config_name, mode, chaos, cases_if_random)
            for (seed, config_name, mode, chaos, cases_if_random) in settings
    ])
Exemplo n.º 5
0
 gen_runner.run_generator("operations", [
     create_suite('attestation', 'minimal',
                  lambda: generate_from_tests(test_process_attestation)),
     create_suite('attestation', 'mainnet',
                  lambda: generate_from_tests(test_process_attestation)),
     create_suite(
         'attester_slashing', 'minimal',
         lambda: generate_from_tests(test_process_attester_slashing)),
     create_suite(
         'attester_slashing', 'mainnet',
         lambda: generate_from_tests(test_process_attester_slashing)),
     create_suite('block_header', 'minimal',
                  lambda: generate_from_tests(test_process_block_header)),
     create_suite('block_header', 'mainnet',
                  lambda: generate_from_tests(test_process_block_header)),
     create_suite('deposit', 'minimal',
                  lambda: generate_from_tests(test_process_deposit)),
     create_suite('deposit', 'mainnet',
                  lambda: generate_from_tests(test_process_deposit)),
     create_suite(
         'proposer_slashing', 'minimal',
         lambda: generate_from_tests(test_process_proposer_slashing)),
     create_suite(
         'proposer_slashing', 'mainnet',
         lambda: generate_from_tests(test_process_proposer_slashing)),
     create_suite('transfer', 'minimal',
                  lambda: generate_from_tests(test_process_transfer)),
     create_suite('transfer', 'mainnet',
                  lambda: generate_from_tests(test_process_transfer)),
     create_suite('voluntary_exit', 'minimal',
                  lambda: generate_from_tests(test_process_voluntary_exit)),
     create_suite('voluntary_exit', 'mainnet',
                  lambda: generate_from_tests(test_process_voluntary_exit)),
 ])
Exemplo n.º 6
0
 gen_runner.run_generator("epoch_processing", [
     create_suite(
         'crosslinks', 'minimal',
         lambda: generate_from_tests(test_process_crosslinks, 'phase0')),
     create_suite(
         'crosslinks', 'mainnet',
         lambda: generate_from_tests(test_process_crosslinks, 'phase0')),
     create_suite(
         'final_updates', 'minimal',
         lambda: generate_from_tests(test_process_final_updates, 'phase0')),
     create_suite(
         'final_updates', 'mainnet',
         lambda: generate_from_tests(test_process_final_updates, 'phase0')),
     create_suite(
         'justification_and_finalization', 'minimal',
         lambda: generate_from_tests(
             test_process_justification_and_finalization, 'phase0')),
     create_suite(
         'justification_and_finalization', 'mainnet',
         lambda: generate_from_tests(
             test_process_justification_and_finalization, 'phase0')),
     create_suite(
         'registry_updates', 'minimal', lambda: generate_from_tests(
             test_process_registry_updates, 'phase0')),
     create_suite(
         'registry_updates', 'mainnet', lambda: generate_from_tests(
             test_process_registry_updates, 'phase0')),
     create_suite(
         'slashings', 'minimal',
         lambda: generate_from_tests(test_process_slashings, 'phase0')),
     create_suite(
         'slashings', 'mainnet',
         lambda: generate_from_tests(test_process_slashings, 'phase0')),
 ])
Exemplo n.º 7
0
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1


def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider:

    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

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='sanity',
            handler_name=handler_name,
            src=tests_src,
            fork_name='phase0'
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("sanity", [
        create_provider('blocks', test_blocks, 'minimal'),
        create_provider('blocks', test_blocks, 'mainnet'),
        create_provider('slots', test_slots, 'minimal'),
        create_provider('slots', test_slots, 'mainnet'),
    ])
Exemplo n.º 8
0
                                   fork_name='phase0')

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator(
        "epoch_processing",
        [
            create_provider('final_updates', test_process_final_updates,
                            'minimal'),
            create_provider('final_updates', test_process_final_updates,
                            'mainnet'),
            create_provider('justification_and_finalization',
                            test_process_justification_and_finalization,
                            'minimal'),
            create_provider('justification_and_finalization',
                            test_process_justification_and_finalization,
                            'mainnet'),
            create_provider('registry_updates', test_process_registry_updates,
                            'minimal'),
            create_provider('registry_updates', test_process_registry_updates,
                            'mainnet'),
            create_provider('rewards_and_penalties',
                            test_process_rewards_and_penalties, 'minimal'),
            # runs full epochs filled with data, with uncached ssz. Disabled for now.
            # create_provider('rewards_and_penalties', test_process_rewards_and_penalties, 'mainnet'),
            create_provider('slashings', test_process_slashings, 'minimal'),
            create_provider('slashings', test_process_slashings, 'mainnet'),
        ])
Exemplo n.º 9
0
                title="UInt Wrong Length",
                summary="Serialized integers that are too short or too long",
                forks_timeline="mainnet",
                forks=["phase0"],
                config="mainnet",
                runner="ssz",
                handler="uint",
                test_cases=generate_uint_wrong_length_test_cases()))


def ssz_uint_bounds_suite(configs_path: str) -> gen_typing.TestSuiteOutput:
    return (
        "uint_bounds", "uint",
        gen_suite.render_suite(
            title="UInt Bounds",
            summary=
            "Integers right at or beyond the bounds of the allowed value range",
            forks_timeline="mainnet",
            forks=["phase0"],
            config="mainnet",
            runner="ssz",
            handler="uint",
            test_cases=generate_uint_bounds_test_cases() +
            generate_uint_out_of_bounds_test_cases()))


if __name__ == "__main__":
    gen_runner.run_generator(
        "ssz_generic",
        [ssz_random_uint_suite, ssz_wrong_uint_suite, ssz_uint_bounds_suite])
Exemplo n.º 10
0

def create_provider(tests_src, config_name: str) -> gen_typing.TestProvider:
    def prepare_fn(configs_path: str) -> str:
        config_util.prepare_config(configs_path, config_name)
        reload(spec_phase0)
        reload(spec_phase1)
        bls.use_milagro()
        return config_name

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='rewards',
            handler_name='core',
            src=tests_src,
            fork_name=PHASE0,
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("rewards", [
        create_provider(test_basic, 'minimal'),
        create_provider(test_basic, 'mainnet'),
        create_provider(test_leak, 'minimal'),
        create_provider(test_leak, 'mainnet'),
        create_provider(test_random, 'minimal'),
        create_provider(test_random, 'mainnet'),
    ])
Exemplo n.º 11
0
        presets = loader.load_presets(configs_path, config_name)
        spec.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()))

    return suite_definition


if __name__ == "__main__":
    gen_runner.run_generator("sanity", [
        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)),
    ])
Exemplo n.º 12
0
            'slots',
        ]
    }
    phase_1_mods = {
        **{
            key: 'eth2spec.test.phase1.sanity.test_' + key
            for key in [
                'blocks',  # more phase 1 specific block tests
                'shard_blocks',
            ]
        },
        **phase_0_mods
    }  # also run the previous phase 0 tests (but against phase 1 spec)

    gen_runner.run_generator(f"sanity", [
        create_provider(PHASE0, key, mod_name, 'minimal')
        for key, mod_name in phase_0_mods.items()
    ])
    gen_runner.run_generator(f"sanity", [
        create_provider(PHASE0, key, mod_name, 'mainnet')
        for key, mod_name in phase_0_mods.items()
    ])
    gen_runner.run_generator(f"sanity", [
        create_provider(PHASE1, key, mod_name, 'minimal')
        for key, mod_name in phase_1_mods.items()
    ])
    gen_runner.run_generator(f"sanity", [
        create_provider(PHASE1, key, mod_name, 'mainnet')
        for key, mod_name in phase_1_mods.items()
    ])
Exemplo n.º 13
0
        return "general"

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        for (case_name, case_fn) in case_maker():
            yield gen_typing.TestCase(fork_name=PHASE0,
                                      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)


if __name__ == "__main__":
    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),
        create_provider("containers", "valid", ssz_container.valid_cases),
        create_provider("containers", "invalid", ssz_container.invalid_cases),
    ])
Exemplo n.º 14
0
        # Nothing to load / change in spec. Maybe in future forks.
        # Put the tests into the general config category, to not require any particular configuration.
        return 'general'

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        for data in test_case_fn():
            print(data)
            (case_name, case_content) = data
            yield gen_typing.TestCase(
                fork_name='phase0',
                runner_name='bls',
                handler_name=handler_name,
                suite_name='small',
                case_name=case_name,
                case_fn=lambda: [('data', 'data', case_content)])

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("bls", [
        create_provider('msg_hash_uncompressed',
                        case01_message_hash_G2_uncompressed),
        create_provider('msg_hash_compressed',
                        case02_message_hash_G2_compressed),
        create_provider('priv_to_pub', case03_private_to_public_key),
        create_provider('sign_msg', case04_sign_messages),
        create_provider('aggregate_sigs', case06_aggregate_sigs),
        create_provider('aggregate_pubkeys', case07_aggregate_pubkeys),
    ])
Exemplo n.º 15
0
    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='operations',
            handler_name=handler_name,
            src=tests_src,
            fork_name='phase0'
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("operations", [
        create_provider('attestation', test_process_attestation, 'minimal'),
        create_provider('attestation', test_process_attestation, 'mainnet'),
        create_provider('attester_slashing', test_process_attester_slashing, 'minimal'),
        create_provider('attester_slashing', test_process_attester_slashing, 'mainnet'),
        create_provider('block_header', test_process_block_header, 'minimal'),
        create_provider('block_header', test_process_block_header, 'mainnet'),
        create_provider('deposit', test_process_deposit, 'minimal'),
        create_provider('deposit', test_process_deposit, 'mainnet'),
        create_provider('proposer_slashing', test_process_proposer_slashing, 'minimal'),
        create_provider('proposer_slashing', test_process_proposer_slashing, 'mainnet'),
        create_provider('transfer', test_process_transfer, 'minimal'),
        # Disabled, due to the high amount of different transfer tests, this produces a shocking size of tests.
        # Unnecessarily, as transfer are disabled currently, so not a priority.
        # create_provider('transfer', test_process_transfer, 'mainnet'),
        create_provider('voluntary_exit', test_process_voluntary_exit, 'minimal'),
        create_provider('voluntary_exit', test_process_voluntary_exit, 'mainnet'),
    ])
Exemplo n.º 16
0
        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()))

    return suite_definition


if __name__ == "__main__":
    gen_runner.run_generator("epoch_processing", [
        create_suite(
            'crosslinks', 'minimal',
            lambda: generate_from_tests(test_process_crosslinks, 'phase0')),
        create_suite(
            'crosslinks', 'mainnet',
            lambda: generate_from_tests(test_process_crosslinks, 'phase0')),
        create_suite(
            'registry_updates', 'minimal', lambda: generate_from_tests(
                test_process_registry_updates, 'phase0')),
        create_suite(
            'registry_updates', 'mainnet', lambda: generate_from_tests(
                test_process_registry_updates, 'phase0')),
    ])
Exemplo n.º 17
0
        summary="BLS Aggregate signatures",
        forks_timeline="mainnet",
        forks=["phase0"],
        config="mainnet",
        runner="bls",
        handler="aggregate_sigs",
        test_cases=case06_aggregate_sigs()))


def bls_aggregate_pubkeys_suite(configs_path: str) -> gen_typing.TestSuiteOutput:
    return ("aggregate_pubkeys", "aggregate_pubkeys", gen_suite.render_suite(
        title="BLS aggregate pubkeys",
        summary="BLS Aggregate public keys",
        forks_timeline="mainnet",
        forks=["phase0"],
        config="mainnet",
        runner="bls",
        handler="aggregate_pubkeys",
        test_cases=case07_aggregate_pubkeys()))


if __name__ == "__main__":
    gen_runner.run_generator("bls", [
        bls_msg_hash_compressed_suite,
        bls_msg_hash_uncompressed_suite,
        bls_priv_to_pub_suite,
        bls_sign_msg_suite,
        bls_aggregate_sigs_suite,
        bls_aggregate_pubkeys_suite
    ])
Exemplo n.º 18
0
def create_suite(handler_name: str, config_name: str, get_cases: Callable[[], Iterable[gen_typing.TestCase]]) \
        -> 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)

        return (
            "genesis_%s_%s" % (handler_name, config_name), handler_name,
            gen_suite.render_suite(
                title="genesis testing",
                summary="Genesis test suite, %s type, generated from pytests" %
                handler_name,
                forks_timeline="testing",
                forks=["phase0"],
                config=config_name,
                runner="genesis",
                handler=handler_name,
                test_cases=get_cases()))

    return suite_definition


if __name__ == "__main__":
    gen_runner.run_generator("genesis", [
        create_suite(
            'initialization', 'minimal',
            lambda: generate_from_tests(test_initialization, 'phase0')),
        create_suite('validity', 'minimal',
                     lambda: generate_from_tests(test_validity, 'phase0')),
    ])
Exemplo n.º 19
0
from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests
from eth2spec.phase0 import spec as spec
from importlib import reload
from eth2spec.config import config_util


def create_provider(handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider:

    def prepare_fn(configs_path: str) -> str:
        config_util.prepare_config(configs_path, config_name)
        reload(spec)
        return config_name

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='genesis',
            handler_name=handler_name,
            src=tests_src,
            fork_name=PHASE0,
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("genesis", [
        create_provider('initialization', test_initialization, 'minimal'),
        create_provider('validity', test_validity, 'minimal'),
    ])
Exemplo n.º 20
0
            "Swap or not shuffling, with minimally configured testing round-count",
            forks_timeline="testing",
            forks=["phase0"],
            config="minimal",
            runner="shuffling",
            handler="core",
            test_cases=shuffling_test_cases()))


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()))


if __name__ == "__main__":
    gen_runner.run_generator("shuffling",
                             [mini_shuffling_suite, full_shuffling_suite])
Exemplo n.º 21
0
    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(runner_name='operations',
                                   handler_name=handler_name,
                                   src=tests_src,
                                   fork_name='phase0')

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("operations", [
        create_provider('attestation', test_process_attestation, 'minimal'),
        create_provider('attestation', test_process_attestation, 'mainnet'),
        create_provider('attester_slashing', test_process_attester_slashing,
                        'minimal'),
        create_provider('attester_slashing', test_process_attester_slashing,
                        'mainnet'),
        create_provider('block_header', test_process_block_header, 'minimal'),
        create_provider('block_header', test_process_block_header, 'mainnet'),
        create_provider('deposit', test_process_deposit, 'minimal'),
        create_provider('deposit', test_process_deposit, 'mainnet'),
        create_provider('proposer_slashing', test_process_proposer_slashing,
                        'minimal'),
        create_provider('proposer_slashing', test_process_proposer_slashing,
                        'mainnet'),
        create_provider('voluntary_exit', test_process_voluntary_exit,
                        'minimal'),
        create_provider('voluntary_exit', test_process_voluntary_exit,
                        'mainnet'),
    ])
Exemplo n.º 22
0
from gen_base import gen_runner

from deposits import mini_deposits_suite, full_deposits_suite

if __name__ == "__main__":
    gen_runner.run_generator("operations",
                             [mini_deposits_suite, full_deposits_suite])
Exemplo n.º 23
0
        # Apply changes to presets, this affects some of the vector types.
        config_util.prepare_config(configs_path, config_name)
        reload(spec)
        return config_name

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        count = cases_if_random if chaos or mode.is_changing() else 1

        for (i, (name, ssz_type)) in enumerate(get_spec_ssz_types()):
            yield from ssz_static_cases(seed * 1000 + i, name, ssz_type, mode, chaos, count)

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    # [(seed, config name, randomization mode, chaos on/off, cases_if_random)]
    settings = []
    seed = 1
    for mode in random_value.RandomizationMode:
        settings.append((seed, "minimal", mode, False, 30))
        seed += 1
    settings.append((seed, "minimal", random_value.RandomizationMode.mode_random, True, 30))
    seed += 1
    settings.append((seed, "mainnet", random_value.RandomizationMode.mode_random, False, 5))
    seed += 1

    gen_runner.run_generator("ssz_static", [
        create_provider(config_name, seed, mode, chaos, cases_if_random)
        for (seed, config_name, mode, chaos, cases_if_random) in settings
    ])
Exemplo n.º 24
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

    def cases_fn() -> Iterable[gen_typing.TestCase]:
        return generate_from_tests(
            runner_name='epoch_processing',
            handler_name=handler_name,
            src=tests_src,
            fork_name='phase0'
        )

    return gen_typing.TestProvider(prepare=prepare_fn, make_cases=cases_fn)


if __name__ == "__main__":
    gen_runner.run_generator("epoch_processing", [
        create_provider('crosslinks', test_process_crosslinks, 'minimal'),
        create_provider('crosslinks', test_process_crosslinks, 'mainnet'),
        create_provider('final_updates', test_process_final_updates, 'minimal'),
        create_provider('final_updates', test_process_final_updates, 'mainnet'),
        create_provider('justification_and_finalization', test_process_justification_and_finalization, 'minimal'),
        create_provider('justification_and_finalization', test_process_justification_and_finalization, 'mainnet'),
        create_provider('registry_updates', test_process_registry_updates, 'minimal'),
        create_provider('registry_updates', test_process_registry_updates, 'mainnet'),
        create_provider('slashings', test_process_slashings, 'minimal'),
        create_provider('slashings', test_process_slashings, 'mainnet'),
    ])