How to debug into a forked chain's contract code while running forge test? I do have source code #12734
Replies: 1 comment
-
|
The debugger shows bytecode for forked contracts because it maps source to compiled artifacts in your You mentioned compiling production code alongside tests but only using interfaces. That's the issue: interfaces don't carry source maps for the implementation. The debugger needs the full implementation artifact with source mappings. Fix: make sure the full contract implementation (not just the interface) is compiled as part of your forge build:
Since you've already verified the local bytecode matches on-chain, once the full artifact (with source map) exists in If you're importing the contract via a path that resolves to an interface, change the import to point to the full implementation in your test file. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I forked an blockchain locally by using
vm.createSelectFork. And usedforge test --debugto get into the call inside forked contracts.Basically my test calls different functions on different contracts.
But the problem is: I can debug my test code by solidity code, but i can only step into bytecode of the on-chain contracts.
I do have the source code of the forked contracts and compiled them with the same compiler version/optimizer exactly as the onchain contracts, and I also verified the local runtime bytecode is the same as onchain.
And I have compiled the production code(on-chain contracts) together with my test code. Although my test code only need the interfaces of production code. Not the implementation code.
Beta Was this translation helpful? Give feedback.
All reactions