Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

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

Open
leckylao opened this issue Apr 2, 2020 · 2 comments
Open
Labels
bug Something isn't working

Comments

@leckylao
Copy link

leckylao commented Apr 2, 2020

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

@abcoathup
Copy link
Contributor

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 });

@leckylao
Copy link
Author

leckylao commented Apr 3, 2020

Thank you @abcoathup, that works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants