2

I'm creating a contract/token which extends the openzeppelin ERC20.sol and Ownable.sol.

My contract has no own logic yet and looks like this:

pragma solidity ^0.5.2;

import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract OwnToken is Ownable, ERC20 {

    constructor() public {
    }
}

Compiling works as expected but when I try to run truffle test it fails and gives me:

Error: Callback was already called.
    at C:\Users\towo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\~\async\dist\async.js:966:1
    at C:\Users\towo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\~\async\dist\async.js:3885:1

The test I have is only a dummy and looks like this:

pragma solidity ^0.5.2;

import "truffle/Assert.sol";
import "../contracts/MoniToken.sol";
import "truffle/DeployedAddresses.sol";

contract TestOwnToken {

    function testDummy() public {
        OwnToken ownToken = new OwnToken();
        address expected = 0x1C8994b9A1802374579AF9d2312a6C2eF26A24F5;
        Assert.equal(ownToken.owner(), expected, "Error");
    }
}

When I exclude the solidity test and include an Javascript-test, everything works as expected which means, truffle test is running fine. The Javascript test does the same as the solidity version.

Regarding the error and the fact that a Javascript-test is running fine it seems this has something to do with async/await within the truffle-suite itself. Does anyone has any idea on this? Maybe I'm missing something? It looks like an truffle issue at the first glance.

EDIT: Deleted the code for the Javascript test since it is not relevant to the question as stated by @goodvibration

  • contract TestOwnToken looks irrelevant to your question, so you may want to remove that code snippet altogether. – goodvibration Apr 8 at 8:18
  • You deleted the wrong piece of code!!! – goodvibration Apr 8 at 12:20
  • Why? The Javascript-test is running and isn't necessary for my problem because it's related to the solidity-test. – Tobias Apr 8 at 12:29
  • The error occurs when you run your Truffle test, which no longer appears in your question. This Truffle test makes no use of contract TestOwnToken, which is therefore redundant in your question. – goodvibration Apr 8 at 12:41
  • I have met the same problem – Zainan Victor Zhou Jul 4 at 0:34
2

I had the same problem and I managed it as follows: https://github.com/trufflesuite/truffle/issues/2176

So just by manually deleting the build folder and creating it back again just running the test.

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.