Skip to content

Commit

Permalink
test(pool-monitor): increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandr-masl committed Sep 12, 2024
1 parent 32237f5 commit e691a20
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "../../helpers/LocalTestHelper.sol";
contract PoolLiquidityMonitorTest is LocalTestHelper {
PoolLiquidityMonitor monitor;
address defenderRelayer = address(0x456);
address unauthorized = address(0x123);

function setUp() public override {
super.setUp();
Expand All @@ -25,8 +26,54 @@ contract PoolLiquidityMonitorTest is LocalTestHelper {
function testSetDefenderRelayer() public {
address newRelayer = address(0x789);

vm.prank(monitor.owner());
monitor.setDefenderRelayer(newRelayer);

assertEq(monitor.defenderRelayer(), newRelayer);
}

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

monitor.checkLiquidity();
}

function testCheckLiquidity() public {
vm.prank(defenderRelayer);
monitor.checkLiquidity();
}

function testSetDefenderRelayerToZeroAddress() public {
vm.prank(owner);
vm.expectRevert();
monitor.setDefenderRelayer(address(0));
}

function testCheckLiquidityWithDifferentValues() public {
uint256 mockedLiquidityHigh = 10000;
uint256 mockedLiquidityLow = 100;

vm.mockCall(
address(ubiquityPoolFacet),
abi.encodeWithSelector(
UbiquityPoolFacet.collateralUsdBalance.selector
),
abi.encode(mockedLiquidityHigh)
);

vm.prank(defenderRelayer);
monitor.checkLiquidity();

vm.mockCall(
address(ubiquityPoolFacet),
abi.encodeWithSelector(
UbiquityPoolFacet.collateralUsdBalance.selector
),
abi.encode(mockedLiquidityLow)
);

vm.prank(defenderRelayer);
monitor.checkLiquidity();
}
}

0 comments on commit e691a20

Please sign in to comment.