Reputation: 4202
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?
Upvotes: 1
Views: 1177
Reputation: 1008
Does remix ignore unused parameters when it deploys a contract?
Well, actually it gives you a warning when you left parameter unused:
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:
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.
Upvotes: 2