-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(cheatcodes): add vm.storeTransient
and vm.loadTransient
#8165
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
Comments
this is related to #6908 |
@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 |
vm.storeTransient
and vm.loadTransient
vm.storeTransient
and vm.loadTransient
vm.storeTransient
and vm.loadTransient
vm.storeTransient
and vm.loadTransient
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
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
The text was updated successfully, but these errors were encountered: