2

By default this is the content of the file truffle.js:

module.exports = {
    // See <http://truffleframework.com/docs/advanced/configuration>
    // to customize your Truffle configuration!
};

When I execute the command truffle test with the above configuration, it work well. However, if I change the configuration to this:

module.exports = {
    networks: {
        test: {
            network_id: '*',
            gas: 4712388,
            gasPrice: 10
        }
    }
};

When I execute the command truffle test I get the following error:

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

I tried setting options host and port but still not working.

I'm using Truffle v4.1.14 on Mac.

  • 1
    which client are you using? ganache? – Tanveer Singh Oct 5 '18 at 6:33
  • I'm using truffle develop. I just figured out that I had to start it manually. I will post the answer. – dgaviola Oct 5 '18 at 12:47
0

It sounds like when you change the configuration of the test network, Truffle Develop is not initialized automatically. So in order to make this work I had to run Truffle Develop manually:

truffle develop

And then in the truffle.js I put this config:

module.exports = {
    networks: {
        test: {
            network_id: '*',
            host: '127.0.0.1',
            port: 9545,
            gas: 6712388,
            gasPrice: 100000000000
        }
    }
};

Doing that it started to work. I guess if you specify any of the parameters in the test network you have to manually take care of having the Ethereum client running.

0

Beware that default network is development-

If you define test network, then you need to use parameter --network test

Code from truffle truffle test

// if "development" exists, default to using that for testing
if (!config.network && config.networks.development) {
  config.network = "development";
}

if (!config.network) {
  config.network = "test";
}
  • I think when you execute the command truffle test the default network is test instead of development – dgaviola Oct 5 '18 at 22:19
  • @dgaviola I put code from truffle above, default network is development but test command has fallback, it will work with test network if development is not defined. Sorry to mess you up. – Aquila Oct 6 '18 at 7:24
  • I tried defining the development network too, but it doesn't work, I still need to manually run truffle develop to get it working. – dgaviola Oct 6 '18 at 18:07
  • @dgaviola before run tests you need to start test network, right? have you start ganache/testrpc? – Aquila Oct 6 '18 at 18:11
  • @Alquila yes, I need to start a network with truffle develop before running the tests, and then in the test network I configured it to point to that network – dgaviola Oct 7 '18 at 20:30

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.