Cyfrin / foundry-defi-stablecoin-cu

250 stars 117 forks source link

Update StopOnRevertHandler.t.sol #12

Closed touqeerShah closed 9 months ago

touqeerShah commented 1 year ago

redeemCollateral have problem in getCollateralBalanceOfUser function argument so it was never call that why it never give issue it define as user address then contract collateral address but pass swap of it so that why it never run and revert from if conditions

PatrickAlphaC commented 1 year ago

Ahhhh I See what you're doing here! Thank you!

So this is good, but we are just depositing and then withdrawing right away. I think a better play would be to only redeem collateral from users who have deposited. What do you think?

touqeerShah commented 1 year ago

Let suppose it call function randomly if it call redeemCollateral first without depositing it give following error that why I add deposit in the test

[FAIL. Reason: Arithmetic over/underflow]
[Sequence] sender=addr=[test/fuzz/failOnRevert/StopOnRevertHandler.t.sol:StopOnRevertHandler]calldata=mintAndDepositCollateral(uint256,uint256), 
args=[47409767332275032229872235448 [4.74e28], 23614243684831295026004535944408119379691892249249472724442933517775913615360 [2.361e76]]
PatrickAlphaC commented 1 year ago

Right, but we could improve this even more by keeping track of all the people who have deposited collateral, and then call redeem collateral with only people who have deposited.

PatrickAlphaC commented 1 year ago

In any case, I like your addition

PatrickAlphaC commented 9 months ago

Going to close as we are now pranking msg.sender to fix the issues here