3

I am trying to run truffle test on an old contract which was written using pragma solidity 0.4.24;. While I am able to deploy the contracts using truffle migrate, I get the following error when running truffle test:

Using network 'development'.


Compiling your contracts...
===========================
Error: CompileError: Error parsing truffle/DeployedAddresses.sol: ParsedContract.sol:4:55: ParserError: Expected ',' but got 'payable'
  function Marketplace() public pure returns (address payable) { return 0x6395927945EA39aDD6B1E04144f1e1324B30DeFC; }
                                                      ^-----^
Compilation failed. See above.
    at async.whilst.error (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:369:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/async/dist/async.js:969:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/~/async/dist/async.js:5222:1)
    at Promise.all.then.results (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:351:1)
    at <anonymous>
Truffle v5.0.7 (core: 5.0.7)
Node v8.12.0

truffle/DeployedAddresses.sol: ParsedContract.sol:4:55 is not code I've written, nor is it part of my project. I suspect this error may be caused because Truffle is running solidity 0.4.24 to compile my contracts but that whatever it uses to execute internal tests is running solidity 0.5. Is there a way to verify/change this?

Here are the contents of truffle.js in the main directory:

module.exports = {
  migrations_directory: "./migrations",
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }, 
 // ... Other configs specified here, removed because irrelevant
 // to SO question ... 
 compilers: {
  solc: {
    version: "0.4.24",  
    }
  },
  solc: {
    optimizer: {
      enabled: true,
      runs: 500
    }
  } 
};

and the contents of truffle.js under `/test:

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    }
  }, 
  compilers: {
  solc: {
    version: "0.4.24",  
    }
  }
};

I have both .sol and .js tests and neither will run (either individually or as part of running all tests with truffle test).

  • It sounds like Truffle is running the old compiler, which is why it doesn't understand the new address payable type. I'm unclear on whether you're trying to figure out how to fix your code (use just address) or whether you actually want to start using a newer compiler. Could you clarify? – user19510 Mar 11 at 15:54
  • version: "0.4.24" is your problem of course. address payable not supported in solc 0.4.x or earlier. – goodvibration Mar 11 at 16:25
  • Thanks @smarx @goodvibration . The issue is that address payable is not part of any code I've written. It seems like it's part of whatever truffle is running internally. Therefore, when I'm running truffle test, it seems to use the right compiler for my contracts, but seems unable to compile whatever Truffle is using to execute tests, if that makes sense. – Tim Beiko Mar 11 at 17:35
  • @goodvibration I've edited the original post to make the point above a bit clearer. – Tim Beiko Mar 11 at 17:39
  • 1
    @ZachLysobey I was able to deploy it on both my local ganache-cli network and Rinkeby, using Truffle using the same setup. Not sure if there is anything else I can check? – Tim Beiko Mar 11 at 22:05
1

It seems like this was a bug in Truffle. I opened an issue on their Github, and they have created a PR to address it. I will update this answer after having tried the updated truffle version.

0

I think you need change your compiler up to version: "0.5.0", or newer version (but older than 0.6.0), and make all your code compatible with that compiler version, if you need to use this DeployedAddresses.sol dynamically generated library (see this)

  • Thank you for the suggestion, but unfortunately this does not work, as I have some dependencies on Zeppelin contracts which use pragma 0.4.11 and I do not want to upgrade those, for obvious security reasons. It seems like this was a bug in Truffle. They are fixing it here: github.com/trufflesuite/truffle/pull/1820 – Tim Beiko Mar 16 at 13:59

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.