Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vm load cheatcode #27

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

Jrigada
Copy link
Collaborator

@Jrigada Jrigada commented Dec 1, 2023

What πŸ’»

  • Added vm.load cheatcode implementation

Why βœ‹

  • downstream users of era-test-node would be able to use the load cheatcode to retrieve a value stored in an specific slot regarding an address.

Evidence πŸ“·

  function testLoad(bytes32 slot) external {
    TestLoadTarget testLoadTarget = new TestLoadTarget();
    (bool success, bytes memory data) = CHEATCODE_ADDRESS.call(abi.encodeWithSignature("load(address,bytes32)", address(testLoadTarget), slot));
    require(success, "load failed");
    bytes32 loadedValue = abi.decode(data, (bytes32));
    require(loadedValue == bytes32(uint256(1337)), "address mismatch");
  }
}

contract TestLoadTarget {
  bytes32 public testValue = bytes32(uint256(1337)); //slot 0
}

Cheatcodes
    βœ” Should test vm.load (429ms)


  1 passing (431ms)

✨  Done in 4.26s.

@Jrigada Jrigada merged commit f02534c into grw/feat-cheatcode-tracer Dec 4, 2023
8 of 11 checks passed
@Jrigada Jrigada deleted the jr/feat-add-vm-load-cheatcode branch December 4, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants