Tests are failing using ganache-fork with OpenZeppelin Test Environment with a timeout error

@msolomon4 reported on Telegram:

Trying out the ganache fork with the new test-environment package.

Tests are failing for me with a timeout error, but seem to be working for someone else. Does anyone have insight into why this is happening?

Repo and details here: https://github.com/ScopeLift/endaoment/pull/14

1 Like

I suspect that the issue could be Ganache startup time can trigger mocha timeout as per open Issue: https://github.com/OpenZeppelin/openzeppelin-test-environment/issues/48

A work around is to increase the mocha timeout (though you have already done that to 10000ms).

I need to check out your repo today.

I had tried increasing the time out to 100000ms as well and still get the same error

1 Like

Hi @msolomon4,

I changed the timeout to 100,000ms and the test passed,
I also ran with the timeout disabled.

It looks like the setup is taking 18-26sec to run, so assume it is related to: OpenZeppelin/openzeppelin-test-environment#48

I am running on WSL2 on Windows 10.
node v10.19.0
npm 6.14.4

Test

$ npm run test

> endaoment@1.0.0 test /home/abcoathup/projects/forum/endaoment
> oz compile && mocha --exit --timeout 0 test/*-test.js

Nothing to compile, all contracts are up to date.


  Moloch
    ✓ should see the deployed Moloch contract


  1 passing (26s)

Time check

    before(async () => {

        start = Date.now();

        this.instance = await Moloch.new(
            summoner,
            "0x6B175474E89094C44Da98b954EedeAC495271d0F", // address _approvedToken (DAI address)
            17280, // uint256 _periodDuration
            35, // uint256 _votingPeriodLength -- 35 periods?
            35, // uint256 _gracePeriodLength -- 35 periods?
            5, // uint256 _abortWindow -- 5 periods?
            "100000000000000000000", // uint256 _proposalDeposit -- 100 Dai
            3, // uint256 _dilutionBound -- 3
            "1000000000000000000", // uint256 _processingReward -- 1 Dai
            {from: summoner});

        end = Date.now();

        console.log(`Deploy Moloch: ${(end - start)/1000} sec`)
    });

So I removed the build directory and reinstalled node_modules, and with a timeout of zero I get the error below and the process quits 2-3 seconds after compiling:

> endaoment@1.0.0 test /Users/mds/Documents/projects/endaoment
> oz compile && mocha --exit --timeout 0 test/*-test.js

Nothing to compile, all contracts are up to date.


  Moloch
(node:11943) UnhandledPromiseRejectionWarning: Error: Unhandled server error
    at Object.default_1 [as default] (/Users/mds/Documents/projects/endaoment/node_modules/@openzeppelin/test-environment/src/setup-ganache.ts:68:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:11943) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11943) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

With a timeout of 100,000 and 1,000,000 (over 16 minutes!) it prints the same error as above and ultimately times out, as shown below

> endaoment@1.0.0 test /Users/mds/Documents/projects/endaoment
> oz compile && mocha --exit --timeout 1000000 test/*-test.js

Nothing to compile, all contracts are up to date.


  Moloch
(node:12234) UnhandledPromiseRejectionWarning: Error: Unhandled server error
    at Object.default_1 [as default] (/Users/mds/Documents/projects/endaoment/node_modules/@openzeppelin/test-environment/src/setup-ganache.ts:68:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12234) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12234) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    1) "before all" hook for "should see the deployed Moloch contract"


  0 passing (17m)
  1 failing

  1) Moloch
       "before all" hook for "should see the deployed Moloch contract":
     Error: Timeout of 1000000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/mds/Documents/projects/endaoment/test/endaoment-test.js)
  



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! endaoment@1.0.0 test: `oz compile && mocha --exit --timeout 1000000 test/*-test.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the endaoment@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mds/.npm/_logs/2020-04-22T02_43_07_733Z-debug.log

Versions
macOS 10.15.1
Ganache CLI v6.9.1 (ganache-core: 2.10.2)
openzeppelin/test-environment 0.1.4

1 Like

Hi @msolomon4,

Just checking that you have a .env file in your project root directory with contents:

INFURA_ID="VALID INFURA PROJECT ID"

Without a valid .env file I get the following error:

$ npm run test

> endaoment@1.0.0 test /home/abcoathup/projects/forum/endaoment
> oz compile && mocha --exit --timeout 0 test/*-test.js

Nothing to compile, all contracts are up to date.


  Moloch
(node:13725) UnhandledPromiseRejectionWarning: Error: Unhandled server error
    at Object.default_1 [as default] (/home/abcoathup/projects/forum/endaoment/node_modules/@openzeppelin/test-environment/src/setup-ganache.ts:68:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13725) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13725) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Ah, yes. Set the last run up quickly in response to your message and in my haste forgot to run source .env as a result. Whoops… :man_facepalming:

Well it does pass with the timeout set to 100000 now. Perhaps reinstalling node_modules was the solution to the original issue? Either way, takes about 6 seconds to start up and tests pass now. Apologies for the mistake earlier, and thanks as always for your help! :pray:

1 Like

Hi @msolomon4,

I’m not sure what caused the original issue that you were seeing.
I get a test time of 18-26 seconds, though I am on WSL2.

Glad you have resolved.

1 Like