Created
September 18, 2024 13:27
-
-
Save jordaniza/a06d360d90c3bdae918759f862f55917 to your computer and use it in GitHub Desktop.
Check When We start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.17; | |
import {Test, console2 as console} from "forge-std/Test.sol"; | |
import {Clock} from "src/clock/Clock.sol"; | |
contract TestWhenWeStart is Test { | |
Clock clock; | |
function setUp() public { | |
clock = new Clock(); | |
} | |
/** | |
* Python script cross checking: | |
* Current Unix Epoch Time: 1726663698 | |
* Number of seconds in a week: 604800 | |
* Number of seconds in an epoch (2 weeks): 1209600 | |
* Current Epoch Number (2-week periods since genesis): 1427 | |
* | |
* Epoch Schedule: | |
* Epoch ID Voting window starts Distribution window starts | |
* 1427 Thursday, 2024-09-12 00:00:00 UTC Thursday, 2024-09-19 00:00:00 UTC | |
* 1428 Thursday, 2024-09-26 00:00:00 UTC Thursday, 2024-10-03 00:00:00 UTC | |
* 1429 Thursday, 2024-10-10 00:00:00 UTC Thursday, 2024-10-17 00:00:00 UTC | |
* 1430 Thursday, 2024-10-24 00:00:00 UTC Thursday, 2024-10-31 00:00:00 UTC | |
* 1431 Thursday, 2024-11-07 00:00:00 UTC Thursday, 2024-11-14 00:00:00 UTC | |
* 1432 Thursday, 2024-11-21 00:00:00 UTC Thursday, 2024-11-28 00:00:00 UTC | |
* 1433 Thursday, 2024-12-05 00:00:00 UTC Thursday, 2024-12-12 00:00:00 UTC | |
* 1434 Thursday, 2024-12-19 00:00:00 UTC Thursday, 2024-12-26 00:00:00 UTC | |
* 1435 Thursday, 2025-01-02 00:00:00 UTC Thursday, 2025-01-09 00:00:00 UTC | |
* 1436 Thursday, 2025-01-16 00:00:00 UTC Thursday, 2025-01-23 00:00:00 UTC | |
*/ | |
function testStartDates() public { | |
// timestamp | |
uint sep18 = 1726663091; | |
vm.warp(sep18); | |
console.log(block.timestamp); | |
uint expEpoch = 1427; | |
assertEq(clock.currentEpoch(), expEpoch); | |
uint oct10 = sep18 + 22 days; | |
vm.warp(oct10); | |
console.log(block.timestamp); | |
assertEq(clock.currentEpoch(), 1429); | |
// check voting is active | |
assertTrue(clock.votingActive()); | |
// check that if we rewind 1 day, voting is not active | |
vm.warp(oct10 - 1 days); | |
assertFalse(clock.votingActive()); | |
// from the interwebs | |
uint oct10EpochConverter = 1728518400; | |
assertEq(oct10 / 2 weeks, oct10EpochConverter / 2 weeks); | |
vm.warp(oct10EpochConverter); | |
assertEq(clock.currentEpoch(), 1429); | |
// check voting is active - think it might not be b/c we need to wait 1 hours | |
assertFalse(clock.votingActive()); | |
vm.warp(oct10EpochConverter + 1 hours); | |
assertTrue(clock.votingActive()); | |
// warp 1 second back | |
vm.warp(oct10EpochConverter + 1 hours - 1 seconds); | |
assertFalse(clock.votingActive()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment