This is the error I get when running truffle test --network kovan:

1) "before all" hook: prepare suite

 Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/mcplums/Repos/ConsensysBootcamp/truffle-test-debugging/project-dir/test/simpleStorageTest.js)

The tests work fine if I just do truffle test. Also truffle migrate --network kovan works fine and I am able to interact with the contract via remix. So whatever the problem is, it is not a problem with testing generally, and it is not a problem with migrating to kovan generally.

I managed to recreate my problem using the truffle test tutorial box to make things as simple as possible.

Here is my truffle config:

const path = require("path");
const HDWalletProvider = require('truffle-hdwallet-provider');
const mnemonic = 'XX'; // 12 word mnemonic 
const kovanProviderUrl = 'https://kovan.infura.io/v3/XX';

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  plugins: [ "truffle-security" ],
  contracts_build_directory: path.join(__dirname, "app/src/contracts"),
  networks: {
    kovan: {
      network_id: 42,
      provider: new HDWalletProvider(mnemonic, kovanProviderUrl, 0),
      gas: 10000000,
      gasPrice: 1000000000, // 1 gwei
      skipDryRun: true,
    development: {
      host: "",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
      gasPrice: 1000000000, // 1 gwei
  mocha: {
    reporter: 'eth-gas-reporter',
    reporterOptions: {
      currency: 'USD',
      gasPrice: 5, //in gwei

And here is the js test file:

var SimpleStorage = artifacts.require('SimpleStorage')

contract('SimpleStorage', async (accounts) => {

    it('Calling set(x) should set storedData in storage to x', async() => {
        let newValue = 2;
        let instance = await SimpleStorage.deployed()

        instance.set(newValue, {from: accounts[0]})
        let returnedValue = await instance.storedData.call()

        assert.equal(newValue, returnedValue, "The returned value should equal the new value.")


It takes < 2 minutes to deploy the contracts onto kovan so I don't think simply increasing the timeout is the solution.

Happy to put the above onto github to allow testing the exact code I've got if that would help.

Wat do? Thank you in advance kind internet strangers.

  • 1
    1. Print accounts[0] and make sure it's valid. Ganache gives you a set of unlocked accounts "for free", which you don't automatically get on a public network. 2. Add mocha: {enableTimeouts: false} to your Truffle configuration file and see if it resolves the problem. Commented Dec 22, 2019 at 7:31
  • Thanks for your response. So I disabled timeouts, and deleted all parts of the test but added console.log(accounts[0]);. I added it twice, just before and just after the ' it('......', async() => { bit. It correctly prints the relevant address ONCE but never gets to it a second time (ie the test is never run). I waited ten mins. I should also mention that I can see the contract being deployed on kovan so SOMETHING is happening. It appears to deploy the contracts but never actually get to running the test. Any other ideas? Commented Dec 23, 2019 at 9:03
  • You don't have to use await before SimpleStorage.deployed, and you have to use await before instance.set. Commented Dec 23, 2019 at 9:46
  • Hello. Both the relevant lines you mentioned are commented out anyway so I don't think that is the issue. Please see github.com/mcplums/Truffle-test-problem can you get the test to work on kovan your end? Commented Dec 27, 2019 at 5:04


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.