-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cheatcodes): add
vm.getFoundryVersion()
(#8530)
* feat: implement `vm.getFoundryVersion` * test: implement dummy test for `vm.getFoundryVersion` * chore: modify implementation to return cargo version and build timestamp * test: modify test * docs: add sample output * chore: cargo cheats * fix: failing test and vergen setup * test: update getFoundryVersion * docs: mention built timestamps issue --------- Co-authored-by: Matthias Seitz <[email protected]>
- Loading branch information
Showing
8 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
fn main() { | ||
vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import "ds-test/test.sol"; | ||
import "cheats/Vm.sol"; | ||
|
||
contract GetFoundryVersionTest is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function testGetFoundryVersion() public view { | ||
string memory fullVersionString = vm.getFoundryVersion(); | ||
|
||
string[] memory versionComponents = vm.split(fullVersionString, "+"); | ||
require(versionComponents.length == 3, "Invalid version format"); | ||
|
||
string memory semanticVersion = versionComponents[0]; | ||
require(bytes(semanticVersion).length > 0, "Semantic version is empty"); | ||
|
||
string memory commitHash = versionComponents[1]; | ||
require(bytes(commitHash).length > 0, "Commit hash is empty"); | ||
|
||
uint256 buildUnixTimestamp = vm.parseUint(versionComponents[2]); | ||
uint256 minimumAcceptableTimestamp = 202406111234; | ||
require(buildUnixTimestamp >= minimumAcceptableTimestamp, "Build timestamp is too old"); | ||
} | ||
} |