Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spectest decorator #1052

Merged
merged 25 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b24abd
implement spectest decorator, update attestation tests
protolambda May 5, 2019
a8d8da2
fix wording and improve encoding logic
protolambda May 6, 2019
dcedfc3
move out spec state test deco
protolambda May 6, 2019
7bbf9ed
update attestation testing
protolambda May 6, 2019
61c0ddb
update attester slashing testing
protolambda May 6, 2019
9ff5219
update block header testing
protolambda May 6, 2019
90a56e2
update deposit testing
protolambda May 6, 2019
802f271
clean import, update proposer slashing test
protolambda May 6, 2019
4820ac9
update transfer tests
protolambda May 6, 2019
922a30a
update voluntary exit tests
protolambda May 6, 2019
1722d58
updat epoch processing tests
protolambda May 6, 2019
89a2bd2
work on sanity tests
protolambda May 6, 2019
d2afed8
fix deposit testing generalization
protolambda May 6, 2019
e5a50bc
finish port of test_sanity to new format
djrtwo May 6, 2019
8e619f8
port finality tests to new format. still has excessive deepcopies
djrtwo May 6, 2019
683fe00
fix blocks
protolambda May 7, 2019
f9539ed
move tests, update operations test vector generation
protolambda May 8, 2019
d9baee2
move tests to standard pkg/test folder, enable conftest options with …
protolambda May 8, 2019
8570584
PR 1052 apply suggestions
protolambda May 9, 2019
3189cf0
new proposer slashing tests
protolambda May 11, 2019
a39623a
fix test tooling bug
protolambda May 11, 2019
b4be220
new attestation tests
protolambda May 11, 2019
17d057e
improve transfer testing
protolambda May 11, 2019
636a45a
voluntary exit test case: invalid index
protolambda May 11, 2019
680017f
voluntary exit test case: invalid, exit in future
protolambda May 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ install_test:
cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements-testing.txt;

test: $(PY_SPEC_ALL_TARGETS)
cd $(PY_SPEC_DIR); . venv/bin/activate; python -m pytest .
cd $(PY_SPEC_DIR); . venv/bin/activate; python -m pytest eth2spec

citest: $(PY_SPEC_ALL_TARGETS)
cd $(PY_SPEC_DIR); mkdir -p test-reports/eth2spec; . venv/bin/activate; python -m pytest --junitxml=test-reports/eth2spec/test_results.xml .
Expand Down
180 changes: 0 additions & 180 deletions test_generators/operations/deposits.py

This file was deleted.

44 changes: 0 additions & 44 deletions test_generators/operations/genesis.py

This file was deleted.

7 changes: 0 additions & 7 deletions test_generators/operations/keys.py

This file was deleted.

28 changes: 25 additions & 3 deletions test_generators/operations/main.py
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", [
protolambda marked this conversation as resolved.
Show resolved Hide resolved
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)),
])
3 changes: 1 addition & 2 deletions test_generators/operations/requirements.txt
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
39 changes: 39 additions & 0 deletions test_generators/operations/suite_creator.py
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
3 changes: 2 additions & 1 deletion test_libs/pyspec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ The `-B` flag may be helpful to force-overwrite the `pyspec` output after you ma

Run the tests:
```
pytest --config=minimal
pytest --config=minimal eth2spec
```
Note the package-name, this is to locate the tests.


## Contributing
Expand Down
Empty file.
Loading