Here my test js file

const ApprovalContract = artifacts.require('../../contracts/ApprovalContract.sol');

contract('ApprovalContract' function (accounts) {

    it('initiates contract', async function() {
        const contract = await ApprovalContract.deployed();
        const approver = await contract.approver.call();
        assert.equal(approver, 0x3999BA5D247c800E5Ef3d4de66618741E3675379, "approver don't match");

From my cmd

  • What is the content of your configuration file (truffle.js and/or truffle-config.js)? Are you testing against ganache or a private network? The error message is saying your truffle configuration id doesn't matches the id returned by the network. – Ismael Apr 4 at 19:22
  • I testing against truffle/ganache network, and I have both 2 file, truffle.js and truffle-config.js in different location. The truffle-config.js file was just an example file when i "truffle init" and below is my truffle.js file code. module.exports = { networks: { development: { host: "", port: 9545, network_id: "*" } } }; truffle-config.js location: D:\Desktop\BuildDapps 2\contracts truffle.js location: D:\Desktop\BuildDapps 2\contracts\test – johnho.91 Apr 5 at 13:46
  • I think the configuration file has to be in D:\Desktop\BuildDapps 2`, and you should execute truffle commands from that directory. You only need one config file in your proyect, either truffle-config.js` or truffle.js. – Ismael Apr 5 at 17:20

I encountered the same thing when running truffle test.

The reason is likely because truffle-config.js from truffle unbox <package> have network information commented out.

Thus, the port and network_id default to 4447, which is what truffle test defaults to if nothing is specified in truffle-config.js

See: https://github.com/trufflesuite/truffle/pull/1577/files

What you will need to do is to uncomment the networks config in truffle-config.js.

module.exports = {
  /* <- NOTE: need to uncomment this!
  networks: {
    development: {
      host: "",
      port: 7545,
      network_id: "*"
    test: {
      host: "",
      port: 7545,
      network_id: "*"
  */ <- NOTE: need to uncomment this!


delete file truffle.js

file truffle-config.js module.exports = { networks: { development: { host: "", port: 7545, network_id: "*" } } };

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.