1

I'm trying to run a test with hardhat, and have it deploy my deployments/fixtures with the command:

npx hardhat test --network rinkeby --deploy-fixture

When I run this, I get the following error:

ProviderError: The method evm_snapshot does not exist/is not available

I have a deploy folder containing all my methods to deploy, and npx hardhat deploy --network rinkeby works great.

What gives?

3

The fixture functionality currently doesn't work for testnets. If you want to run your tests on a testnet, you'll first have to deploy the contracts, and then run your tests.

0

The following assumes your fixture setup looks something like this (?):

await deployments.fixture(contractName);

You can define a function isLocalEnv as follows.

function isLocalEnv(envName: string) {
  return !!({
    hardhat: true,
    localhost: true,
  } as Record<string, true>)[envName];
}

Then, wherever you set up the fixture, import network from hardhat, and use isLocalEnv to safeguard against the potentially-useless fixture init. Aka.

if (isLocalEnv(network.name)) {
  await deployments.fixture(contractName);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.