Skip to content

Facing problem while writing the Test for "mintDsc()" in Stablecoins project. #137

Closed Answered by pacelliv
PsychoPunkSage asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @APrakash-913, if I checked everything correctly... the issue is the setup when you execute testMappingIsPopulatedByMintDsc.

Who is calling mintDsc in this test? With you current setup is not USER, it is in fact a default account from Anvil, and the test will fail because this account have no collateral in the contract, therefore it cannot mint DSC.

This test should pass if you start a new prank for USER to call dscMint:

function testMappingIsPopulatedByMintDsc() public depositedCollateral {
    //start a new prank
    vm.startPrank(USER);
    dscEngine.mintDsc(MINT_VALUE);
    vm.stopPrank();
    assertEq(MINT_VALUE, dsc.balanceOf(USER));
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PsychoPunkSage
Comment options

Answer selected by PsychoPunkSage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants