-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(cheatcodes
): vm.rememberKeys
#9087
Conversation
Companion PR: foundry-rs/forge-std#622 |
@grandizzy @klkvr review pls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, note on performance, would like us to revisit script wallets handling if we want to support scripting cheats in tests as well
// This is needed in case of testing scripts, wherein script wallets are not set on setup. | ||
let script_wallets = ScriptWallets::new(MultiWallet::default(), None); | ||
script_wallets.add_local_signer(wallet); | ||
Arc::make_mut(&mut state.config).script_wallets = Some(script_wallets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be quite expensive because we'll clone config which stores all project bytecodes
I think essentially for tests ScriptWallets
can just be a vec of PrivateKeySigner
s stored on Cheatcodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* feat(`cheatcodes`): vm.rememberKeys * docs + return addresses + test * remeberKeys with language * doc nits * cargo cheats * set script wallet in config if unset * nit * test
Motivation
Closes #8225 + Closes #7950
Solution
Introduces cheatcodes to derive and save multiple wallets/signers in the script env.
Under the hood these cheatcodes save the derived wallets in
ScriptWallets
such that they are persisted throughout the script environment.Moreover, to aid in the testing of scripts (as in
forge test DeployScript.t.sol
) these cheatcodes will initializeScriptWallets
in theCheatsConfig
if not already initializedThis is particularly useful for testing scripts that require unlocked accounts.