Skip to content

Commit

Permalink
fix(test): adapt test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Sep 20, 2023
1 parent 5070df2 commit 7e5a256
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
24 changes: 4 additions & 20 deletions test/forge/RoleTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ contract RoleTest is BaseTest {

vm.startPrank(caller);

vm.expectRevert("Ownable: caller is not the owner");
vault.submitTimelock(1);

vm.expectRevert("Ownable: caller is not the owner");
vault.acceptTimelock();

vm.expectRevert("Ownable: caller is not the owner");
vault.setRiskManager(caller);

vm.expectRevert("Ownable: caller is not the owner");
vault.setIsAllocator(caller, true);

vm.expectRevert("Ownable: caller is not the owner");
vault.submitTimelock(1);

vm.expectRevert("Ownable: caller is not the owner");
vault.submitFee(1);

vm.expectRevert("Ownable: caller is not the owner");
vault.acceptFee();
vault.submitGuardian(address(1));

vm.expectRevert("Ownable: caller is not the owner");
vault.setFeeRecipient(caller);
Expand All @@ -43,9 +40,6 @@ contract RoleTest is BaseTest {
vm.expectRevert(bytes(ErrorsLib.NOT_RISK_MANAGER));
vault.submitCap(allMarkets[0], CAP);

vm.expectRevert(bytes(ErrorsLib.NOT_RISK_MANAGER));
vault.acceptCap(allMarkets[0].id());

vm.stopPrank();
}

Expand Down Expand Up @@ -74,18 +68,8 @@ contract RoleTest is BaseTest {
vm.prank(OWNER);
vault.submitCap(allMarkets[0], CAP);

vm.warp(block.timestamp + vault.timelock());

vm.prank(OWNER);
vault.acceptCap(allMarkets[0].id());

vm.prank(RISK_MANAGER);
vault.submitCap(allMarkets[1], CAP);

vm.warp(block.timestamp + vault.timelock());

vm.prank(RISK_MANAGER);
vault.acceptCap(allMarkets[1].id());
}

function testAllocatorOrRiskManagerOrOwnerShouldTriggerAllocatorFunctions() public {
Expand Down
25 changes: 20 additions & 5 deletions test/forge/TimelockTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ contract TimelockTest is BaseTest {
assertEq(submittedAt, 0, "submittedAt");
}

function testAcceptTimelockNotOwner() public {
function testAcceptTimelockNoPendingValue() public {
vm.expectRevert(bytes(ErrorsLib.NO_PENDING_VALUE));
vault.acceptTimelock();
}

function testAcceptTimelockNotOwner(uint256 timelock) public {
timelock = bound(timelock, 0, TIMELOCK - 1);

vm.prank(OWNER);
vault.submitTimelock(timelock);

vm.warp(block.timestamp + TIMELOCK);

vm.expectRevert("Ownable: caller is not the owner");
vault.acceptTimelock();
}
Expand All @@ -95,12 +107,10 @@ contract TimelockTest is BaseTest {
vault.acceptTimelock();
}

function testAcceptTimelockExpirationExceeded(uint256 timelock, uint256 elapsed) public {
timelock = bound(timelock, 0, MAX_TIMELOCK);
function testAcceptTimelockDecreasedTimelockExpirationExceeded(uint256 timelock, uint256 elapsed) public {
timelock = bound(timelock, 0, TIMELOCK - 1);
elapsed = bound(elapsed, TIMELOCK + TIMELOCK_EXPIRATION + 1, type(uint64).max);

vm.assume(timelock != TIMELOCK);

vm.prank(OWNER);
vault.submitTimelock(timelock);

Expand Down Expand Up @@ -140,6 +150,11 @@ contract TimelockTest is BaseTest {
assertEq(Id.unwrap(vault.withdrawQueue(0)), Id.unwrap(id), "withdrawQueue");
}

function testAcceptCapNoPendingValue() public {
vm.expectRevert(bytes(ErrorsLib.NO_PENDING_VALUE));
vault.acceptCap(allMarkets[0].id());
}

function testAcceptCapTimelockNotElapsed(uint256 alpsed) public {
alpsed = bound(alpsed, 0, TIMELOCK - 1);

Expand Down

0 comments on commit 7e5a256

Please sign in to comment.