A contract with multiple events with the same name throws `decodeParameters` in Truffle

by Hardly Difficult   Last Updated March 18, 2019 21:28 PM

Question:

There is an issue open with Truffle, in the meantime is there a work-around or anything else we could try to unblock development? I'm hesitant to start wrapping our tests with try...catch blocks that just ignore the errors.

The issue:

When a contract has an event defined and attempts to make an external call to another contract which emits an event with the same name the Truffle test throws the following error:

Error: Returned values aren't valid, did it run Out of Gas?
    at ABICoder.decodeParameters (node_modules\truffle\build\webpack:\~\web3-eth-abi\src\index.js:226:1)
    at ABICoder.decodeParameter (node_modules\truffle\build\webpack:\~\web3-eth-abi\src\index.js:213:1)
    at node_modules\truffle\build\webpack:\~\web3-eth-abi\src\index.js:274:14
    at Array.forEach (<anonymous>)
    at ABICoder.decodeLog (node_modules\truffle\build\webpack:\~\web3-eth-abi\src\index.js:270:1)
    at node_modules\truffle\build\webpack:\packages\truffle-contract\lib\utils.js:60:1
    at Array.map (<anonymous>)
    at Function.decodeLogs (node_modules\truffle\build\webpack:\packages\truffle-contract\lib\utils.js:44:1)
    at Promise.receipt (node_modules\truffle\build\webpack:\packages\truffle-contract\lib\handlers.js:98:1)
    at Promise.emit (node_modules\truffle\build\webpack:\~\eventemitter3\index.js:89:1)
    at node_modules\truffle\build\webpack:\~\web3-eth\~\web3-core-method\src\index.js:353:1
    at process._tickCallback (internal/process/next_tick.js:68:7)

It seems you can try...catch the error and ignore it. The transaction does process successfully.

More specifically: we are creating a contract with implements ERC721. ERC721 has the following event:

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

Our contract then attempts to call transferFrom on an ERC20 token, which emits the following:

event Transfer(address indexed _from, address indexed _to, uint256 _value)

The issue occurs when that Transfer event is emitted.

How to repo:

We created a simple example on GitHub which includes a Travis CI build where you can see the error triggered by the test (in test/Test.js)

Additional context:

Turning off Ganache's auto-mine did not fix the issue. Switching to use the Web3 API to make the call results in the test hanging (instead of throwing an error). There's a bit more detail about these attempts in the example repo.

Also, can we even be sure this is an issue with Truffle vs maybe Ganache?



Related Questions


Updated May 17, 2019 15:28 PM

Updated September 10, 2018 16:28 PM

Updated March 31, 2018 21:28 PM

Updated February 20, 2019 12:28 PM

Updated April 23, 2018 10:28 AM