Move deposit contract rules to its own Makefile
This commit is contained in:
parent
d14fb52249
commit
223d7346f9
33
Makefile
33
Makefile
|
@ -8,10 +8,6 @@ ETH2SPEC_MODULE_DIR = $(PY_SPEC_DIR)/eth2spec
|
|||
TEST_REPORT_DIR = $(PY_SPEC_DIR)/test-reports
|
||||
TEST_VECTOR_DIR = ../consensus-spec-tests/tests
|
||||
GENERATOR_DIR = ./tests/generators
|
||||
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
|
||||
TEST_PRESET_TYPE ?= minimal
|
||||
# Collect a list of generator names
|
||||
|
@ -50,15 +46,8 @@ GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.t
|
|||
|
||||
SCRIPTS_DIR = ${CURRENT_DIR}/scripts
|
||||
|
||||
export DAPP_SKIP_BUILD:=1
|
||||
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
|
||||
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
|
||||
export DAPP_JSON:=build/combined.json
|
||||
|
||||
.PHONY: clean partial_clean all test citest lint generate_tests pyspec install_test open_cov \
|
||||
install_deposit_contract_tester test_deposit_contract install_deposit_contract_compiler \
|
||||
compile_deposit_contract test_compile_deposit_contract check_toc \
|
||||
detect_generator_incomplete detect_generator_error_log
|
||||
check_toc detect_generator_incomplete detect_generator_error_log
|
||||
|
||||
all: $(PY_SPEC_ALL_TARGETS)
|
||||
|
||||
|
@ -162,26 +151,6 @@ lint_generators: pyspec
|
|||
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
|
||||
flake8 --config $(LINTER_CONFIG_FILE)
|
||||
|
||||
compile_deposit_contract:
|
||||
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
|
||||
@git submodule update --recursive --init
|
||||
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi --combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout --overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) $(SOLIDITY_DEPOSIT_CONTRACT_DIR)/tests/deposit_contract.t.sol
|
||||
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
|
||||
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
|
||||
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
|
||||
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
|
||||
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
|
||||
|
||||
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; python3 -m pip install -r requirements.txt
|
||||
|
||||
test_deposit_contract_web3_tests:
|
||||
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
|
||||
python3 -m pytest .
|
||||
|
||||
# Runs a generator, identified by param 1
|
||||
define run_generator
|
||||
# Started!
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
SOLIDITY_FILE_NAME = deposit_contract.json
|
||||
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = deposit_contract.sol
|
||||
DEPOSIT_CONTRACT_TESTER_DIR = web3_tester
|
||||
|
||||
export DAPP_SKIP_BUILD:=1
|
||||
export DAPP_SRC:=$(CURDIR)
|
||||
export DAPP_LIB:=$(CURDIR)/lib
|
||||
export DAPP_JSON:=build/combined.json
|
||||
|
||||
all: \
|
||||
compile_deposit_contract \
|
||||
install_deposit_contract_web3_tester \
|
||||
test_deposit_contract_web3_tests
|
||||
|
||||
compile_deposit_contract:
|
||||
@git submodule update --recursive --init
|
||||
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi \
|
||||
--combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout \
|
||||
--overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) tests/deposit_contract.t.sol
|
||||
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
|
||||
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
|
||||
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
|
||||
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
|
||||
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
|
||||
|
||||
test_deposit_contract:
|
||||
@dapp test -v --fuzz-runs 5
|
||||
|
||||
install_deposit_contract_web3_tester:
|
||||
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
|
||||
python3 -m venv venv; \
|
||||
source venv/bin/activate; \
|
||||
python3 -m pip install -r requirements.txt
|
||||
|
||||
test_deposit_contract_web3_tests:
|
||||
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
|
||||
source venv/bin/activate; \
|
||||
python3 -m pytest .
|
||||
|
||||
clean:
|
||||
@git clean -fdx
|
|
@ -1,5 +1,5 @@
|
|||
eth-tester[py-evm]>=0.3.0b1,<0.4
|
||||
web3==5.4.0
|
||||
pytest==3.6.1
|
||||
eth-tester[py-evm]>=0.12.0b1
|
||||
web3>=6.11.0
|
||||
pytest>=4.4
|
||||
# The eth2spec
|
||||
../../
|
||||
|
|
|
@ -51,7 +51,7 @@ def registration_contract(w3, tester):
|
|||
abi=contract_abi,
|
||||
bytecode=contract_bytecode)
|
||||
tx_hash = registration.constructor().transact()
|
||||
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
|
||||
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
|
||||
registration_deployed = w3.eth.contract(
|
||||
address=tx_receipt.contractAddress,
|
||||
abi=contract_abi
|
||||
|
|
|
@ -2,7 +2,7 @@ from random import randint
|
|||
import pytest
|
||||
import eth_utils
|
||||
|
||||
from eth2spec.phase0.spec import DepositData
|
||||
from eth2spec.phase0.mainnet import DepositData
|
||||
from eth2spec.utils.ssz.ssz_typing import List
|
||||
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
||||
|
||||
|
@ -119,7 +119,7 @@ def test_deposit_inputs(registration_contract,
|
|||
|
||||
|
||||
def test_deposit_event_log(registration_contract, a0, w3):
|
||||
log_filter = registration_contract.events.DepositEvent.createFilter(
|
||||
log_filter = registration_contract.events.DepositEvent.create_filter(
|
||||
fromBlock='latest',
|
||||
)
|
||||
deposit_amount_list = [randint(MIN_DEPOSIT_AMOUNT, FULL_DEPOSIT_AMOUNT * 2) for _ in range(3)]
|
||||
|
@ -154,7 +154,7 @@ def test_deposit_event_log(registration_contract, a0, w3):
|
|||
|
||||
|
||||
def test_deposit_tree(registration_contract, w3, assert_tx_failed):
|
||||
log_filter = registration_contract.events.DepositEvent.createFilter(
|
||||
log_filter = registration_contract.events.DepositEvent.create_filter(
|
||||
fromBlock='latest',
|
||||
)
|
||||
|
||||
|
@ -178,7 +178,7 @@ def test_deposit_tree(registration_contract, w3, assert_tx_failed):
|
|||
tx_hash = registration_contract.functions.deposit(
|
||||
*deposit_input,
|
||||
).transact({"value": deposit_amount_list[i] * eth_utils.denoms.gwei})
|
||||
receipt = w3.eth.getTransactionReceipt(tx_hash)
|
||||
receipt = w3.eth.get_transaction_receipt(tx_hash)
|
||||
print("deposit transaction consumes %d gas" % receipt['gasUsed'])
|
||||
|
||||
logs = log_filter.get_new_entries()
|
||||
|
|
Loading…
Reference in New Issue