Skip to content

Commit

Permalink
fix: use SafeClientException to mimic real environment
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jun 5, 2024
1 parent 07a512c commit eb59b34
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ape_safe/client/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ def post_transaction(
# Ensure that if this is a zero-conf SafeTx, that at least one signature is from a delegate
# NOTE: More strict than Safe API check that silently ignores if no signatures are valid or
# from delegates, but should help us to get correct logic for mock testing purposes
if len(safe_tx_data.confirmations) == 0:
# NOTE: Using `assert` because this client is only meant for mock testing purposes
assert any(
self.delegator_for_delegate(signer) in owners
for signer in filter(lambda signer: signer not in owners, signatures)
), "At least one signature must be from a valid owner of the safe"
if len(safe_tx_data.confirmations) == 0 and not any(
self.delegator_for_delegate(delegate) in owners
for delegate in filter(lambda signer: signer not in owners, signatures)
):
# NOTE: mimic real exception for mock testing purposes
raise SafeClientException(
"At least one signature must be from a valid owner of the safe"
)

tx_id = cast(SafeTxID, HexBytes(safe_tx_data.safe_tx_hash).hex())
self.transactions[tx_id] = safe_tx_data
Expand Down

0 comments on commit eb59b34

Please sign in to comment.