Skip to content

Commit

Permalink
✅ fuzz start time
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Oct 28, 2024
1 parent a281e34 commit faeacdd
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 4 deletions.
87 changes: 87 additions & 0 deletions test/KSXVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,91 @@ contract KSXVaultAuctionTest is KSXVaultTest {
ksxVault.setEpochDuration(2 weeks);
}

/*//////////////////////////////////////////////////////////////
FUZZ START TIME
//////////////////////////////////////////////////////////////*/

function testFuzzStartTime_createAuction(uint128 startTime) public {
fuzzStartTime(startTime);
test_createAuction();
}

function testFuzzStartTime_createAuction_AuctionNotReady(uint128 startTime) public {
fuzzStartTime(startTime);
test_createAuction_AuctionNotReady();
}

function testFuzzStartTime_isAuctionReady(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady();
}

function testFuzzStartTime_isAuctionReady_before_start(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady_before_start();
}

function testFuzzStartTime_isAuctionReady_before_start_fuzz(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady_before_start_fuzz(startTime);
}

function testFuzzStartTime_isAuctionReady_next_week(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady_next_week();
}

function testFuzzStartTime_isAuctionReady_set_one_day(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady_set_one_day();
}

function testFuzzStartTime_isAuctionReady_set_one_day_then_4_weeks(uint128 startTime) public {
fuzzStartTime(startTime);
test_isAuctionReady_set_one_day_then_4_weeks();
}

function testFuzzStartTime_setEpochDuration(uint128 startTime) public {
fuzzStartTime(startTime);
test_setEpochDuration();
}

function testFuzzStartTime_setEpochDuration_Invalid(uint128 startTime) public {
fuzzStartTime(startTime);
test_setEpochDuration_Invalid();
}

function testFuzzStartTime_setEpochDuration_before_start(uint128 startTime) public {
fuzzStartTime(startTime);
test_setEpochDuration_before_start();
}

function testFuzzStartTime_setEpochDuration_fuzz(uint128 startTime, uint256 duration) public {
fuzzStartTime(startTime);
test_setEpochDuration_fuzz(duration);
}

function testFuzzStartTime_setEpochDuration_onlyOwner(uint128 startTime) public {
fuzzStartTime(startTime);
test_setEpochDuration_onlyOwner();
}

/*//////////////////////////////////////////////////////////////
HELPERS
//////////////////////////////////////////////////////////////*/

function fuzzStartTime(uint128 startTime) public {
DEFAULT_START_TIME = DEFAULT_START_TIME + startTime;
initializeLocal(
address(depositToken),
address(mockUSDC),
address(stakingRewards),
address(auctionFactory),
DECIMAL_OFFSET,
DEFAULT_START_TIME,
DEFAULT_EPOCH_DURATION,
DEFAULT_START_TIME
);
}

}
5 changes: 5 additions & 0 deletions test/utils/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ contract Bootstrap is Test, Constants {
// decimal offset
uint256 public decimalsOffset;

/// @dev DEFAULT_START_TIME has to be > MAX_EPOCH_DURATION
/// to avoid issues with the tests (underflow)
/// @dev this is not a constant so the tests can change it
uint256 internal DEFAULT_START_TIME = 6 weeks;

// deployed contracts
KSXVault internal ksxVault;

Expand Down
4 changes: 0 additions & 4 deletions test/utils/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ contract Constants {

uint256 internal constant TEST_VALUE = 100 ether;

/// @dev DEFAULT_START_TIME has to be > MAX_EPOCH_DURATION
/// to avoid issues with the tests (underflow)
uint256 internal constant DEFAULT_START_TIME = 6 weeks;

uint256 internal constant DEFAULT_EPOCH_DURATION = 1 weeks;

uint256 internal constant MIN_EPOCH_DURATION = 1 days;
Expand Down

0 comments on commit faeacdd

Please sign in to comment.