Skip to content

Commit

Permalink
fix(unreleased): bug where evm-chains ecosystems overrode plugin ecos…
Browse files Browse the repository at this point in the history
…ystems. (#2382)
  • Loading branch information
antazoey authored Nov 21, 2024
1 parent 74c7746 commit 442ad01
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"packaging>=23.0,<24",
"pandas>=2.2.2,<3",
"pluggy>=1.3,<2",
"pydantic>=2.6.4,<3",
"pydantic>=2.6.4,<2.10",
"pydantic-settings>=2.5.2,<3",
"pytest>=8.0,<9.0",
"python-dateutil>=2.8.2,<3",
Expand Down
2 changes: 1 addition & 1 deletion src/ape/managers/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def ecosystems(self) -> dict[str, EcosystemAPI]:
)
plugin_ecosystems[ecosystem_name] = ecosystem_cls

return {**plugin_ecosystems, **self._evmchains_ecosystems}
return {**self._evmchains_ecosystems, **plugin_ecosystems}

@cached_property
def _plugin_ecosystems(self) -> dict[str, EcosystemAPI]:
Expand Down
32 changes: 32 additions & 0 deletions tests/functional/test_network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,38 @@ def test_getattr_custom_ecosystem(networks, custom_networks_config_dict, project
assert isinstance(actual, EcosystemAPI)


def test_getattr_plugin_ecosystem_same_as_evm_chains(mocker, networks):
"""
Simulated having a plugin ecosystem installed.
"""
optimismy = mocker.MagicMock()
networks._plugin_ecosystems["optimismy"] = optimismy
actual = networks.optimismy
del networks._plugin_ecosystems["optimismy"]
assert actual == optimismy


def test_getattr_evm_chains_ecosystem(networks):
"""
Show we can getattr evm-chains only ecosystems.
"""
actual = networks.moonbeam
assert actual.name == "moonbeam"


def test_getattr_plugin_ecosystem_same_name_as_evm_chains(mocker, networks):
"""
Show when an ecosystem is both in evm-chains and an installed plugin
that Ape prefers the installed plugin.
"""
moonbeam_plugin = mocker.MagicMock()
networks._plugin_ecosystems["moonbeam"] = moonbeam_plugin
actual = networks.moonbeam
del networks._plugin_ecosystems["moonbeam"]
assert actual == moonbeam_plugin
assert actual != networks._evmchains_ecosystems["moonbeam"]


@pytest.mark.parametrize("scheme", ("http", "https"))
def test_create_custom_provider_http(networks, scheme):
provider = networks.create_custom_provider(f"{scheme}://example.com")
Expand Down

0 comments on commit 442ad01

Please sign in to comment.