Closed johnson2427 closed 2 years ago
Node and hardhat installed globally on Ubuntu 20.04
ape
$ ape --version # .0.1.0b4
$ ape plugins list
hardhat 0.1.0b3.dev1+g64bca80.d20220119
* Python Version: 3.8.10 * OS: Ubuntu 20.04 ### What went wrong? Please include information like: * ape test --network ::hardhat * ```python def test_snapshot_and_revert(hardhat_provider): snap = hardhat_provider.snapshot() assert snap == "1" block_1 = hardhat_provider._web3.eth.get_block("latest") hardhat_provider.mine() block_2 = hardhat_provider._web3.eth.get_block("latest") assert block_2.number > block_1.number assert block_1.hash != block_2.hash hardhat_provider.revert(snap) block_3 = hardhat_provider._web3.eth.get_block("latest") assert block_1.number == block_3.number assert block_1.hash == block_3.hash def test_set_timestamp(hardhat_provider): seconds = 5 pending_time_stamp = hardhat_provider.get_block("pending").timestamp time_1 = hardhat_provider.set_timestamp(seconds + pending_time_stamp) time_2 = hardhat_provider.set_timestamp(2 * seconds + pending_time_stamp) assert time_2 - time_1 == seconds
*
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-0.13.1 rootdir: /home/blake/ApeWorX/ape-hardhat, configfile: pyproject.toml, testpaths: tests plugins: eth-ape-0.1.0b4, cov-3.0.0, forked-1.4.0, web3-5.26.0, xdist-2.5.0, hypothesis-6.36.0 collected 16 items tests/test_hardhat.py ..........F..F.. [100%] ============================================================================================================== FAILURES =============================================================================================================== _________________________________________________________________________________________________________ test_set_timestamp __________________________________________________________________________________________________________ formatters = {'baseFeePerGas': <function apply_formatter_if at 0x7f850057c040>, 'difficulty': <function apply_formatter_if at 0x7f8...extraData': <function to_hexbytes at 0x7f84fbbb0af0>, 'gasLimit': <function apply_formatter_if at 0x7f850057c040>, ...} value = {'baseFeePerGas': '0x0', 'difficulty': '0x20000', 'extraData': '0x', 'gasLimit': '0x1c9c380', ...} @to_dict def apply_formatters_to_dict( formatters: Dict[Any, Any], value: Dict[Any, Any] ) -> Generator[Tuple[Any, Any], None, None]: for key, item in value.items(): if key in formatters: try: > yield key, formatters[key](item) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/eth_utils/applicators.py:84: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? cytoolz/functoolz.pyx:254: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? cytoolz/functoolz.pyx:250: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ num_bytes = 32, val = None, variable_length = False @curry def to_hexbytes( num_bytes: int, val: Union[str, int, bytes], variable_length: bool = False ) -> HexBytes: if isinstance(val, (str, int, bytes)): result = HexBytes(val) else: > raise TypeError("Cannot convert %r to HexBytes" % val) E TypeError: Cannot convert None to HexBytes ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/_utils/method_formatters.py:126: TypeError The above exception was the direct cause of the following exception: hardhat_provider = HardhatProvider(name='hardhat', network=NetworkAPI(name='development', ecosystem=Ethereum(name='ethereum', network_man...1, 1, 5], process_attempts=10, mainnet_fork=None), provider_settings={}, data_folder=PosixPath('.'), request_header='') def test_set_timestamp(hardhat_provider): seconds = 5 > pending_time_stamp = hardhat_provider.get_block("pending").timestamp tests/test_hardhat.py:99: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/ape/api/providers.py:734: in get_block block_data = self._web3.eth.get_block(block_id) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/eth.py:642: in get_block return self._get_block(block_identifier, full_transactions) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/module.py:57: in caller result = w3.manager.request_blocking(method_str, ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/manager.py:197: in request_blocking response = self._make_request(method, params) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/manager.py:150: in _make_request return request_func(method, params) cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__ ??? cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/middleware/formatting.py:76: in apply_formatters response = make_request(method, params) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/middleware/gas_price_strategy.py:90: in middleware return make_request(method, params) cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__ ??? cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/middleware/formatting.py:76: in apply_formatters response = make_request(method, params) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/middleware/attrdict.py:33: in middleware response = make_request(method, params) cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__ ??? cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/web3/middleware/formatting.py:83: in apply_formatters formatter(response["result"]), cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__ ??? cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/eth_utils/applicators.py:72: in apply_formatter_if return formatter(value) cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__ ??? cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__ ??? ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/eth_utils/functional.py:45: in inner return callback(fn(*args, **kwargs)) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ formatters = {'baseFeePerGas': <function apply_formatter_if at 0x7f850057c040>, 'difficulty': <function apply_formatter_if at 0x7f8...extraData': <function to_hexbytes at 0x7f84fbbb0af0>, 'gasLimit': <function apply_formatter_if at 0x7f850057c040>, ...} value = {'baseFeePerGas': '0x0', 'difficulty': '0x20000', 'extraData': '0x', 'gasLimit': '0x1c9c380', ...} @to_dict def apply_formatters_to_dict( formatters: Dict[Any, Any], value: Dict[Any, Any] ) -> Generator[Tuple[Any, Any], None, None]: for key, item in value.items(): if key in formatters: try: yield key, formatters[key](item) except ValueError as exc: new_error_message = "Could not format invalid value %r as field %r" % ( item, key, ) raise ValueError(new_error_message) from exc except TypeError as exc: new_error_message = ( "Could not format invalid type of %r for field %r" % (item, key) ) > raise TypeError(new_error_message) from exc E TypeError: Could not format invalid type of None for field 'mixHash' ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/eth_utils/applicators.py:95: TypeError -------------------------------------------------------------------------------------------------------- Captured stdout setup -------------------------------------------------------------------------------------------------------- INFO: Connecting to existing Hardhat node at port '8545'. --------------------------------------------------------------------------------------------------------- Captured log setup ---------------------------------------------------------------------------------------------------------- INFO ape:process.py:146 Connecting to existing Hardhat node at port '8545'. ______________________________________________________________________________________________________ test_snapshot_and_revert _______________________________________________________________________________________________________ hardhat_provider = HardhatProvider(name='hardhat', network=NetworkAPI(name='development', ecosystem=Ethereum(name='ethereum', network_man...1, 1, 5], process_attempts=10, mainnet_fork=None), provider_settings={}, data_folder=PosixPath('.'), request_header='') def test_snapshot_and_revert(hardhat_provider): snap = hardhat_provider.snapshot() > assert snap == "1" E AssertionError: assert '2' == '1' E - 1 E + 2 tests/test_hardhat.py:118: AssertionError -------------------------------------------------------------------------------------------------------- Captured stdout setup -------------------------------------------------------------------------------------------------------- INFO: Connecting to existing Hardhat node at port '8545'. --------------------------------------------------------------------------------------------------------- Captured log setup ---------------------------------------------------------------------------------------------------------- INFO ape:process.py:146 Connecting to existing Hardhat node at port '8545'. ========================================================================================================== warnings summary =========================================================================================================== ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_accounts self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_compile self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_console self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_ethereum self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_geth self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_networks self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_plugins self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_pm self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_run self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ape_test self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: ens self._mark_plugins_for_rewrite(hook) ../../.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114 /home/blake/.local/share/virtualenvs/ape-hardhat-_w4hTD5y/lib/python3.8/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: web3 self._mark_plugins_for_rewrite(hook) -- Docs: https://docs.pytest.org/en/stable/warnings.html ---------- coverage: platform linux, python 3.8.10-final-0 ----------- Name Stmts Miss Branch BrPart Cover ------------------------------------------------------------- ape_hardhat/__init__.py 10 10 0 0 0% ape_hardhat/exceptions.py 53 29 28 8 42% ape_hardhat/process.py 124 62 34 11 50% ape_hardhat/providers.py 176 117 52 8 34% ape_hardhat/version.py 2 2 0 0 0% ------------------------------------------------------------- TOTAL 365 220 114 27 40% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ======================================================================================================= short test summary info ======================================================================================================= FAILED tests/test_hardhat.py::test_set_timestamp - TypeError: Could not format invalid type of None for field 'mixHash' FAILED tests/test_hardhat.py::test_snapshot_and_revert - AssertionError: assert '2' == '1' ============================================================================================= 2 failed, 14 passed, 13 warnings in 28.70s ============================================================================================== INFO: Stopping Hardhat node. INFO: Stopping Hardhat node. INFO: Stopping Hardhat node. INFO: Stopping Hardhat node.
Fill this in if you have ideas on how the bug could be fixed.
This no longer stalls but instead an exception occurs. Resolved!
Environment information
Node and hardhat installed globally on Ubuntu 20.04
ape
and plugin versions:$ ape plugins list
Installed Plugins:
hardhat 0.1.0b3.dev1+g64bca80.d20220119
*
How can it be fixed?
Fill this in if you have ideas on how the bug could be fixed.