Skip to content
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

Plugin fails after an update in deepmerge library #7

Open
pdyraga opened this issue May 3, 2022 · 0 comments
Open

Plugin fails after an update in deepmerge library #7

pdyraga opened this issue May 3, 2022 · 0 comments

Comments

@pdyraga
Copy link

pdyraga commented May 3, 2022

See: NomicFoundation/hardhat#2630

It is no longer possible to use hardhat-local-networks-config and run tests on a forked mainnet chain.

Quoting @fvictorio:

I think the root of the issue is here:

https://github.com/keep-network/hardhat-local-networks-config/blob/964729beeb28115e143de61d6a99ece74eafb14b/src/index.ts#L21

The Hardhat Network config has a chains property, which is a Map. But if you use deepmerge with a map, it gets converted to an object (and you lose its contents):

> deepmerge({}, {a: new Map([[1, 1]])})
{ a: {} }

I don't know what's the right solution here. There is an open issue about this in the deepmerge repo and the author created an alternative that seems to support maps and sets, maybe that helps?

Steps to reproduce

Try this piece of code with the most recent (2.9.3) hardhat version and this config referencing our clone of hardhat-local-networks-config-plugin.

You will see the test failing with TypeError: config.chains.has is not a function when trying to hardhat_reset.

const hre = require("hardhat")

describe.only("Forking test", () => {
  async function resetFork() {
    await hre.network.provider.request({
      method: "hardhat_reset",
      params: [
        {
          forking: {
            jsonRpcUrl: "https://eth-mainnet.alchemyapi.io/v2/<id>",
            blockNumber: 13619810,
          },
        },
      ],
    })
  }

  before(async () => {
    await resetFork()
  })

  it("should work", async () => {
    console.log("ok")
  })
})
  1) Forking test
       "before all" hook for "should work":
     TypeError: config.chains.has is not a function
      at Function.create (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:199:25)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async HardhatNetworkProvider._init (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:250:28)
      at async HardhatNetworkProvider._send (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:191:5)
      at async HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:117:18)
      at async resetFork (test/system/staking.test.js:5:5)
      at async Context.<anonymous> (test/system/staking.test.js:19:5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant