Skip to content

Commit

Permalink
Merge pull request vyperlang#129 from DanielSchiavini/anvil
Browse files Browse the repository at this point in the history
fix: disable prefetch for anvil tests
  • Loading branch information
charles-cooper committed Feb 2, 2024
2 parents 0057c14 + 62bd452 commit 3d977d3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
3 changes: 1 addition & 2 deletions boa/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import requests

from boa.environment import Address

SESSION = requests.Session()


def _fetch_etherscan(uri: str, api_key: str = None, **params) -> dict:
if api_key is not None:
params["apikey"] = api_key
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/fork/test_from_etherscan.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os

import pytest

import boa

crvusd = "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E"
voting_agent = "0xE478de485ad2fe566d49342Cbd03E49ed7DB3356"


@pytest.fixture(scope="module")
def api_key():
return os.environ.get("ETHERSCAN_API_KEY")
Expand All @@ -14,14 +16,14 @@ def api_key():
@pytest.fixture(scope="module")
def crvusd_contract(api_key):
contract = boa.from_etherscan(crvusd, name="crvUSD", api_key=api_key)

return contract


@pytest.fixture(scope="module")
def proxy_contract(api_key):
contract = boa.from_etherscan(voting_agent, name="VotingAgent", api_key=api_key)

return contract


Expand Down
5 changes: 5 additions & 0 deletions tests/integration/network/anvil/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def anvil_env(free_port):
break
except requests.exceptions.ConnectionError:
time.sleep(0.1)

# Anvil ignores the tracer argument, therefore returning invalid data.
# see https://github.com/foundry-rs/foundry/issues/6882
anvil_env._fork_try_prefetch_state = False

yield NetworkEnv(anvil_uri)
finally:
anvil.terminate()
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/network/anvil/test_network_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,21 @@ def test_raise_exception(simple_contract, t):
simple_contract.raise_exception(t)


# Prefetch is disabled currently since anvil doesn't support `prestateTracer`.
# This test will fail when anvil is fixed, so we can re-enable prefetching.
# Then, this test may be deleted. See fixture `anvil_env`
def test_debug_traceCall_tracer_ignored(simple_contract):
assert boa.env._fork_try_prefetch_state is False
assert simple_contract.totalSupply() == STARTING_SUPPLY

boa.env._fork_try_prefetch_state = True
try:
with pytest.raises(ValueError) as excinfo:
boa.loads(code, STARTING_SUPPLY)
expected = "when sending a str, it must be a hex string. Got: 'failed'"
assert expected == str(excinfo.value)
finally:
boa.env._fork_try_prefetch_state = False


# XXX: probably want to test deployment revert behavior

0 comments on commit 3d977d3

Please sign in to comment.