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

Improve experience of mixing hardhat_reset and fixtures #4151

Open
fvictorio opened this issue Jul 14, 2023 · 3 comments
Open

Improve experience of mixing hardhat_reset and fixtures #4151

fvictorio opened this issue Jul 14, 2023 · 3 comments
Labels

Comments

@fvictorio
Copy link
Member

If you use fixtures and hardhat_reset, you will likely run into an error like:

FixtureSnapshotError: There was an error reverting the snapshot of the fixture.

This might be caused by using nested loadFixture calls in a test, for example by using multiple beforeEach calls. This is not supported yet.

That message is misleading, and also a lie: we support nested loadFixture calls now.

Two things to do here:

  • Update that error message
  • Check if there's an easy way to detect that there was a reset and act accordingly (just clear the fixtures array in that case I guess?)
@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Jul 14, 2023
@zdenham
Copy link

zdenham commented Jul 22, 2023

I'm also seeing this issue with fixtures + hardhat_reset on any test, our workaround was to run this test which required rest without fixtures (and separately from the rest of our tests with fixtures).

@Saty248
Copy link
Contributor

Saty248 commented Jul 27, 2023

hi @fvictorio ,am working on this issue..

  1. first of all ,in my pr, am changing the the error message to

There was an error reverting the snapshot of the fixture.

This might be caused by using hardhat_reset and loadFixture calls in a testcase.

  1. what we also can do is, when hardhat_reset is called, we create a function at the loadFixtures which sets the fixtures array to empty.

any thoughts about this idea?

@julianmrodri
Copy link

julianmrodri commented Dec 12, 2023

I think Im facing this issue!

What is strange in my case is that i works locally but not in CI. When the test runs in Github actions I get: What could be the reason Im only seeing the error in CI? Is there a workaround?

I do not have nested beforeEach, but I do a network reset and then a beforeEach that deploys a lot of contracts, and performs impersonation, etc.

 FixtureSnapshotError: There was an error reverting the snapshot of the fixture.

This might be caused by using nested loadFixture calls in a test, for example by using multiple beforeEach calls. This is not supported yet.
      at loadFixture (/home/runner/work/protocol/protocol/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:51:15)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at runNextTicks (node:internal/process/task_queues:65:3)
      at processImmediate (node:internal/timers:437:9)
      at async Context.<anonymous> (/home/runner/work/protocol/protocol/test/integration/FacadeMonitorNew.test.ts:159:9)
  
      Caused by: InvalidSnapshotError: Trying to restore an invalid snapshot.
          at Object.restore (/home/runner/work/protocol/protocol/node_modules/@nomicfoundation/hardhat-network-helpers/src/helpers/takeSnapshot.ts:46:15)
          at runMicrotasks (<anonymous>)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at runNextTicks (node:internal/process/task_queues:65:3)
          at processImmediate (node:internal/timers:437:9)
          at async loadFixture (/home/runner/work/protocol/protocol/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:44:7)
  ...

alcuadrado added a commit that referenced this issue May 17, 2024
…ssue_#4151

adding a function and editing the error message for the issue #4151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

4 participants