Skip to content

Commit

Permalink
feat: set automine [APE-1173] (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jul 7, 2023
1 parent 57b065a commit 61dfc38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 61dfc38

Please sign in to comment.