Error in Fuzz tests in stablecoin #2914
Replies: 2 comments 3 replies
-
Hello @heheboii11, There is nothing wrong with the Fuzzer calling [98750] Handler::Collateralredeem(219228 [2.192e5], 1164005204 [1.164e9])
├─ [2805] DSCEngine::getCollateralwithUser(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 0x0000000000000000068D95e41e85E7bC10fa45D1) [staticcall]
│ └─ ← [Return] 4262
├─ [0] console::log("Bound result", 1580) [staticcall]
│ └─ ← [Stop]
├─ [0] VM::startPrank(0x0000000000000000068D95e41e85E7bC10fa45D1)
│ └─ ← [Return]
├─ [80848] DSCEngine::redeemcollateral(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 1580)
│ ├─ emit CollateralRedeemed(from: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], to: 0x0000000000000000068D95e41e85E7bC10fa45D1, token: ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], amount: 1580)
│ ├─ [29805] ERC20Mock::transfer(0x0000000000000000068D95e41e85E7bC10fa45D1, 1580)
│ │ ├─ emit Transfer(from: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], to: 0x0000000000000000068D95e41e85E7bC10fa45D1, value: 1580)
│ │ └─ ← [Return] true
│ ├─ [8993] MockV3Aggregator::latestRoundData() [staticcall]
│ │ └─ ← [Return] 1, 200000000000 [2e11], 1, 1, 1
│ ├─ [8993] MockV3Aggregator::latestRoundData() [staticcall]
│ │ └─ ← [Return] 1, 100000000000 [1e11], 1, 1, 1
│ └─ ← [Revert] DSCEngine__HealthFactorIsLessThan(629282470165980877 [6.292e17])
└─ ← [Revert] DSCEngine__HealthFactorIsLessThan(629282470165980877 [6.292e17]) |
Beta Was this translation helpful? Give feedback.
-
your test is actually corrects based on the implementation i wonder how @PatrickAlphaC got away with that in the video. your trying to redeem collateral and haven't burn the dsc minted ?? or make sure implement the and note this line of code |
Beta Was this translation helpful? Give feedback.
-
This is my
Handler.t.sol
fileand while running the fuzz test with
fail_on_revert
true
, I am getting this errorAs far as I can see, in here it is getting reverted because of the
healthfactor
is getting broken as it is obvious because it is calling redeem collateral after depositing collateral and minting dsc and because of this the healthfactor is getting broken. Can anyone please help me to guide through this problem.Beta Was this translation helpful? Give feedback.
All reactions