Skip to content

Commit

Permalink
Merge pull request #655 from morpho-org/test/irm
Browse files Browse the repository at this point in the history
test(irm): dont fuzz irm
  • Loading branch information
Rubilmax authored Dec 19, 2023
2 parents fadc8a8 + c34a801 commit e1dc2e2
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions test/forge/integration/CreateMarketIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ contract CreateMarketIntegrationTest is BaseTest {
function testCreateMarketWithNotEnabledIrmAndEnabledLltv(MarketParams memory marketParamsFuzz) public {
vm.assume(!morpho.isIrmEnabled(marketParamsFuzz.irm));

marketParamsFuzz.lltv = _boundValidLltv(marketParamsFuzz.lltv);

vm.startPrank(OWNER);
if (!morpho.isLltvEnabled(marketParamsFuzz.lltv)) morpho.enableLltv(marketParamsFuzz.lltv);
vm.stopPrank();

vm.expectRevert(bytes(ErrorsLib.IRM_NOT_ENABLED));
vm.prank(OWNER);
morpho.createMarket(marketParamsFuzz);
Expand All @@ -43,18 +37,14 @@ contract CreateMarketIntegrationTest is BaseTest {
}

function testCreateMarketWithEnabledIrmAndLltv(MarketParams memory marketParamsFuzz) public {
marketParamsFuzz.irm = address(irm);
marketParamsFuzz.lltv = _boundValidLltv(marketParamsFuzz.lltv);
Id marketParamsFuzzId = marketParamsFuzz.id();

vm.startPrank(OWNER);
if (!morpho.isIrmEnabled(marketParamsFuzz.irm)) morpho.enableIrm(marketParamsFuzz.irm);
if (!morpho.isLltvEnabled(marketParamsFuzz.lltv)) morpho.enableLltv(marketParamsFuzz.lltv);
vm.stopPrank();

if (marketParamsFuzz.irm != address(0)) {
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
}

vm.expectEmit(true, true, true, true, address(morpho));
emit EventsLib.CreateMarket(marketParamsFuzz.id(), marketParamsFuzz);
vm.prank(OWNER);
Expand All @@ -69,17 +59,13 @@ contract CreateMarketIntegrationTest is BaseTest {
}

function testCreateMarketAlreadyCreated(MarketParams memory marketParamsFuzz) public {
marketParamsFuzz.irm = address(irm);
marketParamsFuzz.lltv = _boundValidLltv(marketParamsFuzz.lltv);

vm.startPrank(OWNER);
if (!morpho.isIrmEnabled(marketParamsFuzz.irm)) morpho.enableIrm(marketParamsFuzz.irm);
if (!morpho.isLltvEnabled(marketParamsFuzz.lltv)) morpho.enableLltv(marketParamsFuzz.lltv);
vm.stopPrank();

if (marketParamsFuzz.irm != address(0)) {
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
}

vm.prank(OWNER);
morpho.createMarket(marketParamsFuzz);

Expand All @@ -89,18 +75,14 @@ contract CreateMarketIntegrationTest is BaseTest {
}

function testIdToMarketParams(MarketParams memory marketParamsFuzz) public {
marketParamsFuzz.irm = address(irm);
marketParamsFuzz.lltv = _boundValidLltv(marketParamsFuzz.lltv);
Id marketParamsFuzzId = marketParamsFuzz.id();

vm.startPrank(OWNER);
if (!morpho.isIrmEnabled(marketParamsFuzz.irm)) morpho.enableIrm(marketParamsFuzz.irm);
if (!morpho.isLltvEnabled(marketParamsFuzz.lltv)) morpho.enableLltv(marketParamsFuzz.lltv);
vm.stopPrank();

if (marketParamsFuzz.irm != address(0)) {
vm.mockCall(marketParamsFuzz.irm, abi.encodeWithSelector(IIrm.borrowRate.selector), abi.encode(0));
}

vm.prank(OWNER);
morpho.createMarket(marketParamsFuzz);

Expand Down

0 comments on commit e1dc2e2

Please sign in to comment.