From 70d1ee7f31c339519bc13f4895296eb6d0a1f3f8 Mon Sep 17 00:00:00 2001 From: doggie <3859395+fubuloubu@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:34:05 -0400 Subject: [PATCH] refactor: use asserts rather than excepiton for mock --- ape_safe/client/mock.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ape_safe/client/mock.py b/ape_safe/client/mock.py index 00cd155..a8b6862 100644 --- a/ape_safe/client/mock.py +++ b/ape_safe/client/mock.py @@ -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