Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set automine [APE-1173] #59

Merged
merged 3 commits into from
Jul 7, 2023
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
8 changes: 8 additions & 0 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ def _test_config(self) -> TestConfig:
def auto_mine(self) -> bool:
return self._make_request("anvil_getAutomine", [])

def __setattr__(self, attr: str, value: Any) -> None:
# NOTE: Need to do this until https://github.com/pydantic/pydantic/pull/2625 is figured out
if attr == "auto_mine":
self._make_request("anvil_setAutomine", [value])

else:
super().__setattr__(attr, value)

def connect(self):
"""
Start the foundry process and verify it's up and accepting connections.
Expand Down
6 changes: 5 additions & 1 deletion tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ def test_base_fee(connected_provider):
assert connected_provider.base_fee == 0


def test_automine(connected_provider):
def test_auto_mine(connected_provider):
assert connected_provider.auto_mine is True
connected_provider.auto_mine = False
assert connected_provider.auto_mine is False
connected_provider.auto_mine = True
assert connected_provider.auto_mine is True


Expand Down