Truffle: Error: Invalid number of arguments to Solidity function in tests still exists in 4.0.4

Created on 3 Jan 2018  路  2Comments  路  Source: trufflesuite/truffle

I was excited to see that this error was dealt with in the upgrade to 4.0.4. Unfortunately I'm still getting it. In the past I've managed to get rid of errors like this by removing the build directory and running
truffle migrate --reset --compile-all

This time it's not working. The contract code is very simple and so is the test:

function placePredictions(uint feedId, uint value) public {
        require(feedMaster.isValidFeed(feedId));

        if (predictions[feedId].length > 10000) {
                predictions[feedId].length = 0; 
        }

        Prediction memory prediction = Prediction({
            value:value,
            feedId:feedId,
            blocknumber: block.number,
            oracle: msg.sender
        });

        predictions[feedId].push(prediction);
    }

The test:

  await openPredictionsInstance.placePredictions(BTCUSDID, 1300, { from: accounts[2] });

By habit now I remove build directory and run the full compile migrate as above before running tests but no luck. I've scoured every stackOverflow and github issue with no luck so I'm assuming this is a continuation of the previous compile bug.

Most helpful comment

Yeah the ABI does not get updated with new contract code. The source map DOES get updated, but not the ABI.

All 2 comments

Yeah the ABI does not get updated with new contract code. The source map DOES get updated, but not the ABI.

Update: this error comes up when there's a type mismatch. Be careful when testing not to pass a string of an int when the contract expects a uint. In testing when I called placePredictions("0",12) I got the error incorrect number of arguments as opposed to something like "type mismatch". This might be a sign to me that I need to move my testing to typescript.

Was this page helpful?
0 / 5 - 0 ratings