Update Makefile and CI config
1. Add `install_deposit_contract_test` command 2. Add `test_deposit_contract` command
This commit is contained in:
parent
09f7114b63
commit
b05444a92c
|
@ -64,7 +64,7 @@ jobs:
|
|||
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
|
||||
- run:
|
||||
name: Install pyspec requirements
|
||||
command: make install_test && make install_lint
|
||||
command: make install_test && make install_lint && make install_deposit_contract_test
|
||||
- save_cached_venv:
|
||||
venv_name: v1-pyspec-03
|
||||
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
|
||||
|
@ -97,6 +97,19 @@ jobs:
|
|||
- run:
|
||||
name: Run linter
|
||||
command: make lint
|
||||
deposit_contract:
|
||||
docker:
|
||||
- image: circleci/python:3.6
|
||||
working_directory: ~/specs-repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
|
||||
- restore_cached_venv:
|
||||
venv_name: v1-pyspec-03
|
||||
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
|
||||
- run:
|
||||
name: Run deposit contract test
|
||||
command: make test_deposit_contract
|
||||
workflows:
|
||||
version: 2.1
|
||||
test_spec:
|
||||
|
@ -111,3 +124,6 @@ workflows:
|
|||
- lint:
|
||||
requires:
|
||||
- test
|
||||
- deposit_contract:
|
||||
requires:
|
||||
- test
|
||||
|
|
10
Makefile
10
Makefile
|
@ -4,6 +4,7 @@ TEST_LIBS_DIR = ./test_libs
|
|||
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
|
||||
YAML_TEST_DIR = ./eth2.0-spec-tests/tests
|
||||
GENERATOR_DIR = ./test_generators
|
||||
DEPOSIT_CONTRACT_DIR = ./deposit_contract
|
||||
CONFIGS_DIR = ./configs
|
||||
|
||||
# Collect a list of generator names
|
||||
|
@ -46,6 +47,15 @@ lint: $(PY_SPEC_ALL_TARGETS)
|
|||
cd $(PY_SPEC_DIR); . venv/bin/activate; \
|
||||
flake8 --max-line-length=120 ./eth2spec;
|
||||
|
||||
install_deposit_contract_test:
|
||||
cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; \
|
||||
cd ../..; cd $(DEPOSIT_CONTRACT_DIR); \
|
||||
pip3 install -r requirements-testing.txt
|
||||
|
||||
test_deposit_contract:
|
||||
cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; \
|
||||
cd ../.. && cd $(DEPOSIT_CONTRACT_DIR) && python -m pytest .
|
||||
|
||||
# "make pyspec" to create the pyspec for all phases.
|
||||
pyspec: $(PY_SPEC_ALL_TARGETS)
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
pytest>=3.6,<3.7
|
||||
tox==3.0.0,
|
||||
eth-tester[py-evm]==0.1.0b29,
|
||||
vyper==0.1.0b9,
|
||||
web3==4.8.3,
|
||||
pytest==3.6.1,
|
||||
../../test_libs/pyspec
|
||||
tox==3.0.0
|
||||
eth-tester[py-evm]==0.1.0b29
|
||||
vyper==0.1.0b9
|
||||
web3==4.8.3
|
||||
pytest==3.6.1
|
||||
../test_libs/pyspec
|
||||
|
|
|
@ -5,10 +5,6 @@ import re
|
|||
|
||||
import pytest
|
||||
|
||||
from deposit_contract.contracts.utils import (
|
||||
get_deposit_contract_code,
|
||||
get_deposit_contract_json,
|
||||
)
|
||||
import eth_tester
|
||||
from eth_tester import (
|
||||
EthereumTester,
|
||||
|
@ -21,6 +17,11 @@ from web3 import Web3
|
|||
from web3.providers.eth_tester import (
|
||||
EthereumTesterProvider,
|
||||
)
|
||||
from .utils import (
|
||||
get_deposit_contract_code,
|
||||
get_deposit_contract_json,
|
||||
)
|
||||
|
||||
|
||||
# Constants
|
||||
MIN_DEPOSIT_AMOUNT = 1000000000 # Gwei
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from deposit_contract.contracts.utils import (
|
||||
get_deposit_contract_code,
|
||||
get_deposit_contract_json,
|
||||
)
|
||||
from vyper import (
|
||||
compiler,
|
||||
)
|
||||
|
||||
from .utils import (
|
||||
get_deposit_contract_code,
|
||||
get_deposit_contract_json,
|
||||
)
|
||||
|
||||
|
||||
def test_compile_deposit_contract():
|
||||
compiled_deposit_contract_json = get_deposit_contract_json()
|
||||
|
|
|
@ -13,22 +13,13 @@ from tests.contracts.conftest import (
|
|||
FULL_DEPOSIT_AMOUNT,
|
||||
MIN_DEPOSIT_AMOUNT,
|
||||
)
|
||||
from eth2spec.utils.minimal_ssz import
|
||||
from eth2spec.utils.minimal_ssz import (
|
||||
SSZType,
|
||||
hash_tree_root,
|
||||
)
|
||||
|
||||
|
||||
DepositData = SSZType({
|
||||
# BLS pubkey
|
||||
'pubkey': 'bytes48',
|
||||
# Withdrawal credentials
|
||||
'withdrawal_credentials': 'bytes32',
|
||||
# Amount in Gwei
|
||||
'amount': 'uint64',
|
||||
# Container self-signature
|
||||
'signature': 'bytes96',
|
||||
})
|
||||
from eth2spec.phase0.spec import (
|
||||
DepositData,
|
||||
)
|
||||
|
||||
|
||||
def hash(data):
|
||||
|
|
|
@ -5,12 +5,12 @@ DIR = os.path.dirname(__file__)
|
|||
|
||||
|
||||
def get_deposit_contract_code():
|
||||
file_path = os.path.join(DIR, './validator_registration.v.py')
|
||||
file_path = os.path.join(DIR, './../../contracts/validator_registration.v.py')
|
||||
deposit_contract_code = open(file_path).read()
|
||||
return deposit_contract_code
|
||||
|
||||
|
||||
def get_deposit_contract_json():
|
||||
file_path = os.path.join(DIR, './validator_registration.json')
|
||||
file_path = os.path.join(DIR, './../../contracts/validator_registration.json')
|
||||
deposit_contract_json = open(file_path).read()
|
||||
return json.loads(deposit_contract_json)
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
|
||||
def test_import():
|
||||
import deposit_contract # noqa: F401
|
Loading…
Reference in New Issue