starter-kit-gsn icon indicating copy to clipboard operation
starter-kit-gsn copied to clipboard

Error: Invalid number of parameters for "initialize". Got 2 expected 0!

Open leckylao opened this issue 5 years ago • 2 comments

image

Please correct me if I am wrong. As below shows, This error was caused by there's two initialize() functions and the test case was calling the one with 0 parameters.

image

And it can be fixed by renaming it e.g. rename initialize to initialise.

image

leckylao avatar Apr 02 '20 13:04 leckylao

Hi @leckylao! I’m sorry that you had this issue.

We have been able to reproduce this issue by following these steps: With truffle installed run the tests

$ npx truffle test
Using network 'development'.


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



  Contract: counter
Error: Invalid number of parameters for "initialize". Got 2 expected 0!
Error: Invalid number of parameters for "initialize". Got 2 expected 0!

Thanks so much for reporting it! The workaround is to change the call to initialize to specify the function being called:

    //counter.initialize(value, { from: owner });
    counter.methods['initialize(uint256)'](value, { from: owner });

abcoathup avatar Apr 03 '20 04:04 abcoathup

Thank you @abcoathup, that works.

leckylao avatar Apr 03 '20 05:04 leckylao