env-contract.js 893 B

123456789101112131415161718
  1. // Remove the default account from the accounts list used in tests, in order
  2. // to protect tests against accidentally passing due to the contract
  3. // deployer being used subsequently as function caller
  4. //
  5. // This operation affects:
  6. // - the accounts (and signersAsPromise) parameters of `contract` blocks
  7. // - the return of hre.ethers.getSigners()
  8. extendEnvironment(hre => {
  9. // TODO: replace with a mocha root hook.
  10. // (see https://github.com/sc-forks/solidity-coverage/issues/819#issuecomment-1762963679)
  11. if (!process.env.COVERAGE) {
  12. // override hre.ethers.getSigner()
  13. // note that we don't just discard the first signer, we also cache the value to improve speed.
  14. const originalGetSigners = hre.ethers.getSigners;
  15. const filteredSignersAsPromise = originalGetSigners().then(signers => signers.slice(1));
  16. hre.ethers.getSigners = () => filteredSignersAsPromise;
  17. }
  18. });