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

upgrades.deployProxy hangs in hh coverage #702

Open
davidtperk opened this issue Mar 28, 2022 · 10 comments
Open

upgrades.deployProxy hangs in hh coverage #702

davidtperk opened this issue Mar 28, 2022 · 10 comments

Comments

@davidtperk
Copy link

Fixtures seem to hang indefinitely when running hh coverage. All tests that make use of fixtures fail with Error: Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves....

Conversely, the same tests pass when running hh test.

import { MyContract } from "../types"; 
import { waffle } from "hardhat";
const { loadFixture, provider } = waffle;

interface MyFixture {
    myContract: MyContract;
}

describe("Tests", () => {
    async function myFixture(): Promise<MyFixture> {
        const myContract = MyContract__factory.connect(address, provider);
        return { myContract };
    }

    it("can test something", async () => {
        console.log(0);
        const { myContract } = await loadFixture(myFixture);
        console.log(1); // only outputted when running `hh test`
        ....
    });
});
@cgewecke
Copy link
Member

@davidtperk I'm not familiar with the waffle plugin. Is it using the HardhatEVM?

If it's using a ganache instance supplied by waffle solidity-coverage won't work.

You might try getting the provider from hardhat and using that as the client:

import { waffle, network } from "hardhat";
const { loadFixture } = waffle;
const provider = network.provider;

@davidtperk
Copy link
Author

It's actually an upgrades.deployProxy within the fixture that's hanging.

import { ethers, upgrades } from "hardhat";
import { MyContract } from "../types"; 
import { waffle } from "hardhat";
const { loadFixture } = waffle;

interface MyFixture {
    myContract: MyContract;
}

describe("Tests", () => {
    async function myFixture(): Promise<MyFixture> {
        const myContractFactory = await ethers.getContractFactory("MyContract", deployer);
        console.log(1);
        const myContract = (await upgrades.deployProxy(myContractFactory, [0, 0])) as MyContract;
        console.log(2); // outputs for `hh test`, not `hh coverage`
        return { myContract };
    }

    it("can test something", async () => {
        console.log(0);
        const { myContract } = await loadFixture(myFixture);
        console.log(3); // outputs for `hh test`, not `hh coverage`
        ....
    });
});

@davidtperk davidtperk changed the title Fixtures hang in hh coverage upgrades.deployProxy hangs in hh coverage Mar 29, 2022
@cgewecke
Copy link
Member

cgewecke commented Mar 29, 2022

@davidtperk Yes but that's probably the first interaction with the client? What network are you running your tests on etc. If you have a link to a public git repo which reproduces this error I can take a look.

@davidtperk
Copy link
Author

Network is a hardhat fork of kovan. There are two contract reads before deployProxy is called that both succeed, but deployProxy is the first transaction. I'll see if I can spin up a reproducible example.

@cgewecke
Copy link
Member

I think the forking is likely the problem.

@davidtperk
Copy link
Author

Still need an MRE?

@cgewecke
Copy link
Member

Would it be possible to isolate whether that triggers the hang on your end - i.e can you write your test so it doesn't rely on a forked network (but use upgrades)?

@davidtperk
Copy link
Author

I disabled forking and deployProxy actually still hangs. Cleaned the Hardhat cache too.

@cgewecke
Copy link
Member

@davidtperk Yes, I'm sorry I think an MRE will be necessary to debug this further.

@davidtperk
Copy link
Author

davidtperk commented Mar 30, 2022

Haven't been able to reproduce this in a fresh project. deployProxy first deploys an implementation contract followed by the proxy. The eth_sendTransaction call that deploys the implementation contract doesn't seem to be getting mined, because eth_getTransactionReceipt returns null for the transaction, which prevents the proxy from being deployed, and hence the hang. How would you troubleshoot transactions not getting mined? @cgewecke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants