fix config, work on py_tests
This commit is contained in:
parent
a106edacad
commit
ec4d41e15d
|
@ -9,3 +9,4 @@ build/
|
||||||
output/
|
output/
|
||||||
|
|
||||||
yaml_tests/
|
yaml_tests/
|
||||||
|
.pytest_cache
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -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.
|
||||||
|
|
|
@ -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 .
|
||||||
|
```
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue