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

Custom Solidity errors throw Uncaught TypeError with Mocha --parallel #2355

Closed
davidtperk opened this issue Feb 8, 2022 · 8 comments
Closed
Assignees

Comments

@davidtperk
Copy link

davidtperk commented Feb 8, 2022

In Solidity ^0.8.0, reverting with a custom Solidity error while testing in parallel using Mocha throws the following error:

1) Uncaught error outside test suite:
     Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'SourceFile'
    |     property 'contracts' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Contract'
    |     property 'location' -> object with constructor 'SourceLocation'
    --- property 'file' closes the circle
      at stringify (<anonymous>)
      at writeChannelMessage (internal/child_process/serialization.js:120:20)
      at process.target._send (internal/child_process.js:812:17)
      at process.target.send (internal/child_process.js:710:19)
      at /Users/davidperkins/Desktop/hardhat-examples/parallel-tests/node_modules/workerpool/src/worker.js:131:22

Removing the --parallel flag from mocha throws the expected error: Error: VM Exception while processing transaction: reverted with custom error 'MyCustomError()'.

To reproduce, clone my fork of hardhat-examples. In the parallel-tests folder, run yarn followed by yarn test:parallel, once with --parallel in the npm script and once without.

@feuGeneA
Copy link
Contributor

feuGeneA commented Feb 8, 2022

See #2331

@feuGeneA feuGeneA closed this as completed Feb 8, 2022
@davidtperk
Copy link
Author

davidtperk commented Feb 8, 2022

@fvictorio's parallel-tests already runs successfully with mocha --parallel and "mocha": "^8.3.2", just not with custom Solidity errors. Is --parallel just not "officially" supported?

@fvictorio
Copy link
Member

@davidtperk: notice that that example uses a somewhat old version of Hardhat. Are you using the latest one? If so, can you please create a minimal reproducible example?

@davidtperk
Copy link
Author

@fvictorio yes, using "hardhat": "^2.8.3". Here's a reproducible example: https://github.com/davidtperk/hardhat-examples/tree/master/parallel-tests. Run yarn test:parallel, once with --parallel in the npm script and once without.

@fvictorio
Copy link
Member

Thank you! I'm not sure if we should consider this a Hardhat bug or a bug in my example, but I'll re-open this just in case.

@fvictorio fvictorio reopened this Feb 8, 2022
@davidtperk
Copy link
Author

Should be a Hardhat bug because I'm having the same issue in my own project.

@fvictorio
Copy link
Member

Thanks a lot for finding and reporting this @davidtperk. We were about to release parallel tests support in core, but this is definitely a blocker.

The underlying reason is this issue. The tl;dr is that our errors have circular references, and parallel mode serializes test errors in a way that doesn't support circular references.

@alcuadrado
Copy link
Member

This has been fixed in v2.9.0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants