We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ python3.7 -m venv .venv $ source .venv/bin/activate $ cat requirements.txt vyper pytest web3 eth-tester py-evm $ pip install -r requirements.txt $ cat HelloWorld.json
{ "contractName": "HelloWorld", "abi": [ { "outputs": [], "inputs": [], "constant": false, "payable": false, "type": "constructor" }, { "name": "setGreeting", "outputs": [], "inputs": [ { "type": "bytes", "name": "x" } ], "constant": false, "payable": false, "type": "function", "gas": 70954 }, { "name": "greet", "outputs": [ { "type": "bytes", "name": "out" } ], "inputs": [], "constant": false, "payable": false, "type": "function", "gas": 4524 } ], "bytecode": "0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009857600080fd5b600b610140527f48656c6c6f20576f726c640000000000000000000000000000000000000000006101605261014080600060c052602060c020602082510161012060006002818352015b826101205160200211156100f557610117565b61012051602002850151610120518501555b81516001018083528114156100e2575b50505050505061033b56600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05263b8e46d3a600051141561013057602060046101403734156100b457600080fd5b60346004356004016101603760146004356004013511156100d457600080fd5b61016080600060c052602060c020602082510161012060006002818352015b8261012051602002111561010657610128565b61012051602002850151610120518501555b81516001018083528114156100f3575b505050505050005b63cfae3217600051141561021357341561014957600080fd5b60008060c052602060c020610180602082540161012060006002818352015b8261012051602002111561017b5761019d565b61012051850154610120516020028501525b8151600101808352811415610168575b5050505050506101805160206001820306601f82010390506101e0610180516014818352015b826101e05111156101d3576101ef565b60006101e0516101a001535b81516001018083528114156101c3575b5050506020610160526040610180510160206001820306601f8201039050610160f3005b60006000fd5b61012261033b0361012260003961012261033b036000f3", "compiler": { "name": "vyper", "version": "0.1.0b10" } }
$ cat test_greeter.py
from json import load from pathlib import Path import pytest from web3 import ( EthereumTesterProvider, Web3, ) @pytest.fixture def eth_tester(): return EthereumTesterProvider().ethereum_tester def contract(smart_contract_name, parameters=[], contract_directory=Path('.')): build_contracts_dir = contract_directory contract_json_file = (build_contracts_dir / smart_contract_name).with_suffix('.json') with open(contract_json_file, 'r') as smart_contract_build_file: json_object = load(smart_contract_build_file) bytecode = json_object["bytecode"] abi = json_object["abi"] w3 = Web3(EthereumTesterProvider()) contract = w3.eth.contract(abi=abi, bytecode=bytecode) tx_hash = contract.constructor(*parameters).transact() tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) contract = w3.eth.contract(abi=abi, address=tx_receipt.contractAddress) return contract def test_initial_greeting(): hello_world_contract = contract("HelloWorld") assert hello_world_contract.functions.greet().call() == b"Hello World"
$ py.test test_greeter.py
platform darwin -- Python 3.7.4, pytest-5.1.3, py-1.8.0, pluggy-0.13.0 rootdir: /Users/sarahconnor/bugweb3_v5 plugins: web3-5.1.0 collected 1 item test_greeter.py F [100%] ================================================================= FAILURES ================================================================= __________________________________________________________ test_initial_greeting ___________________________________________________________ def test_initial_greeting(): hello_world_contract = contract("HelloWorld") > assert hello_world_contract.functions.greet().call() == b"Hello World" test_greeter.py:33: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.7/site-packages/web3/contract.py:842: in call **self.kwargs .venv/lib/python3.7/site-packages/web3/contract.py:1346: in call_contract_function return_data = web3.eth.call(call_transaction, block_identifier=block_id) .venv/lib/python3.7/site-packages/eth_utils/functional.py:45: in inner return callback(fn(*args, **kwargs)) .venv/lib/python3.7/site-packages/web3/eth.py:347: in call [transaction, block_identifier], .venv/lib/python3.7/site-packages/web3/manager.py:94: in request_blocking response = self._make_request(method, params) .venv/lib/python3.7/site-packages/web3/manager.py:81: in _make_request return request_func(method, params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:50: in apply_formatters response = make_request(method, params) .venv/lib/python3.7/site-packages/web3/middleware/gas_price_strategy.py:18: in middleware return make_request(method, params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:48: in apply_formatters response = make_request(method, formatted_params) .venv/lib/python3.7/site-packages/web3/middleware/attrdict.py:18: in middleware response = make_request(method, params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:48: in apply_formatters response = make_request(method, formatted_params) .venv/lib/python3.7/site-packages/web3/middleware/normalize_errors.py:9: in middleware result = make_request(method, params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:48: in apply_formatters response = make_request(method, formatted_params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:48: in apply_formatters response = make_request(method, formatted_params) .venv/lib/python3.7/site-packages/web3/providers/eth_tester/middleware.py:300: in middleware return make_request(method, [filled_transaction] + params[1:]) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/middleware/formatting.py:48: in apply_formatters response = make_request(method, formatted_params) .venv/lib/python3.7/site-packages/web3/providers/eth_tester/main.py:68: in make_request response = delegator(self.ethereum_tester, params) cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? .venv/lib/python3.7/site-packages/web3/providers/eth_tester/defaults.py:36: in call_eth_tester return getattr(eth_tester, fn_name)(*fn_args, **fn_kwargs) .venv/lib/python3.7/site-packages/eth_tester/main.py:426: in call raw_result = self.backend.call(raw_transaction, raw_block_number) .venv/lib/python3.7/site-packages/eth_tester/backends/pyevm/main.py:495: in call block_number, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ chain = <eth_tester.backends.pyevm.main.setup_tester_chain.<locals>.MainnetTesterNoProofChain object at 0x103e7cc10> transaction = <eth.vm.forks.constantinople.transactions.ConstantinopleTransaction object at 0x103f26050>, block_number = 'latest' def _execute_and_revert_transaction(chain, transaction, block_number="latest"): vm = _get_vm_for_block_number(chain, block_number) state = vm.state snapshot = state.snapshot() > computation = state.execute_transaction(transaction) E AttributeError: 'ConstantinopleState' object has no attribute 'execute_transaction' .venv/lib/python3.7/site-packages/eth_tester/backends/pyevm/main.py:236: AttributeError ============================================================ 1 failed in 0.97s =============================================================
I don't know.
The text was updated successfully, but these errors were encountered:
I found the thing that caused this issue. The execute_transaction is removed in a commit in py-evm project: ethereum/py-evm@1992368#diff-2d5d99f4dd8df9b29c7486b27678f9fb
The replacement is apply_transaction method. Fixing this issue is easy. Creating test is a little bit confusing.
Sorry, something went wrong.
No branches or pull requests
What was wrong?
$ python3.7 -m venv .venv
$ source .venv/bin/activate
$ cat requirements.txt
vyper
pytest
web3
eth-tester
py-evm
$ pip install -r requirements.txt
$ cat HelloWorld.json
$ cat test_greeter.py
$ py.test test_greeter.py
How can it be fixed?
I don't know.
The text was updated successfully, but these errors were encountered: