Enable anvil / default accounts to be unlocked by default in scripting during local tests #8225
Labels
C-forge
Command: forge
Cmd-forge-script
Command: forge script
P-low
Priority: low
T-feature
Type: feature
Milestone
Component
Forge
Describe the feature you would like
I have the following line in my script:
I am able to run this line without issue if I'm running my script as a script, because I unlock the address by passing in the password:
What is cool, is that I can even pass in my address to this API, and use a
HelperConfig
type contract to pick the address based on the chain I'm working on:However, if I use this script in a test, it fails, because their is no unlocked account. I'd like to be able to run my test suite (which includes my scripts) without having to pass in my password. However, if you run this on a test suite, you'll get:
Right now, I can do a work around like so:
You can see a full example of how I'm using my scripts in my test suite here: https://github.com/PatrickAlphaC/no-unlocked-accounts-example
Rationale
Developers who are using the scripting feature should be able to test their scripts in the same way they test their smart contracts. We are seeing more people deploy their projects without the correct access controls, or with exposed private keys, and we want to make their devops process as easy as foundry makes their dev process.
Issue Summary
I think this could be summarized into adding the anvil default key as a consistently unlocked account for locally running tests. Maybe we restrict the
vm.sign
API so that you can only use the default anvil key if you give it the anvil address or something... Or maybe an API likevm.unlockAnvilAccounts()
would be great as well.Let me know if you have any questions.
Additional context
No response
The text was updated successfully, but these errors were encountered: