From faeacdd3dbf17b0e7e8ec57841168d83ab093d22 Mon Sep 17 00:00:00 2001 From: Andrew Chiaramonte Date: Mon, 28 Oct 2024 12:07:00 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20fuzz=20start=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/KSXVault.t.sol | 87 ++++++++++++++++++++++++++++++++++++++++ test/utils/Bootstrap.sol | 5 +++ test/utils/Constants.sol | 4 -- 3 files changed, 92 insertions(+), 4 deletions(-) diff --git a/test/KSXVault.t.sol b/test/KSXVault.t.sol index 3eb7414..73dc905 100644 --- a/test/KSXVault.t.sol +++ b/test/KSXVault.t.sol @@ -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 + ); + } + } diff --git a/test/utils/Bootstrap.sol b/test/utils/Bootstrap.sol index c2a9a20..6695e0b 100644 --- a/test/utils/Bootstrap.sol +++ b/test/utils/Bootstrap.sol @@ -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; diff --git a/test/utils/Constants.sol b/test/utils/Constants.sol index 3bda0fc..6c837b1 100644 --- a/test/utils/Constants.sol +++ b/test/utils/Constants.sol @@ -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;