Skip to content

Commit

Permalink
refactor: use asserts rather than excepiton for mock
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jun 5, 2024
1 parent 2de253d commit 70d1ee7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ape_safe/client/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ 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 and not any(
# NOTE: Using `assert` because this client is only meant for mock testing purposes
assert len(safe_tx_data.confirmations) > 0
assert all(
self.delegator_for_delegate(signer) in owners
for signer in filter(lambda signer: signer not in owners, signatures)
):
raise SafeClientException("Not submitted by any valid signer or delegate.")
)

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 70d1ee7

Please sign in to comment.