foundry-rs / foundry-rs/foundry
feat(`cheatcodes`): add `vm.chisel()` to load chisel session from test function
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 510
Description
### Component
Chisel
### Describe the feature you would like
This feature would introduce the possibility to add a call such as `vm.chisel()` or `vm.chiselBreakpoint()` anywhere in a test function.
The desired behavior is that calling `chisel` on that function will result in the session being loaded with the entire state of the test at the time the call was made, including the storage state as well as the memory.
Running `forge test` should not result in a different behavior than usual.
--------
## Example
```solidity
pragma solidity ^0.8.15;
import "forge-std/Test.sol";
import "forge-std/console.sol";
import "src/Kevin.sol";
contract KevinTest is Test {
Kevin public kevin;
function setUp() public {
kevin = new Kevin();
}
function testKevin() public {
uint256 bob = 15;
vm.chisel();
uint256 stewart = 1;
}
}
```
Followed by `chisel --match testKevin`, which opens up a chisel session.
```sh
➜ address(kevin)
Type: address
└ Data: 0xf4d9599afd90b5038b18e3b551bc21a97ed21c37
➜ bob
Type: uint
├ Hex: 0xf
└ Decimal: 15
➜ stewart
Compiler errors:
error[7576]: DeclarationError: Undeclared identifier.
--> ReplContract.sol:18:1:
|
18 | stewart;
| ^^^^^^^
➜
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.