feat: add config for impersonating accounts to BS#864
Conversation
🦋 Changeset detectedLatest commit: eb4e362 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
800a7bf to
034406a
Compare
| RUN_OVM_TEST_GAS, | ||
| } from './test/helpers/constants' | ||
|
|
||
| import '@nomiclabs/hardhat-ethers' |
There was a problem hiding this comment.
Is there anything wrong with adding this import? Does it make the production version of our software use the hardhat version of ethers?
There was a problem hiding this comment.
I believe it just mutates the hre
Useful for testing against hardhat forks.
58f6753 to
dfa9e2b
Compare
* feat: make block offset configurable * Add a USE_HARDHAT config * batch-submitter: must pass both impersonate options (#866) Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
Codecov Report
@@ Coverage Diff @@
## develop #864 +/- ##
========================================
Coverage 82.21% 82.21%
========================================
Files 48 48
Lines 1895 1895
Branches 303 303
========================================
Hits 1558 1558
Misses 337 337 Continue to review full report at Codecov.
|
annieke
left a comment
There was a problem hiding this comment.
it bothers me a little having testing / debug logic in the main code path, but can't think of a better way to do it than this for now! just one typo + nit
| logger = new Logger({ name }) | ||
| } | ||
|
|
||
| const useHardhat = config.bool('use-hardhat', !!env.USE_HARDAT) |
There was a problem hiding this comment.
| const useHardhat = config.bool('use-hardhat', !!env.USE_HARDAT) | |
| const useHardhat = config.bool('use-hardhat', !!env.USE_HARDHAT) |
is the double negative here to get the variable to be true even if undefined? i think an || would be more readable here for that
There was a problem hiding this comment.
Using the double negative syntax is shorthand for a typecast to a boolean. A single ! type casts it to the negation and the second ! cancels out the negation and returns it to the original truthiness value. It is a relatively common pattern in JS, a replacement for using Boolean(...) to type cast. I don't really see anybody ever use Boolean(...), probably because its more verbose?
is the double negative here to get the variable to be true even if undefined?
No its not, that would be a single negation (undefined is falsey so a single ! would make it truthy). We only wan't this mode to operate when the env var USE_HARDHAT is defined
I agree, definitely open to suggestions |
) * feat: add config for impersonating accounts to BS Useful for testing against hardhat forks. * Make block offset configurable (ethereum-optimism#865) * feat: make block offset configurable * Add a USE_HARDHAT config * batch-submitter: must pass both impersonate options (ethereum-optimism#866) Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com> * batch-submitter: update example env * batch-submitter: lint fix * batch-submitter: clean up old comments * batch-submitter: USE_HARDHAT * batch-submitter: add error messages Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
Useful for testing against hardhat forks.
Description
When testing changes to the batch submitter it is useful to impersonate mainnet accounts. This can be done with this new config!
Just use: