Test not reverting as expected #2433
Unanswered
PrashikshitSaini
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hello @PrashikshitSaini, your test is failing because the test process did not revert when you expected it to revert. retry your test with the below test and let's see if it will pass. function testDepositCollateralRevertsOnTransferFailed() public {
ERC20Mock(weth).mint(USER, AMOUNT_COLLATERAL); // added this later because realized that there is not token in the system. Hence had to mint some.
uint256 exceedingAmount = STARTING_ERC20_BALANCE + 1 ether;
vm.startPrank(USER);
ERC20Mock(weth).approve(address(dsce), STARTING_ERC20_BALANCE);
vm.expectRevert(DSCEngine.DSCEngine__TransferFailed.selector);
dsce.depositCollateral(weth, exceedingAmount);
vm.stopPrank();
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I am currently working on the DSC Engine tests and while writing a testing that gives out TransferFailed if not success, the test errors out with
[FAIL. Reason: call did not revert as expected]
:DSC Engine Deposit Collateral:
My Test Function:
The complete error:
Beta Was this translation helpful? Give feedback.
All reactions