Skip to content

Commit

Permalink
test: changePrank
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Oct 10, 2023
1 parent 7e03955 commit 59a425d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
17 changes: 9 additions & 8 deletions test/forge/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,24 @@ contract BaseTest is Test {

loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);

vm.startPrank(SUPPLIER);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
vm.stopPrank();
vm.startPrank(BORROWER);

changePrank(BORROWER);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
vm.stopPrank();
vm.startPrank(REPAYER);

changePrank(REPAYER);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
vm.stopPrank();
vm.startPrank(LIQUIDATOR);

changePrank(LIQUIDATOR);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
vm.stopPrank();
vm.startPrank(ONBEHALF);

changePrank(ONBEHALF);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
morpho.setAuthorization(BORROWER, true);
Expand Down
3 changes: 1 addition & 2 deletions test/forge/integration/BorrowIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ contract BorrowIntegrationTest is BaseTest {
vm.startPrank(supplier);
collateralToken.approve(address(morpho), amountCollateral);
morpho.supplyCollateral(marketParams, amountCollateral, supplier, hex"");
vm.stopPrank();

vm.prank(attacker);
changePrank(attacker);
vm.expectRevert(bytes(ErrorsLib.UNAUTHORIZED));
morpho.borrow(marketParams, amountBorrowed, 0, supplier, RECEIVER);
}
Expand Down
1 change: 0 additions & 1 deletion test/forge/integration/RepayIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ contract RepayIntegrationTest is BaseTest {
vm.stopPrank();

vm.prank(REPAYER);

vm.expectEmit(true, true, true, true, address(morpho));
emit EventsLib.Repay(id, REPAYER, ONBEHALF, amountRepaid, expectedRepaidShares);
(uint256 returnAssets, uint256 returnShares) = morpho.repay(marketParams, amountRepaid, 0, ONBEHALF, hex"");
Expand Down
3 changes: 1 addition & 2 deletions test/forge/libraries/periphery/MorphoStorageLibTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ contract MorphoStorageLibTest is BaseTest {
fee = bound(fee, 1, MAX_FEE);

// Set fee parameters.
vm.startPrank(OWNER);
vm.prank(OWNER);
morpho.setFee(marketParams, fee);
vm.stopPrank();

loanToken.setBalance(address(this), amountSupplied);
morpho.supply(marketParams, amountSupplied, 0, address(this), hex"");
Expand Down

0 comments on commit 59a425d

Please sign in to comment.