Skip to content

Commit

Permalink
Add test for applyTroveInterestPermissionless
Browse files Browse the repository at this point in the history
  • Loading branch information
RickGriff authored and bingen committed Mar 27, 2024
1 parent 4e18bed commit 2e111ce
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions contracts/src/test/interestRateBasic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,30 @@ contract InterestRateBasic is DevTestSetup {
assertEq(recordedTroveDebt_2, recordedTroveDebt_1 + accruedTroveInterest);
}

function testRevertApplyTroveInterestPermissionlessWhenTroveIsNotStale() public {
priceFeed.setPrice(2000e18);
uint256 troveDebtRequest = 2000e18;
uint256 interestRate = 25e16;

uint256 ATroveId = openTroveNoHints100pctMaxFee(A, 3 ether, troveDebtRequest, interestRate);

// No time passes. B tries to apply A's interest. expect revert
vm.startPrank(B);
vm.expectRevert();
borrowerOperations.applyTroveInterestPermissionless(ATroveId);
vm.stopPrank();

// Fast-forward time, but less than the staleness threshold
// TODO: replace "90 days" with troveManager.STALE_TROVE_DURATION() after conflicts are resolved
vm.warp(block.timestamp + 90 days - 1);

// B tries to apply A's interest. Expect revert
vm.startPrank(B);
vm.expectRevert();
borrowerOperations.applyTroveInterestPermissionless(ATroveId);
vm.stopPrank();
}

// --- withdrawETHGainToTrove tests ---

function testWithdrawETHGainToTroveSetsTroveLastDebtUpdateTimeToNow() public {
Expand Down

0 comments on commit 2e111ce

Please sign in to comment.