-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit 8eaf59c3753f50067551edd2b907acc5d528d115 Includes fixes and new cheatcodes.
- Loading branch information
Showing
7 changed files
with
51 additions
and
9 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
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
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,31 @@ | ||
pragma experimental ABIEncoderV2; | ||
|
||
interface Hevm { | ||
function setEnv(string calldata, string calldata) external; | ||
function ffi(string[] calldata) external returns (bytes memory); | ||
} | ||
|
||
contract TestFFI { | ||
address constant HEVM_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D; | ||
|
||
bytes32 hehe; | ||
|
||
function foo(int x) external { | ||
// ABI encoded "gm", as a string | ||
Hevm(HEVM_ADDRESS).setEnv("ECHIDNA_FOO_BAR", "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002676d000000000000000000000000000000000000000000000000000000000000"); | ||
|
||
string[] memory inputs = new string[](3); | ||
inputs[0] = "sh"; | ||
inputs[1] = "-c"; | ||
inputs[2] = "printf '%s' \"$ECHIDNA_FOO_BAR\""; | ||
|
||
bytes memory res = Hevm(HEVM_ADDRESS).ffi(inputs); | ||
|
||
(string memory output) = abi.decode(res, (string)); | ||
hehe = keccak256(bytes(output)); | ||
} | ||
|
||
function echidna_ffi() public returns (bool){ | ||
return hehe != keccak256("gm"); | ||
} | ||
} |