diff --git a/test/forge/ERC4626Test.sol b/test/forge/ERC4626Test.sol index 5f82e3ca..ca4cf04b 100644 --- a/test/forge/ERC4626Test.sol +++ b/test/forge/ERC4626Test.sol @@ -228,9 +228,8 @@ contract ERC4626Test is BaseTest, IMorphoFlashLoanCallback { vm.startPrank(BORROWER); morpho.supplyCollateral(allMarkets[0], type(uint128).max, BORROWER, hex""); morpho.borrow(allMarkets[0], 1, 0, BORROWER, BORROWER); - vm.stopPrank(); - vm.prank(ONBEHALF); + changePrank(ONBEHALF); vm.expectRevert(ErrorsLib.WithdrawMorphoFailed.selector); vault.withdraw(assets, RECEIVER, ONBEHALF); } diff --git a/test/forge/GuardianTest.sol b/test/forge/GuardianTest.sol index a5ca1e60..4ad7264e 100644 --- a/test/forge/GuardianTest.sol +++ b/test/forge/GuardianTest.sol @@ -75,7 +75,7 @@ contract GuardianTest is BaseTest { function testRevokeGuardian(uint256 elapsed) public { elapsed = bound(elapsed, 0, TIMELOCK - 1); - address guardian = _addrFromHashedString("Guardian2"); + address guardian = makeAddr("Guardian2"); vm.prank(OWNER); vault.submitGuardian(guardian); diff --git a/test/forge/RoleTest.sol b/test/forge/RoleTest.sol index ccc6ac1c..c5a364b8 100644 --- a/test/forge/RoleTest.sol +++ b/test/forge/RoleTest.sol @@ -7,7 +7,7 @@ contract RoleTest is BaseTest { using MarketParamsLib for MarketParams; function testSetRiskManager() public { - address newRiskManager = _addrFromHashedString("RiskManager2"); + address newRiskManager = makeAddr("RiskManager2"); vm.prank(OWNER); vault.setRiskManager(newRiskManager); @@ -22,7 +22,7 @@ contract RoleTest is BaseTest { } function testSetAllocator() public { - address newAllocator = _addrFromHashedString("Allocator2"); + address newAllocator = makeAddr("Allocator2"); vm.prank(OWNER); vault.setIsAllocator(newAllocator, true); @@ -124,15 +124,13 @@ contract RoleTest is BaseTest { vault.setSupplyQueue(supplyQueue); vault.sortWithdrawQueue(withdrawQueueFromRanks); vault.reallocate(allocation, allocation); - vm.stopPrank(); - vm.startPrank(RISK_MANAGER); + changePrank(RISK_MANAGER); vault.setSupplyQueue(supplyQueue); vault.sortWithdrawQueue(withdrawQueueFromRanks); vault.reallocate(allocation, allocation); - vm.stopPrank(); - vm.startPrank(ALLOCATOR); + changePrank(ALLOCATOR); vault.setSupplyQueue(supplyQueue); vault.sortWithdrawQueue(withdrawQueueFromRanks); vault.reallocate(allocation, allocation); diff --git a/test/forge/TimelockTest.sol b/test/forge/TimelockTest.sol index 82425d9a..a7965052 100644 --- a/test/forge/TimelockTest.sol +++ b/test/forge/TimelockTest.sol @@ -261,7 +261,7 @@ contract TimelockTest is BaseTest { } function testSubmitGuardian() public { - address guardian = _addrFromHashedString("Guardian2"); + address guardian = makeAddr("Guardian2"); vm.prank(OWNER); vault.submitGuardian(guardian); @@ -301,7 +301,7 @@ contract TimelockTest is BaseTest { } function testAcceptGuardian() public { - address guardian = _addrFromHashedString("Guardian2"); + address guardian = makeAddr("Guardian2"); vm.prank(OWNER); vault.submitGuardian(guardian); @@ -326,7 +326,7 @@ contract TimelockTest is BaseTest { function testAcceptGuardianTimelockNotElapsed(uint256 elapsed) public { elapsed = bound(elapsed, 1, TIMELOCK - 1); - address guardian = _addrFromHashedString("Guardian2"); + address guardian = makeAddr("Guardian2"); vm.prank(OWNER); vault.submitGuardian(guardian); @@ -340,7 +340,7 @@ contract TimelockTest is BaseTest { function testAcceptGuardianTimelockExpirationExceeded(uint256 elapsed) public { elapsed = bound(elapsed, TIMELOCK + TIMELOCK_EXPIRATION + 1, type(uint64).max); - address guardian = _addrFromHashedString("Guardian2"); + address guardian = makeAddr("Guardian2"); vm.prank(OWNER); vault.submitGuardian(guardian); diff --git a/test/forge/helpers/BaseTest.sol b/test/forge/helpers/BaseTest.sol index 6303c261..b014de6f 100644 --- a/test/forge/helpers/BaseTest.sol +++ b/test/forge/helpers/BaseTest.sol @@ -59,18 +59,18 @@ contract BaseTest is Test { MarketParams[] internal allMarkets; function setUp() public virtual { - OWNER = _addrFromHashedString("Owner"); - SUPPLIER = _addrFromHashedString("Supplier"); - BORROWER = _addrFromHashedString("Borrower"); - REPAYER = _addrFromHashedString("Repayer"); - ONBEHALF = _addrFromHashedString("OnBehalf"); - RECEIVER = _addrFromHashedString("Receiver"); - ALLOCATOR = _addrFromHashedString("Allocator"); - RISK_MANAGER = _addrFromHashedString("RiskManager"); - GUARDIAN = _addrFromHashedString("Guardian"); - FEE_RECIPIENT = _addrFromHashedString("FeeRecipient"); - MORPHO_OWNER = _addrFromHashedString("MorphoOwner"); - MORPHO_FEE_RECIPIENT = _addrFromHashedString("MorphoFeeRecipient"); + OWNER = makeAddr("Owner"); + SUPPLIER = makeAddr("Supplier"); + BORROWER = makeAddr("Borrower"); + REPAYER = makeAddr("Repayer"); + ONBEHALF = makeAddr("OnBehalf"); + RECEIVER = makeAddr("Receiver"); + ALLOCATOR = makeAddr("Allocator"); + RISK_MANAGER = makeAddr("RiskManager"); + GUARDIAN = makeAddr("Guardian"); + FEE_RECIPIENT = makeAddr("FeeRecipient"); + MORPHO_OWNER = makeAddr("MorphoOwner"); + MORPHO_FEE_RECIPIENT = makeAddr("MorphoFeeRecipient"); morpho = IMorpho(_deploy("lib/morpho-blue/out/Morpho.sol/Morpho.json", abi.encode(MORPHO_OWNER))); vm.label(address(morpho), "Morpho"); @@ -93,11 +93,10 @@ contract BaseTest is Test { vm.startPrank(MORPHO_OWNER); morpho.enableIrm(address(irm)); morpho.setFeeRecipient(MORPHO_FEE_RECIPIENT); - vm.stopPrank(); vault = new MetaMorpho(OWNER, address(morpho), 0, address(loanToken), "MetaMorpho Vault", "MMV"); - vm.startPrank(OWNER); + changePrank(OWNER); vault.setRiskManager(RISK_MANAGER); vault.setIsAllocator(ALLOCATOR, true); vm.stopPrank(); @@ -143,11 +142,6 @@ contract BaseTest is Test { vm.stopPrank(); } - function _addrFromHashedString(string memory name) internal returns (address addr) { - addr = address(uint160(uint256(keccak256(bytes(name))))); - vm.label(addr, name); - } - /// @dev Rolls & warps the given number of blocks forward the blockchain. function _forward(uint256 blocks) internal { vm.roll(block.number + blocks);