Skip to content

Commit

Permalink
refactor: much simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 7, 2024
1 parent 3662242 commit 17c6120
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/ape/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from importlib_metadata import PackageNotFoundError, distributions, packages_distributions
from importlib_metadata import version as version_metadata
from packaging.specifiers import SpecifierSet
from requests import head
from tqdm.auto import tqdm # type: ignore

from ape.exceptions import APINotImplementedError, ProviderNotConnectedError
Expand Down
2 changes: 1 addition & 1 deletion src/ape_geth/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def uri(self) -> str:
if not uri or uri == DEFAULT_SETTINGS["uri"]:
# Do not override explicit configuration
if ecosystem in self.config:
# Shape of this is odd. Pydantic model containing dicts
# Shape of this is odd. Pydantic model containing dicts
if network_config := self.config[ecosystem].get(network):
if "uri" in network_config:
return network_config["uri"]
Expand Down
16 changes: 13 additions & 3 deletions tests/functional/geth/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
TransactionNotFoundError,
)
from ape_ethereum.ecosystem import Block
from ape_ethereum.provider import DEFAULT_SETTINGS
from ape_ethereum.transactions import (
AccessList,
AccessListTransaction,
TransactionStatusEnum,
TransactionType,
)
from ape_geth.provider import GethDevProcess, GethNotInstalledError, _RPCFactory
from ape_geth.provider import GethDevProcess, GethNotInstalledError
from tests.conftest import GETH_URI, geth_process_test


Expand All @@ -48,14 +49,23 @@ def test_uri_localhost_not_running_uses_random_default(config):


@geth_process_test
def test_uri_uses_value_from_config(geth_provider, temp_config):
def test_uri_when_configured(geth_provider, temp_config, ethereum):
settings = geth_provider.provider_settings
geth_provider.provider_settings = {}
value = "https://value/from/config"
config = {"geth": {"ethereum": {"local": {"uri": value}}}}
config = {"geth": {"ethereum": {"local": {"uri": value}, "mainnet": {"uri": value}}}}
try:
with temp_config(config):
# Assert we use the config value.
assert geth_provider.uri == value

# Assert provider settings takes precedence.
expected = DEFAULT_SETTINGS["uri"]
for name in ("local", "mainnet"):
network = ethereum.get_network(name)
provider = network.get_provider("geth", provider_settings={"uri": expected})
assert provider.uri == expected

finally:
geth_provider.provider_settings = settings

Expand Down

0 comments on commit 17c6120

Please sign in to comment.