-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[hardhat-waffle] types for "loadFixture" are broken #849
Comments
I've also just noticed that there is another potentially linked issue with the implementation of fixtures in In the fixtures.ts file, the types are
Possibly related: TrueFiEng/Waffle#355 |
Hey @alcuadrado, has this been addressed in Hardhat? |
@PaulRBerg I was running into this issue today with Hardhat, so it seems like this is not fixed yet. |
Hi, I recently was able to use I'm going to leave this open because at some point we need to put some serious effort into making waffle work more seamlessly with hardhat, and this is one of the several things that should work better. |
I can confirm that it works now. Yes, increasing compatibility between Hardhat and Waffle (or even implementing some of the latter's features natively) would go a long way. |
Update: it doesn't work. The only improvement is that the types match now. I am getting this error: TypeError: Cannot read property '0' of undefined
at /Users/paulrberg/projects/prb-math/test/shared/fixtures.ts:28:35
at step (test/shared/fixtures.ts:33:23)
at Object.next (test/shared/fixtures.ts:14:53)
at /Users/paulrberg/projects/prb-math/test/shared/fixtures.ts:8:71
at new Promise (<anonymous>)
at __awaiter (test/shared/fixtures.ts:4:12)
at unitFixturePrbMathUd60x18 (test/shared/fixtures.ts:65:12)
at Proxy.load (node_modules/@nomiclabs/hardhat-waffle/src/fixtures.ts:32:26)
at Context.<anonymous> (test/prbMathUd60x18/PRBMathUD60x18.ts:9:45)
at step (test/prbMathUd60x18/PRBMathUD60x18.ts:33:23) The issue is that the array of signers is empty. |
Which array of signers? The one received by the async function myFixture() {
const signers = await ethers.getSigners()
... and use that. |
Yes.
Oh, I see. |
You can create different functions to call a fixture with different arguments and use that functions with loadFixture() |
Description
As explained on Discord, the 2.1.0 release for
@nomiclabs/buidler-waffle
broke theloadFixture
function.The root of the issue is in the fixtures.ts file. If
overrideSigners
is not manually overridden by end-users, the defaultloadFixture
function has this argument to 'undefined', as per its definition in index.ts:As you can see, there is no second or third argument, so
overrideSigners
ends up being assigned to 'undefined'.Current Workaround
Fortunately, it is possible to band-aid this bug by creating a custom fixture loader, as per the Waffle docs. Here's how I did it:
Possible Solution
The definition of
loadFixture
should be changed to something like this:I would have made a PR, but:
bre.ethers
from within that contextextendEnvironment
is non-async soawait
functions cannot be executedThe text was updated successfully, but these errors were encountered: