Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Ganache startup time can trigger mocha timeout #48

Open
frangio opened this issue Mar 11, 2020 · 5 comments
Open

Ganache startup time can trigger mocha timeout #48

frangio opened this issue Mar 11, 2020 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@frangio
Copy link
Contributor

frangio commented Mar 11, 2020

The first test in a mocha test suite can time out when it interacts with test-env's ganache node, since it will have to wait until the node has fully spun up.

See this thread in the forum for more info: https://forum.openzeppelin.com/t/openzeppelin-test-environment-timeout-exceeding-2000ms/2406/14

Obviously the best way to fix this would be to reduce the startup time and this is something we would appreciate anyway. Other measures we can take is detecting that mocha is running and automatically increasing the timeout for the first test that hits the node, but I'm not sure how feasible this is. Lastly for now we can document this as something that can come up.

@ylv-io ylv-io added the bug Something isn't working label Mar 25, 2020
@ylv-io ylv-io added this to the 2020 Q2 milestone Mar 30, 2020
@abcoathup
Copy link
Contributor

@frangio
Copy link
Contributor Author

frangio commented Apr 28, 2020

An idea. The problem is that the first transaction sent in the first test will wait until the node has spun up. We can work around this by allowing the users to wait for the node to be ready outside of that first test. For example if the user is running into Mocha timeouts, we can suggest to add the following:

before(async function () {
  this.timeout(none); // however this is done
  await provider.ready;
});

(This provider.ready property is somewhat related to #36.)

@ylv-io
Copy link
Contributor

ylv-io commented May 5, 2020

@frangio that brings us back to the whole design discussion. We import test-env in a sync way so users can access accounts and other properties instantly. But if we have to await before running tests then it makes sense to await for accounts as well await getAccounts. Advantage of this approach would be extracting accounts from Ethereum node rather passing them. It could enable us to support other nodes beyond Ganace. WDYT?

@frangio
Copy link
Contributor Author

frangio commented May 5, 2020

It's not only about it being instant, it's about the accounts being available in the top level context, without having to do dirty tricks with let accounts; and assigning it in a before block. I think we should keep the current design in that regard, and the ability to wait for readiness is only optional in case users run into the timeout problem.

@frangio
Copy link
Contributor Author

frangio commented May 5, 2020

My proposal is basically a workaround though. It would be nicer to do something more automatic, if we can figure it out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants