-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"vm.setBlockhash" cheatcode #7929
Comments
Developer documentation for cheat codes: https://github.com/foundry-rs/foundry/blob/master/docs/dev/cheatcodes.md#cheatcodes-implementation |
Unsure if this makes sense to add if https://eips.ethereum.org/EIPS/eip-2935 is included in Prague, as this could be emulated with just setting the appropriate slot on the contract |
In that case, wouldn't |
yeah for setting a slot this will still be useful imo |
Hello, is it still available? I would like to work on this one |
this is available and should be similar to foundry/crates/cheatcodes/spec/src/vm.rs Lines 415 to 420 in 29e5112
foundry/crates/cheatcodes/src/evm.rs Lines 362 to 367 in 29e5112
the impl would need to update the hash of the number argument in the database if you need more pointers, please open a draft pr and we take it from there |
Hi @mattsse, it appears the previous assignee hasn't started on this task yet so I'd like to work on it. I've created a draft PR but I'm having trouble accessing the database in |
hey @mattsse you can re-assign the issue to @TropicalDog17 . Sorry for delay |
Component
cheatcodes
Describe the feature you would like
A
vm.setBlockhash
cheat code would be very convenient for testing code that uses the Solidityblockhash
function.This is how it would be used:
Currently, the easiest way to test code that calls
blockhash
is to wrap theblockhash
call in a virtual, internal method and then create a test class that overrides that method to mockblockhash
calls.I'd rather just have the mocking performed at the level of the
vm
.If this is considered sufficiently useful, I would be happy to try my hand at adding this cheat code. Just don't want to learn rust, etc. to add this only to have a PR rejected if the feature isn't seen as useful.
Additional context
No response
The text was updated successfully, but these errors were encountered: