Skip to content

Commit

Permalink
Clean up the CI workflow, enable web3.py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Aug 17, 2020
1 parent cd22036 commit 377b2e3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 92 deletions.
111 changes: 34 additions & 77 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,19 @@ commands:
venv_name: v22-pyspec
reqs_checksum: cache-{{ checksum "setup.py" }}
venv_path: ./venv
restore_deposit_contract_compiler_cached_venv:
description: "Restore the venv from cache for the deposit contract compiler"
steps:
- restore_cached_venv:
venv_name: v23-deposit-contract-compiler
reqs_checksum: cache-{{ checksum "deposit_contract/compiler/requirements.txt" }}
save_deposit_contract_compiler_cached_venv:
description: "Save the venv to cache for later use of the deposit contract compiler"
steps:
- save_cached_venv:
venv_name: v23-deposit-contract-compiler
reqs_checksum: cache-{{ checksum "deposit_contract/compiler/requirements.txt" }}
venv_path: ./deposit_contract/compiler/venv
restore_deposit_contract_tester_cached_venv:
description: "Restore the venv from cache for the deposit contract tester"
steps:
- restore_cached_venv:
venv_name: v22-deposit-contract-tester
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "deposit_contract/tester/requirements.txt" }}
venv_name: v23-deposit-contract-tester
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
save_deposit_contract_tester_cached_venv:
description: "Save the venv to cache for later use of the deposit contract tester"
steps:
- save_cached_venv:
venv_name: v22-deposit-contract-tester
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "deposit_contract/tester/requirements.txt" }}
venv_path: ./deposit_contract/tester/venv
venv_name: v23-deposit-contract-tester
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
venv_path: ./solidity_deposit_contract/web3_tester/venv
jobs:
checkout_specs:
docker:
Expand Down Expand Up @@ -145,53 +132,6 @@ jobs:
- run:
name: Run linter
command: make lint
# install_deposit_contract_compiler:
# docker:
# # The deposit contract compiler is pinned to python 3.7 because of the vyper version pin.
# - image: circleci/python:3.7
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_compiler_cached_venv
# - run:
# name: Install deposit contract compiler requirements
# command: make install_deposit_contract_compiler
# - save_deposit_contract_compiler_cached_venv
# install_deposit_contract_tester:
# docker:
# - image: circleci/python:3.8
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_tester_cached_venv
# - run:
# name: Install deposit contract tester requirements
# command: make install_deposit_contract_tester
# - save_deposit_contract_tester_cached_venv
# test_compile_deposit_contract:
# docker:
# - image: circleci/python:3.7
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_compiler_cached_venv
# - run:
# name: Run deposit contract compile test
# command: make test_compile_deposit_contract
# test_deposit_contract:
# docker:
# - image: circleci/python:3.8
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_tester_cached_venv
# - run:
# name: Run deposit contract test
# command: make test_deposit_contract
build_deposit_contract:
docker:
- image: ethereum/solc:0.6.11-alpine
Expand Down Expand Up @@ -234,6 +174,29 @@ jobs:
key: nix-store-test-v2
paths:
- /nix
install_deposit_contract_web3_tester:
docker:
- image: circleci/python:3.8
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_tester_cached_venv
- run:
name: Install deposit contract tester requirements
command: make install_deposit_contract_web3_tester
- save_deposit_contract_tester_cached_venv
test_deposit_contract_web3_tests:
docker:
- image: circleci/python:3.8
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_tester_cached_venv
- run:
name: Run deposit contract test with web3.py
command: make test_deposit_contract_web3_tests
workflows:
version: 2.1
test_spec:
Expand All @@ -250,18 +213,12 @@ workflows:
- lint:
requires:
- test
# - install_deposit_contract_compiler:
# requires:
# - checkout_specs
# - test_compile_deposit_contract:
# requires:
# - install_deposit_contract_compiler
# - install_deposit_contract_tester:
# requires:
# - checkout_specs
# - test_deposit_contract:
# requires:
# - install_deposit_contract_tester
- install_deposit_contract_web3_tester:
requires:
- checkout_specs
- test_deposit_contract_web3_tests:
requires:
- install_deposit_contract_web3_tester
build_and_test_deposit_contract:
jobs:
- build_deposit_contract
Expand Down
23 changes: 10 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
TEST_VECTOR_DIR = ../eth2.0-spec-tests/tests
GENERATOR_DIR = ./tests/generators
DEPOSIT_CONTRACT_COMPILER_DIR = ./deposit_contract/compiler
DEPOSIT_CONTRACT_TESTER_DIR = ./deposit_contract/tester
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
SOLIDITY_FILE_NAME = deposit_contract.json
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
CONFIGS_DIR = ./configs

# Collect a list of generator names
Expand Down Expand Up @@ -115,15 +115,6 @@ lint: pyspec
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1

# install_deposit_contract_tester:
# cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt

test_deposit_contract:
dapp test -v --fuzz-runs 5

# install_deposit_contract_compiler:
# cd $(DEPOSIT_CONTRACT_COMPILER_DIR); python3.7 -m venv venv; . venv/bin/activate; pip3.7 install -r requirements.txt

compile_deposit_contract:
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
@git submodule update --recursive --init
Expand All @@ -134,9 +125,15 @@ compile_deposit_contract:
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)

# test_compile_deposit_contract:
# cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
# python3.7 -m pytest .
test_deposit_contract:
dapp test -v --fuzz-runs 5

install_deposit_contract_web3_tester:
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt

test_deposit_contract_web3_tests:
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
python -m pytest .

# Runs a generator, identified by param 1
define run_generator
Expand Down
2 changes: 1 addition & 1 deletion solidity_deposit_contract/web3_tester/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def get_deposit_contract_json():
file_path = os.path.join(DIR, '../../contracts/validator_registration.json')
file_path = os.path.join(DIR, '../../deposit_contract.json')
deposit_contract_json = open(file_path).read()
return json.loads(deposit_contract_json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from eth2spec.utils.ssz.ssz_typing import List
from eth2spec.utils.ssz.ssz_impl import hash_tree_root

from deposit_contract.conftest import (
from tests.conftest import (
FULL_DEPOSIT_AMOUNT,
MIN_DEPOSIT_AMOUNT,
)
Expand Down

0 comments on commit 377b2e3

Please sign in to comment.