Skip to content

Commit

Permalink
test(pool-monitor): increase pool-monitor test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandr-masl committed Sep 15, 2024
1 parent c3d3fc6 commit e032f0c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/test/diamond/DiamondTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract TestDiamond is DiamondTestSetup {
}

function testHasMultipleFacets() public {
assertEq(facetAddressList.length, 19);
assertEq(facetAddressList.length, 20);
}

function testFacetsHaveCorrectSelectors() public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,72 @@ contract PoolLiquidityMonitorTest is DiamondTestSetup {

function setUp() public override {
super.setUp();

vm.prank(admin);
poolLiquidityMonitor.setDefenderRelayer(defenderRelayer);
}

function testUnauthorizedCheckLiquidity() public {
vm.prank(unauthorized);
vm.expectRevert("Not authorized: Only Defender Relayer allowed");
function testSetThresholdPercentage() public {
uint256 newThresholdPercentage = 30;

poolLiquidityMonitor.checkLiquidityVertex();
vm.prank(admin);
poolLiquidityMonitor.setThresholdPercentage(newThresholdPercentage);
}

function testUnauthorizedSetDefenderRelayer() public {
address newRelayer = address(0x789);
function testUnauthorizedSetThresholdPercentage() public {
uint256 newThresholdPercentage = 30;

vm.expectRevert("Manager: Caller is not admin");
poolLiquidityMonitor.setDefenderRelayer(newRelayer);
poolLiquidityMonitor.setThresholdPercentage(newThresholdPercentage);
}

function testSetDefenderRelayer() public {
address newRelayer = address(0x789);
function testDropLiquidityVertex() public {
vm.expectRevert("Insufficient liquidity");

vm.prank(admin);
poolLiquidityMonitor.setDefenderRelayer(newRelayer);
poolLiquidityMonitor.dropLiquidityVertex();
}

function testSetThresholdPercentage() public {
uint256 newThresholdPercentage = 30;
function testUnauthorizedDropLiquidityVertex() public {
vm.expectRevert("Manager: Caller is not admin");
poolLiquidityMonitor.dropLiquidityVertex();
}

function testTogglePaused() public {
vm.prank(admin);
poolLiquidityMonitor.setThresholdPercentage(newThresholdPercentage);
poolLiquidityMonitor.togglePaused();
}

function testDropLiquidityVertex() public {
function testUnauthorizedTogglePaused() public {
vm.expectRevert("Manager: Caller is not admin");
poolLiquidityMonitor.togglePaused();
}

function testUnauthorizedCheckLiquidity() public {
vm.prank(unauthorized);
vm.expectRevert("Not authorized: Only Defender Relayer allowed");

poolLiquidityMonitor.checkLiquidityVertex();
}

function testCheckLiquidity() public {
vm.expectRevert("Insufficient liquidity");

vm.prank(defenderRelayer);
poolLiquidityMonitor.checkLiquidityVertex();
}

function testSetDefenderRelayer() public {
address newRelayer = address(0x789);

vm.prank(admin);
poolLiquidityMonitor.dropLiquidityVertex();
poolLiquidityMonitor.setDefenderRelayer(newRelayer);
}

function testUnauthorizedSetDefenderRelayer() public {
address newRelayer = address(0x789);

vm.expectRevert("Manager: Caller is not admin");
poolLiquidityMonitor.setDefenderRelayer(newRelayer);
}
}

0 comments on commit e032f0c

Please sign in to comment.