Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,26 @@ def load_network_configs(cls, values):
@computed_field # type: ignore[misc]
@cached_property
def local(self) -> NetworkConfig:
return create_local_network_config(
default_config = create_local_network_config(
default_provider="test",
default_transaction_type=self.DEFAULT_TRANSACTION_TYPE,
gas_limit=self.DEFAULT_LOCAL_GAS_LIMIT,
)
configured_local: dict[str, Any] | NetworkConfig | None = PluginConfig.get(
self, LOCAL_NETWORK_NAME
)
if configured_local is None:
return default_config

if isinstance(configured_local, NetworkConfig):
configured_local = configured_local.model_dump(by_alias=True)

if not isinstance(configured_local, dict):
return default_config

return NetworkConfig.model_validate(
merge_configs(default_config.model_dump(by_alias=True), configured_local)
)

@only_raise_attribute_error
def __getattr__(self, key: str) -> Any:
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,17 @@ def test_ethereum_network_configs(config, project):
assert actual.sepolia.block_time == 15


def test_ethereum_local_network_config(config, project):
eth_config = {"ethereum": {"local": {"default_provider": "node"}}}
with project.temp_config(**eth_config):
actual = config.get_config("ethereum")
assert actual.local.default_provider == "node"

# Ensure that local-network defaults remain unaffected.
assert actual.local.gas_limit == "max"
assert actual.local.required_confirmations == 0


def test_network_gas_limit_default(config):
eth_config = config.get_config("ethereum")

Expand Down
Loading