Skip to content

Impersonate Account #915

@Sotatek-TruongNguyen2

Description

@Sotatek-TruongNguyen2

I'm working with a piece of code that tries to impersonate an account on mainnet, and it works fine in a normal Hardhat test. However, when I run it with solidity-coverage, it fails with the error ProviderError: Unknown account 0xx.

Here's my Hardhat configuration setup:

hardhat: {
      chainId: 31337,
      live: false,
      tags: ['test', 'local'],
      hardfork: HARDFORK,
      blockGasLimit: BigNumber.from(10).pow(15).toNumber(),
      // gas: DEFAULT_BLOCK_GAS_LIMIT,
      throwOnTransactionFailures: true,
      throwOnCallFailures: true,
      forking: {
        enabled: FORKING_ENABLED,
        url: `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
        blockNumber: 22016809,
      },
      allowUnlimitedContractSize: true,
      allowBlocksWithSameTimestamp: false,
      gasPrice: 2228078444,
      accounts: [
        {
          privateKey: DEPLOYER_PRIVATE_KEY,
          balance: DEFAULT_ACCOUNT_BALANCE,
        },
        ...Array.from({ length: 10 }, () => {
          const wallet = Wallet.createRandom();
          return {
            privateKey: wallet.privateKey,
            balance: DEFAULT_ACCOUNT_BALANCE,
          };
        }),
      ],

And this's my command for running coverage script: COVERAGE=true npx hardhat coverage. Are there any ways to workaround this one ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions