fix config, work on py_tests

This commit is contained in:
protolambda 2019-03-28 02:30:47 +08:00
parent a106edacad
commit ec4d41e15d
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
13 changed files with 54 additions and 30 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ build/
output/ output/
yaml_tests/ yaml_tests/
.pytest_cache

View File

@ -56,7 +56,7 @@ define build_yaml_tests
# Activate the venv, this is where dependencies are installed for the generator # Activate the venv, this is where dependencies are installed for the generator
. $(GENERATOR_VENVS_DIR)$(1)bin/activate . $(GENERATOR_VENVS_DIR)$(1)bin/activate
# Install all the necessary requirements # Install all the necessary requirements
pip3 install -r $(GENERATOR_DIR)$(1)requirements.txt --user pip3 install -r $(GENERATOR_DIR)$(1)requirements.txt
# Run the generator. The generator is assumed to have an "main.py" file. # Run the generator. The generator is assumed to have an "main.py" file.
# We output to the tests dir (generator program should accept a "-p <filepath>" argument. # We output to the tests dir (generator program should accept a "-p <filepath>" argument.

23
py_tests/README.md Normal file
View File

@ -0,0 +1,23 @@
# ETH 2.0 py-tests
These tests are not intended for client-consumption.
These tests are sanity tests, to verify if the spec itself is consistent.
There are ideas to port these tests to the YAML test suite,
but we are still looking for inputs on how this should work.
## How to run tests
From within the py_tests folder:
Install dependencies:
```bash
python3 -m venv venv
. py_tests/venv/bin/activate
pip3 install -r requirements.txt
```
Run the tests:
```
pytest -m minimal_config .
```

View File

@ -1,18 +1,17 @@
from copy import deepcopy from copy import deepcopy
import pytest import pytest
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.state_transition import ( from eth2.phase0.state_transition import (
state_transition, state_transition,
) )
from build.phase0.spec import ( from eth2.phase0.spec import (
ZERO_HASH,
get_current_epoch, get_current_epoch,
process_attestation, process_attestation,
slot_to_epoch, slot_to_epoch,
) )
from tests.phase0.helpers import ( from ..helpers import (
build_empty_block_for_next_slot, build_empty_block_for_next_slot,
get_valid_attestation, get_valid_attestation,
) )

View File

@ -2,13 +2,13 @@ from copy import deepcopy
import pytest import pytest
from build.phase0.spec import ( from eth2.phase0.spec import (
get_beacon_proposer_index, get_beacon_proposer_index,
cache_state, cache_state,
advance_slot, advance_slot,
process_block_header, process_block_header,
) )
from tests.phase0.helpers import ( from ..helpers import (
build_empty_block_for_next_slot, build_empty_block_for_next_slot,
) )

View File

@ -1,14 +1,14 @@
from copy import deepcopy from copy import deepcopy
import pytest import pytest
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.spec import ( from eth2.phase0.spec import (
get_balance, get_balance,
ZERO_HASH, ZERO_HASH,
process_deposit, process_deposit,
) )
from tests.phase0.helpers import ( from ..helpers import (
build_deposit, build_deposit,
privkeys, privkeys,
pubkeys, pubkeys,

View File

@ -1,13 +1,13 @@
from copy import deepcopy from copy import deepcopy
import pytest import pytest
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.spec import ( from eth2.phase0.spec import (
get_balance, get_balance,
get_current_epoch, get_current_epoch,
process_proposer_slashing, process_proposer_slashing,
) )
from tests.phase0.helpers import ( from ..helpers import (
get_valid_proposer_slashing, get_valid_proposer_slashing,
) )

View File

@ -1,14 +1,14 @@
from copy import deepcopy from copy import deepcopy
import pytest import pytest
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.spec import ( from eth2.phase0.spec import (
get_active_validator_indices, get_active_validator_indices,
get_current_epoch, get_current_epoch,
process_voluntary_exit, process_voluntary_exit,
) )
from tests.phase0.helpers import ( from ..helpers import (
build_voluntary_exit, build_voluntary_exit,
pubkey_to_privkey, pubkey_to_privkey,
) )

View File

@ -1,8 +1,8 @@
import pytest import pytest
from build.phase0 import spec from eth2.phase0 import spec
from tests.phase0.helpers import ( from .helpers import (
create_genesis_state, create_genesis_state,
) )

View File

@ -2,9 +2,9 @@ from copy import deepcopy
from py_ecc import bls from py_ecc import bls
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.utils.minimal_ssz import signed_root from eth2.utils.minimal_ssz import signed_root
from build.phase0.spec import ( from eth2.phase0.spec import (
# constants # constants
EMPTY_SIGNATURE, EMPTY_SIGNATURE,
ZERO_HASH, ZERO_HASH,
@ -31,7 +31,7 @@ from build.phase0.spec import (
verify_merkle_branch, verify_merkle_branch,
hash, hash,
) )
from build.phase0.utils.merkle_minimal import ( from eth2.utils.merkle_minimal import (
calc_merkle_tree_from_leaves, calc_merkle_tree_from_leaves,
get_merkle_proof, get_merkle_proof,
get_merkle_root, get_merkle_root,

View File

@ -3,10 +3,10 @@ from copy import deepcopy
import pytest import pytest
from py_ecc import bls from py_ecc import bls
import build.phase0.spec as spec import eth2.phase0.spec as spec
from build.phase0.utils.minimal_ssz import signed_root from eth2.utils.minimal_ssz import signed_root
from build.phase0.spec import ( from eth2.phase0.spec import (
# constants # constants
EMPTY_SIGNATURE, EMPTY_SIGNATURE,
ZERO_HASH, ZERO_HASH,
@ -27,15 +27,15 @@ from build.phase0.spec import (
verify_merkle_branch, verify_merkle_branch,
hash, hash,
) )
from build.phase0.state_transition import ( from eth2.phase0.state_transition import (
state_transition, state_transition,
) )
from build.phase0.utils.merkle_minimal import ( from eth2.utils.merkle_minimal import (
calc_merkle_tree_from_leaves, calc_merkle_tree_from_leaves,
get_merkle_proof, get_merkle_proof,
get_merkle_root, get_merkle_root,
) )
from tests.phase0.helpers import ( from .helpers import (
build_deposit_data, build_deposit_data,
build_empty_block_for_next_slot, build_empty_block_for_next_slot,
force_registry_change_at_next_epoch, force_registry_change_at_next_epoch,

View File

@ -4,3 +4,4 @@ oyaml==0.7
pycryptodome==3.7.3 pycryptodome==3.7.3
py_ecc>=1.6.0 py_ecc>=1.6.0
pytest>=3.6,<3.7 pytest>=3.6,<3.7
../pyspec

View File

@ -62,7 +62,7 @@ eth-utils==1.4.1
Install all the necessary requirements (re-run when you add more): Install all the necessary requirements (re-run when you add more):
```bash ```bash
pip3 install -r requirements.txt --user pip3 install -r requirements.txt
``` ```
And write your initial test generator, extending the base generator: And write your initial test generator, extending the base generator: