Skip to content

Lesson 12 Fuzz test depositCollateral #604

Answered by usmanfarooq91
Mepsss asked this question in Q&A
Discussion options

You must be logged in to vote

You are missing couple of things in Handler::depositCollateral function.

First, in order to deposit collateral, msg.sender have to have the deposit amount in the first place. to get it do collateral.mint(msg.sender, amountCollateral);.

Second, msg.sender needs to approve the amountCollateral to DSCEngine so that it can be transferred to DSCEngine, do it like this collateral.approve(address(dsce), amountCollateral);

Third you need to prank approve and depositCollateral functions with msg.sender, do it like this

vm.startPrank(msg.sender);
collateral.approve(address(dsce), amountCollateral);
dsce.depositCollateral(address(collateral), amountCollateral);
vm.stopPrank();

After all the changes…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Mepsss
Comment options

@usmanfarooq91
Comment options

@Mepsss
Comment options

@save-the-planet08
Comment options

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