1

I'm trying to test out some functionality using the AAVE sandbox network, which is a hardhat forked network that has their protocol built in for testing purposes. I am able to deploy my contract to the network and interact with it, however, the state resets every time I run a new test. Also, I am printing the address of the contract each time I run the test and the address changes every time and is different that the address in the contract's JSON object in deployments. For clarity, here is how I am accessing the contract in my test code.

accounts = await ethers.getSigners()
              deployer = accounts[0]
              user = accounts[1]
              await deployments.fixture(["all"])
              yieldFundContract = await ethers.getContract("YieldFund")
              yieldFund = yieldFundContract.connect(deployer)

I'm wondering if this issue is happening due to some property of a hardhat network, but I figured it would be able to keep track of state? Furthermore, this code works as expected when deployed to a testnet and tested in the exact same way.

1 Answer 1

1

that's a pretty normal state of affairs. the hardhat network only lasts as long as your script is running and you start afresh each run. That's generally not a bad thing for unit tests and suchlike.

If you want the network state to persist for a while, like with ganache or similar, you'd have to run it up in a separate process and interact with that. something like npx hardhat node

1
  • Yea I am running hardhat node...
    – l1nkm4rine
    Sep 10, 2022 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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