Replace assert
with if
condition in checkAndCalculateBrokerFee
#854
Replies: 3 comments 4 replies
-
Since the max fee is hard-coded to 10%, it is impossible to write a test that makes the This assertion is there on a precautionary basis - if there's an unknown bug, the assertion will stop contract execution. But since we don't know what bug there is, we cannot write a test for it. Given this rationale, I'd keep the assertion as is. P.S. See the discussion I opened on Twitter about production assertions: What are your thoughts on leaving asserts in production contracts? |
Beta Was this translation helpful? Give feedback.
-
On a separate note, this discussion makes me realize that it would be helpful to write a test that validates that |
Beta Was this translation helpful? Give feedback.
-
Closing it since no more discussion is required. |
Beta Was this translation helpful? Give feedback.
-
There is only one place where we still use
assert
check.v2-core/src/libraries/Helpers.sol
Line 42 in be1dea4
Integration tests also don't cover this scenario where broker fee exceeds total amount. This seems to be safe because we already have a check above it
v2-core/src/libraries/Helpers.sol
Lines 33 to 35 in be1dea4
However, since we are re-checking whether broker amount is less than total amount, we should also cover this in tests and replae it it with
if
.This will also increase branch coverage of Helpers.sol.
Would love to hear your thoughts on this @PaulRBerg.
Beta Was this translation helpful? Give feedback.
All reactions