Skip to content

Commit 223d734

Browse files
committed
Move deposit contract rules to its own Makefile
1 parent d14fb52 commit 223d734

File tree

5 files changed

+50
-40
lines changed

5 files changed

+50
-40
lines changed

Makefile

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ ETH2SPEC_MODULE_DIR = $(PY_SPEC_DIR)/eth2spec
88
TEST_REPORT_DIR = $(PY_SPEC_DIR)/test-reports
99
TEST_VECTOR_DIR = ../consensus-spec-tests/tests
1010
GENERATOR_DIR = ./tests/generators
11-
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
12-
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
13-
SOLIDITY_FILE_NAME = deposit_contract.json
14-
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
1511
CONFIGS_DIR = ./configs
1612
TEST_PRESET_TYPE ?= minimal
1713
# Collect a list of generator names
@@ -50,15 +46,8 @@ GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.t
5046

5147
SCRIPTS_DIR = ${CURRENT_DIR}/scripts
5248

53-
export DAPP_SKIP_BUILD:=1
54-
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
55-
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
56-
export DAPP_JSON:=build/combined.json
57-
5849
.PHONY: clean partial_clean all test citest lint generate_tests pyspec install_test open_cov \
59-
install_deposit_contract_tester test_deposit_contract install_deposit_contract_compiler \
60-
compile_deposit_contract test_compile_deposit_contract check_toc \
61-
detect_generator_incomplete detect_generator_error_log
50+
check_toc detect_generator_incomplete detect_generator_error_log
6251

6352
all: $(PY_SPEC_ALL_TARGETS)
6453

@@ -162,26 +151,6 @@ lint_generators: pyspec
162151
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
163152
flake8 --config $(LINTER_CONFIG_FILE)
164153

165-
compile_deposit_contract:
166-
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
167-
@git submodule update --recursive --init
168-
@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
169-
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
170-
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
171-
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
172-
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
173-
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
174-
175-
test_deposit_contract:
176-
dapp test -v --fuzz-runs 5
177-
178-
install_deposit_contract_web3_tester:
179-
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; python3 -m pip install -r requirements.txt
180-
181-
test_deposit_contract_web3_tests:
182-
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
183-
python3 -m pytest .
184-
185154
# Runs a generator, identified by param 1
186155
define run_generator
187156
# Started!

solidity_deposit_contract/Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
SOLIDITY_FILE_NAME = deposit_contract.json
2+
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = deposit_contract.sol
3+
DEPOSIT_CONTRACT_TESTER_DIR = web3_tester
4+
5+
export DAPP_SKIP_BUILD:=1
6+
export DAPP_SRC:=$(CURDIR)
7+
export DAPP_LIB:=$(CURDIR)/lib
8+
export DAPP_JSON:=build/combined.json
9+
10+
all: \
11+
compile_deposit_contract \
12+
install_deposit_contract_web3_tester \
13+
test_deposit_contract_web3_tests
14+
15+
compile_deposit_contract:
16+
@git submodule update --recursive --init
17+
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi \
18+
--combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout \
19+
--overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) tests/deposit_contract.t.sol
20+
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
21+
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
22+
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
23+
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
24+
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
25+
26+
test_deposit_contract:
27+
@dapp test -v --fuzz-runs 5
28+
29+
install_deposit_contract_web3_tester:
30+
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
31+
python3 -m venv venv; \
32+
source venv/bin/activate; \
33+
python3 -m pip install -r requirements.txt
34+
35+
test_deposit_contract_web3_tests:
36+
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
37+
source venv/bin/activate; \
38+
python3 -m pytest .
39+
40+
clean:
41+
@git clean -fdx
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
eth-tester[py-evm]>=0.3.0b1,<0.4
2-
web3==5.4.0
3-
pytest==3.6.1
1+
eth-tester[py-evm]>=0.12.0b1
2+
web3>=6.11.0
3+
pytest>=4.4
44
# The eth2spec
55
../../

solidity_deposit_contract/web3_tester/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def registration_contract(w3, tester):
5151
abi=contract_abi,
5252
bytecode=contract_bytecode)
5353
tx_hash = registration.constructor().transact()
54-
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
54+
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
5555
registration_deployed = w3.eth.contract(
5656
address=tx_receipt.contractAddress,
5757
abi=contract_abi

solidity_deposit_contract/web3_tester/tests/test_deposit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
import eth_utils
44

5-
from eth2spec.phase0.spec import DepositData
5+
from eth2spec.phase0.mainnet import DepositData
66
from eth2spec.utils.ssz.ssz_typing import List
77
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
88

@@ -119,7 +119,7 @@ def test_deposit_inputs(registration_contract,
119119

120120

121121
def test_deposit_event_log(registration_contract, a0, w3):
122-
log_filter = registration_contract.events.DepositEvent.createFilter(
122+
log_filter = registration_contract.events.DepositEvent.create_filter(
123123
fromBlock='latest',
124124
)
125125
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):
154154

155155

156156
def test_deposit_tree(registration_contract, w3, assert_tx_failed):
157-
log_filter = registration_contract.events.DepositEvent.createFilter(
157+
log_filter = registration_contract.events.DepositEvent.create_filter(
158158
fromBlock='latest',
159159
)
160160

@@ -178,7 +178,7 @@ def test_deposit_tree(registration_contract, w3, assert_tx_failed):
178178
tx_hash = registration_contract.functions.deposit(
179179
*deposit_input,
180180
).transact({"value": deposit_amount_list[i] * eth_utils.denoms.gwei})
181-
receipt = w3.eth.getTransactionReceipt(tx_hash)
181+
receipt = w3.eth.get_transaction_receipt(tx_hash)
182182
print("deposit transaction consumes %d gas" % receipt['gasUsed'])
183183

184184
logs = log_filter.get_new_entries()

0 commit comments

Comments
 (0)