defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Mocking overloaded functions fails #98

Closed mariogutval closed 2 years ago

mariogutval commented 2 years ago

Describe the bug Mocking the returned value of a function fails when there is another function with the same name.

Reproduction steps

When you have two different functions like function myFunction(uint256 x) and function myFunction(uint256 x, address user) and you want to mock the returned value by using myContract.myFunction.returns(true), you get TypeError: Cannot read property 'returns' of undefined

Expected behavior It would be great that you could specify the signature of the function (including the arguments) whose returned value you want to mock.

System Specs:

alejoamiras commented 2 years ago

@mariogutval have you tried myContract['myFunction(signature)'].returns(true), thats how ethersjs in general works.

0xGorilla commented 2 years ago

This should work as @alejoamiras described. Closing this issue because of inactivity, reopen it if necessary.