diff --git a/.circleci/config.yml b/.circleci/config.yml index a6931b17e..df415f2eb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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 @@ -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: @@ -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 diff --git a/Makefile b/Makefile index 52825a3eb..4f6a98be7 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 diff --git a/solidity_deposit_contract/web3_tester/tests/conftest.py b/solidity_deposit_contract/web3_tester/tests/conftest.py index c20501b11..57b5f6b7a 100644 --- a/solidity_deposit_contract/web3_tester/tests/conftest.py +++ b/solidity_deposit_contract/web3_tester/tests/conftest.py @@ -15,7 +15,7 @@ DIR = os.path.dirname(__file__) 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) diff --git a/solidity_deposit_contract/web3_tester/tests/test_deposit.py b/solidity_deposit_contract/web3_tester/tests/test_deposit.py index 5fa98e232..4b16446a1 100644 --- a/solidity_deposit_contract/web3_tester/tests/test_deposit.py +++ b/solidity_deposit_contract/web3_tester/tests/test_deposit.py @@ -6,7 +6,7 @@ from eth2spec.phase0.spec import DepositData 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, )