Skip to content

Commit

Permalink
test: improve testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Oct 31, 2023
1 parent 60e588a commit 89a1fdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/libraries/ErrorsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library ErrorsLib {

/// @dev Thrown when the input is too small.
string internal constant INPUT_TOO_SMALL = "input too small";

/// @dev Thrown when passing the zero address.
string internal constant ZERO_ADDRESS = "zero address";

Expand Down
15 changes: 7 additions & 8 deletions test/SpeedJumpIrmTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract AdaptativeCurveIRMTest is Test {
uint256 internal constant CURVE_STEEPNESS = 4 ether;
uint256 internal constant ADJUSTMENT_SPEED = 50 ether / uint256(365 days);
uint256 internal constant TARGET_UTILIZATION = 0.8 ether;
uint256 internal constant INITIAL_BASE_RATE = uint128(0.01 ether) / uint128(365 days);
uint256 internal constant INITIAL_BASE_RATE = 0.01 ether / uint256(365 days);

AdaptativeCurveIRM internal irm;
MarketParams internal marketParams = MarketParams(address(0), address(0), address(0), address(0), 0);
Expand Down Expand Up @@ -59,11 +59,10 @@ contract AdaptativeCurveIRMTest is Test {
vm.assume(market.totalBorrowAssets > 0);
vm.assume(market.totalSupplyAssets >= market.totalBorrowAssets);

// TODO: fix this failing test
// Reason: Expected an emit, but the call reverted instead. Ensure you're testing the happy path when using the
// `expectEmit` cheatcode.
// vm.expectEmit(true, true, true, true, address(irm));
// emit BorrowRateUpdate(marketParams.id(), INITIAL_RATE, INITIAL_RATE);
vm.expectEmit(true, true, true, true, address(irm));
emit BorrowRateUpdate(
marketParams.id(), _curve(INITIAL_BASE_RATE, _err(market)), _expectedBaseRate(marketParams.id(), market)
);
irm.borrowRate(marketParams, market);
}

Expand Down Expand Up @@ -98,7 +97,7 @@ contract AdaptativeCurveIRMTest is Test {
assertApproxEqRel(irm.baseRate(marketParams.id()), expectedBaseRate, 0.001 ether, "baseRate");
}

function testBorrowRateJumpOnly(Market memory market0, Market memory market1) public {
function testBorrowRateNoTimeElapsed(Market memory market0, Market memory market1) public {
vm.assume(market0.totalBorrowAssets > 0);
vm.assume(market0.totalSupplyAssets >= market0.totalBorrowAssets);
irm.borrowRate(marketParams, market0);
Expand All @@ -118,7 +117,7 @@ contract AdaptativeCurveIRMTest is Test {
assertApproxEqRel(irm.baseRate(marketParams.id()), expectedBaseRate, 0.001 ether, "baseRate");
}

function testBorrowRateSpeedOnly(Market memory market0, Market memory market1) public {
function testBorrowRateNoUtilizationChange(Market memory market0, Market memory market1) public {
vm.assume(market0.totalBorrowAssets > 0);
vm.assume(market0.totalSupplyAssets >= market0.totalBorrowAssets);
irm.borrowRate(marketParams, market0);
Expand Down

0 comments on commit 89a1fdc

Please sign in to comment.