3

Been trying to get the standard init tests to work for a couple of hours, but no joy. Would be grateful for any assistance.

Steps taken so far

truffle init

Fine. So far, so good.

truffle compile 

Still OK.

truffle migrate

Success.

truffle test

Problems. Seem to have tried everything.

  Contract: MetaCoin
    1) "before all" hook: prepare suite


  0 passing (2m)
  1 failing

  1) Contract: MetaCoin "before all" hook: prepare suite:
     Error: timeout of 120000ms exceeded. Ensure the done() callback is being called in this test.

This seems like it could be a Mocha issue, but the metacoin.js code is off-the-shelf source from Consensys...

Many thanks in advance.

  • 1
    Edit: Had similar problem, when connected to EthereumJS TestRPC tests pass just fine. So perhaps this is just network timeout. – wonglik Sep 27 '16 at 12:40
  • Cheers wonglik! TestRPC works a treat for me, too. Just had my heart set on seeing it work with geth, too, I guess. – Max Sep 28 '16 at 20:24
4

Main author of Truffle here. It's likely related to how fast your Ethereum client is processing blocks. Truffle assumes deployment will take no longer than two minutes during tests, but I have heard reports that when deploying to the morden testnet it can often take far longer. If it does, it can cause truffle test to mark the test as failed and throw an error, as you're seeing above.

We have a ticket filed for this very issue: https://github.com/ConsenSys/truffle/issues/261

Cheers!

  • Wow, Tim. A little star struck over here. No need to introduce yourself. Of course I know who you are! I'm running against geth on a private chain, but that is runniing in a VM with limited resources. So, I'm definitely exceeding 120 seconds, but that's also the case for truffle migrate , and there's no timeout there. In any case, Test RPC is like a hot knife through butter, so I'm up-and-running anyway. My first week using Truffle, and I'm really starting to fly with Smart Contract dev. Thank you for your work, well done. – Max Sep 28 '16 at 20:30
  • 1
    "that's also the case for truffle migrate, and there's no timeout there" -- correct! I actually answered the question incorrectly. It's not due to block time, but rather the total time it takes to deploy all contracts. truffle test uses truffle migrate for deployment, which has no maximum timeout, but the test runner (mocha) enforces a timeout to ensure the test doesn't run indefinitely. I'll edit my answer! – Tim Coulter Sep 28 '16 at 20:58
1

Hard coded mocha.js timeout to 0. Hardly an elegant solution, but it seems to have gotten me over the hump. Truffle test now executes!

  • Could you add details for this please @Max? – pfrank Sep 30 '17 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.