Skip to content

Commit 145bf8b

Browse files
authored
Update DSCEngineTest.t.sol - testCanRedeemCollateral() (#114)
in the previous testCanRedeemCollateral() function it was being asserted that userBalance = amountCollateral `assertEq(userBalance, amountCollateral)` but that test is bound to fail because the `user` only had `amountCollateral = 10 ether` deposited as collateral and after calling the `dsce.redeemCollateral(weth, amountCollateral);` LOC there's not going to be any collateral left in the DSCEngine.
1 parent 40623f7 commit 145bf8b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/unit/DSCEngineTest.t.sol

+5-2
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,15 @@ contract DSCEngineTest is StdCheats, Test {
315315

316316
function testCanRedeemCollateral() public depositedCollateral {
317317
vm.startPrank(user);
318+
uint256 userBalanceBeforeRedeem = dsce.getCollateralBalanceOfUser(user, weth);
319+
assertEq(userBalanceBeforeRedeem, amountCollateral);
318320
dsce.redeemCollateral(weth, amountCollateral);
319-
uint256 userBalance = ERC20Mock(weth).balanceOf(user);
320-
assertEq(userBalance, amountCollateral);
321+
uint256 userBalanceAfterRedeem = dsce.getCollateralBalanceOfUser(user, weth);
322+
assertEq(userBalanceAfterRedeem, 0);
321323
vm.stopPrank();
322324
}
323325

326+
324327
function testEmitCollateralRedeemedWithCorrectArgs() public depositedCollateral {
325328
vm.expectEmit(true, true, true, true, address(dsce));
326329
emit CollateralRedeemed(user, user, weth, amountCollateral);

0 commit comments

Comments
 (0)