Skip to content

Commit

Permalink
refactor: don't add extra conversion logic in mock
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jun 5, 2024
1 parent 70d1ee7 commit 88795ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions ape_safe/client/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ def delegator_for_delegate(self, delegate: AddressType) -> Optional[AddressType]
return None

def add_delegate(self, delegate: AddressType, label: str, delegator: AccountAPI):
delegate = self.conversion_manager.convert(delegate, AddressType)

if delegator.address not in self.safe_details.owners:
raise SafeClientException(f"'{delegator}' not a valid owner.")

Expand All @@ -158,8 +156,6 @@ def add_delegate(self, delegate: AddressType, label: str, delegator: AccountAPI)
self.delegates[delegator.address] = [delegate]

def remove_delegate(self, delegate: AddressType, delegator: AccountAPI):
delegate = self.conversion_manager.convert(delegate, AddressType)

if delegator.address not in self.safe_details.owners:
raise SafeClientException(f"'{delegator.address}' not a valid owner.")

Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def test_manage_delegates(safe, delegate, OWNERS):
owner = OWNERS[0]
assert owner.address not in safe.client.get_delegates()

safe.client.add_delegate(delegate, "pepito", owner)
safe.client.add_delegate(delegate.address, "pepito", owner)
assert delegate.address in safe.client.get_delegates()[owner.address]
assert delegate.address in safe.all_delegates()
# NOTE: Only in MockSafeClient
assert safe.client.delegator_for_delegate(delegate.address) == owner.address

safe.client.remove_delegate(delegate, owner)
safe.client.remove_delegate(delegate.address, owner)
assert owner.address not in safe.client.get_delegates()

with pytest.raises(SafeClientException):
Expand All @@ -32,7 +32,7 @@ def test_delegate_can_propose_safe_tx(safe, delegate, OWNERS):
# Not a delegate or signer
safe.propose_safe_tx(safe_tx, submitter=delegate)

safe.client.add_delegate(delegate, "pepito", owner)
safe.client.add_delegate(delegate.address, "pepito", owner)
safe.propose_safe_tx(safe_tx, submitter=delegate)

assert len(safe.get_api_confirmations(safe_tx)) == 0
Expand Down

0 comments on commit 88795ef

Please sign in to comment.