1
votes

I have a contract developed using remix. After copying the contract over and writing mocha tests, I received the following error when running the deploy test:

Error: Invalid number of parameters for "undefined"

1) "before each" hook for "deploys a contract": Error: Invalid number of parameters for "undefined". Got 0 expected 1!

The constructor previously had used a parameter & I realized I had mistakenly left the variable type address as a parameter for the Test (contract) constructor which I didn't provide in the test. After removing the parameter (which isn't used in the constructor) the test passes.

function Test(address) public {...

It worked in remix (no errors/warnings) as I expected so I didn't catch it before copying the code over to an editor.

Does remix ignore bad parameters when it deploys a contract? Is there a way to catch this in remix?

1
TAG REQUEST: I noticed that there isn't a tag for 'remix', the Ethereum solidity IDE. Solidity is a valid tag but remix doesn't exist. The dedicated Ethereum exchange site has this tag but shouldn't it be available here as well for programming-related questions? A simple search for it shows there are enough questions to warrant one. There are tags for many IDEs & text editors but not one for remix. I don't have the rep or I'd create it myself.Don P

1 Answers

2
votes

Does remix ignore unused parameters when it deploys a contract?

Well, actually it gives you a warning when you left parameter unused:

warning

Warning: Unused function parameter. Remove or comment out the variable name to silence this warning. function demo(address _unused) public pure returns (uint8) {

But it seems that if you are only providing variable type without a name, then remix just ignores it:

no warning


Is there a way to catch this in remix?

It might be possible to catch such thing in the assembly if the value of the nameless variable was stored on stack, but this is pretty deep dive into how Solidity code is compiled and might not fit the purpose of just testing.