-
Notifications
You must be signed in to change notification settings - Fork 55
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
Support for parallel tests #98
Comments
Thanks so much for looking into this @fvictorio.
Agree, will do that right now. Is there a task hook (executed before test) where a plugin that is wrapping the provider could initialize the globally injected provider? Perhaps that would be a way around the serialization issue - e.g if we stopped passing it as an in-memory arg to mocha via the config... (Would need some other changes here as well but seems like the biggest obstacle). I can't do any setup asynchronously in the mocha reporter because those hooks are all sync (unless they've improved this recently). |
I think you could use a root hook plugin for that. I'm not 100% sure if it fits your use case, but I think it would be something like: exports.mochaHooks = {
beforeAll(done) {
// wrap the provider
done();
}
}; And then you add that to the
I don't think that's possible right now (cc @alcuadrado) |
Oh!!! That looks really useful. |
Confirming this |
This is published (with suggested revision to use a warning instead of an error) in Just lmk if you see this not working for some reason...thanks again for advice, etc :) |
Note: Gas reporting is skipped in parallel tests because plugin `hardhat-gas-reporter` does not support the --parallel flag. Reference cgewecke/hardhat-gas-reporter#98
Note: Gas reporting is skipped in parallel tests because plugin `hardhat-gas-reporter` does not support the --parallel flag. Reference cgewecke/hardhat-gas-reporter#98
We are working on adding support for parallel tests in Hardhat and one of our concerns is how it works with
hardhat-gas-reporter
. I tested it locally and found some errors when Mocha executes in parallel.The first problem looks like this:
And it's thrown here. This is weird and I couldn't find the reason why it happens. But I did find that adding this line in the overridden subtask fixes the problem:
if (hre.network.name === HARDHAT_NETWORK_NAME || options.fast){ const wrappedDataProvider= new EGRDataCollectionProvider(hre.network.provider,mochaConfig); + await hre.network.provider.send("eth_blockNumber"); hre.network.provider = new BackwardsCompatibilityProviderAdapter(wrappedDataProvider); const asyncProvider = new EGRAsyncApiProvider(hre.network.provider);
That call forces the existing provider to be initialized, and so the function exists. Obviously, this is not the right fix, but it's a hint that the problem could be related to the custom providers created by the plugin.
The second problem looks like this:
I'm more confident about what's causing this one. I think it's this line in the plugin:
My guess is that Mocha stringifies the config for some reason (maybe to send it to the workers it creates to run the tests?) and then an error is thrown because the provider is a non-serializable object.
All that being said, I think a first step would be to just detect that parallel mode is being used and throw a proper error. That can be done like this:
The text was updated successfully, but these errors were encountered: