-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vm.sleep() & vm.unixTime() cheatcodes (#1021)
* Add vm.sleep() docs * Add vm.unixTime() docs
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## `sleep` | ||
|
||
### Signature | ||
|
||
```solidity | ||
function sleep(uint256 milliseconds) external; | ||
``` | ||
|
||
### Description | ||
|
||
Sleeps for a given amount of milliseconds. | ||
|
||
### Examples | ||
|
||
```solidity | ||
vm.sleep(10_000); // Halts execution for 10 seconds | ||
``` | ||
|
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,21 @@ | ||
## `unixTime` | ||
|
||
### Signature | ||
|
||
```solidity | ||
function unixTime() external returns (uint milliseconds); | ||
``` | ||
|
||
### Description | ||
|
||
Returns the time since unix epoch in milliseconds. | ||
|
||
### Examples | ||
|
||
```solidity | ||
uint start = vm.unixTime(); | ||
vm.sleep(10_000); // Halts execution for 10 seconds | ||
uint end = vm.unixTime(); | ||
assertEq(end - start, 10_000); | ||
``` | ||
|