Skip to content

Commit

Permalink
feat: add vm.loadAllocs(string) cheatcode (#474)
Browse files Browse the repository at this point in the history
* vm: add `loadAllocs(string)` cheatcode

Adds the `loadAllocs(string)` cheatcode to be usable as part of the
`Vm` interface. This was added to foundry in foundry-rs/foundry#6207.
The cheatcode can be used to read a JSON file from disk that sets EVM
state directly.

* chore: keep section alphabetically sorted

---------

Co-authored-by: Matt Solomon <matt@mattsolomon.dev>
  • Loading branch information
tynes and mds1 authored Nov 7, 2023
1 parent 267acd3 commit 37a37ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Vm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ interface Vm is VmSafe {
// Sets an address' code
function etch(address target, bytes calldata newRuntimeBytecode) external;

// Load a genesis JSON file's `allocs` into the in-memory state.
function loadAllocs(string calldata pathToAllocsJson) external;

// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts
function resetNonce(address account) external;

Expand Down
2 changes: 1 addition & 1 deletion test/Vm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ contract VmTest is Test {
// added to or removed from Vm or VmSafe.
function test_interfaceId() public {
assertEq(type(VmSafe).interfaceId, bytes4(0x329f5e71), "VmSafe");
assertEq(type(Vm).interfaceId, bytes4(0x82ccbb14), "Vm");
assertEq(type(Vm).interfaceId, bytes4(0x316cedc3), "Vm");
}
}

0 comments on commit 37a37ab

Please sign in to comment.