-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Squashed commits from block-timestamp * fix: use pending block timestamp as mined block timestamp * chore: remove unused import * enha: fix dev offsets and evm_setnextblocktimestamp * chore: remove useless test * fix: lint * fix: lint * fix: 1s granularity * chore: lint * fix: lint * fix: lint * enha: initial test block timestamp contract * chore: add to automine as well * enha: improve external test case * chore: simplify contract * chore: change test * chore; remove unused * chore: lint * chore: add some methods to get records * feat: add hardhat compatibility * enha: fix test * fix: lint * chore: remove * chore: lint * chore: simplify contract * chore: wait * chore: doc * enha: use more methods to validate * chore: add final timestamp comparison * chore: improve automine test
- Loading branch information
1 parent
146330d
commit 5e14bea
Showing
16 changed files
with
401 additions
and
113 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
contract TestContractBlockTimestamp { | ||
event TimestampRecorded(uint256 timestamp, uint256 blockNumber); | ||
|
||
struct TimeRecord { | ||
uint256 timestamp; | ||
uint256 blockNumber; | ||
} | ||
|
||
TimeRecord[] public records; | ||
|
||
/// @dev Records current block timestamp and number | ||
/// @return The recorded timestamp | ||
function recordTimestamp() public returns (uint256) { | ||
uint256 timestamp = block.timestamp; | ||
records.push(TimeRecord(timestamp, block.number)); | ||
emit TimestampRecorded(timestamp, block.number); | ||
return timestamp; | ||
} | ||
|
||
/// @dev Gets the current block timestamp | ||
/// @return The current block.timestamp | ||
function getCurrentTimestamp() public view returns (uint256) { | ||
return block.timestamp; | ||
} | ||
|
||
/// @dev Gets all recorded timestamps | ||
/// @return Array of TimeRecord structs | ||
function getRecords() public view returns (TimeRecord[] memory) { | ||
return records; | ||
} | ||
} |
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
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
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
Oops, something went wrong.