Open 0xteddybear opened 2 weeks ago
this is related to #6908
@klkvr would this be possible with --isolate?
@klkvr would this be possible with --isolate?
only if cheatcode is invoked inside of isolated subcall
contract TransientAssert {
function assertLocked() external {
bool locked;
assembly { locked := tload(0) }
assertTrue(locked);
}
}
contract TestTransient {
TransientAssert target = new TransientAssert();
// passes only without --isolate
function test_root() {
vm.tstore(target, bytes32(0), bytes32(1));
target.assertLocked();
}
// passes always
function test_subcall() {
this.test_root();
}
}
we can probably allow it always, even though I think testing transient storage makes sense only with --isolate
Component
Forge
Describe the feature you would like
A cheatcode that sets a contract's transient storage slot to a particular value, and another one allowing to read it
Additional context
It'd be consistent to have methods to read/write transient storage similar to those that already perform those operations on regular storage
They are useful for mocks & unit testing of contracts using transient storage, and would be extra useful given there are currently no solidity variables of
transient
type and that makes it more cumbersome to write mocks by hand or with automated mocking tools such as smock-foundrySetting the transient storage slot from outside the contract enables devs to do less mocking