[Ethereum] “Callback was already called” during truffle test using a solidity testfile

soliditytruffle-test

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

Best Answer

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.

Related Topic