-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1052 from ethereum/spectest-deco
Spectest decorator
- Loading branch information
Showing
31 changed files
with
1,363 additions
and
1,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
from eth2spec.test.block_processing import ( | ||
test_process_attestation, | ||
test_process_attester_slashing, | ||
test_process_block_header, | ||
test_process_deposit, | ||
test_process_proposer_slashing, | ||
test_process_transfer, | ||
test_process_voluntary_exit | ||
) | ||
|
||
from gen_base import gen_runner | ||
|
||
from deposits import mini_deposits_suite, full_deposits_suite | ||
from suite_creator import generate_from_tests, create_suite | ||
|
||
if __name__ == "__main__": | ||
gen_runner.run_generator("operations", [ | ||
mini_deposits_suite, | ||
full_deposits_suite | ||
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)), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
eth-utils==1.4.1 | ||
../../test_libs/gen_helpers | ||
../../test_libs/config_helpers | ||
../../test_libs/pyspec | ||
py_ecc | ||
../../test_libs/pyspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from typing import Callable, Iterable | ||
from inspect import getmembers, isfunction | ||
from gen_base import gen_suite, gen_typing | ||
from preset_loader import loader | ||
from eth2spec.phase0 import spec | ||
|
||
|
||
def generate_from_tests(pkg): | ||
fn_names = [ | ||
name for (name, _) in getmembers(pkg, isfunction) | ||
if name.startswith('test_') | ||
] | ||
out = [] | ||
print("generating test vectors from tests package: %s" % pkg.__name__) | ||
for name in fn_names: | ||
tfn = getattr(pkg, name) | ||
try: | ||
out.append(tfn(generator_mode=True)) | ||
except AssertionError: | ||
print("ERROR: failed to generate vector from test: %s (pkg: %s)" % (name, pkg.__name__)) | ||
return out | ||
|
||
|
||
def create_suite(operation_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 ("%s_%s" % (operation_name, config_name), operation_name, gen_suite.render_suite( | ||
title="%s operation" % operation_name, | ||
summary="Test suite for %s type operation processing" % operation_name, | ||
forks_timeline="testing", | ||
forks=["phase0"], | ||
config=config_name, | ||
runner="operations", | ||
handler=config_name, | ||
test_cases=get_cases())) | ||
return suite_definition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
Oops, something went wrong.