Skip to content

Conversation

montyly
Copy link
Contributor

@montyly montyly commented Jul 7, 2025

This PR is a WIP to add new cheatcode to medusa. The PR is not ready yet, but I am sharing it in case anyone has time to provide some feedback.

It's built on top of #618, so the code outside of chain/cheat_code_tracer.go / chain/standard_cheat_code_contract.go is not relevant to the PR.

Once I have stabilized everything, I will open individual PR to make the review easier + add the relevant documentation.

Open questions:

  • It's a bit unclear to me what is the proper way to do unit test on the cheatcode.
  • getDeployedCode would benefit from some logging to let the user knows if the targeted contract was not deployed, but I am not sure how to log this properly
  • I am not sure the logic to support expectRevert is the right approach. The cheatcode is a bit tricky given it's logic, so I had to modify the OnOpcode hook (cheat_code_tracer.go). It works by having expectRevert adding a placeholder variable, that basically means "once you execute the first opcode after returning from the targeted call, invert the value on the stack". If you have a cleaner idea on how to handle this one, let me know

The new cheatcodes:

  • getDeployedCode
  • assertTrue / assertFalse
  • assume
  • expectEmit (NOOP for now)
  • expectRevert (WIP)
  • assertEq (and variant)

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