Closed smol-ninja closed 4 months ago
I want to mention that we should use bound over assume
Very useful reminder. Thank you.
I have replied to your feedback above. I will review the feedback PR once we have discussed the comments.
@andreivladbrg other than resolving conflicts, I added two new commits: https://github.com/sablier-labs/flow/pull/155/commits/21f1d6c94f8d07aa79d388b27ec6177c88b9a0c3 and https://github.com/sablier-labs/flow/pull/155/commits/7c99bd36d7d0f16e33eb9c7a84c31c9ef5f020a3.
The explanation for removing ratePerSecond = boundUint128(ratePerSecond, 1, UINT128_MAX - 1);
is that ratePerSecond
is already uint128
type so vm.assume(ratePerSecond > 0) is all we need.
lmk if all looks good.
The explanation for removing
ratePerSecond = boundUint128(ratePerSecond, 1, UINT128_MAX - 1);
is thatratePerSecond
is alreadyuint128
type so vm.assume(ratePerSecond > 0) is all we need.
why do you want to use assume
over bound
?
even if there is only one value (0) that can be fuzzed to not be in the specified range, i am still of the opinion we should not discard that test
once again pasting this here:
want to mention that we should use bound over assume. When using assume, the test is discarded if the condition is not met, resulting in fewer test runs and potentially slowing down the testing process. On the other hand, bound adjusts the values to fit within a specified range, ensuring the test still runs. This approach leads to a higher number of test executions and ultimately a more thoroughly tested environment. See here.
I now understand your point. I agree that we should not let it go waste even if its just a single test.
Reverted it back.
Linked issues
Additional changelog
Constants.sol
TRANSFER_VALUE
which is default value of 50,000. Used it to deriveTRANSFER_AMOUNT
for differentUtils.sol
bound
functions.Constants
so that I can defineUINT128_MAX
inConstants
and use it in `Utils.Base.t.sol
createAsset
, useful to create assets on the run.type(uint256).max
withUINT256_MAX
. I am usingUINT128_MAX
in fuzz to bound deposit amount so for consistency, I changed it here too.getDefaultAmountWithDecimals
- useful to calculate default transfer amount for a random asset. Useful in fuzz tests.Integration.t.sol
Use solidity >=0.8.22 everywhere. Let me know if its a problem.
I have only covered
create
anddeposit
in this PR because before proceeding further, I want both of us to agree with the proposed changes. Once this PR is merged, I will proceed with the remaining tests in a separate PR.This PR uses a different technique to write fuzz tests. For
deposit
function, to test all the possibilities, I have written a shared fuzz contract that creates some streams with all possible decimals and store them into fixture variables. Without fixtures and using the same approach as in lockup contracts, fuzz runs only test the initial deposit into the contract which imo is not sufficient. With this new approach, both initial deposits as well as subsequent deposits are tested.40% of the fuzz run would load input values from the fixtures. 60% would be random.