defi-wonderland / smock

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

Request: Externalize internal functions #9

Closed wei3erHase closed 3 years ago

wei3erHase commented 3 years ago

It'd be amazing to have a way of externalizing the internal functions so that we avoid writing them down in for-test contracts.

ContractForTest is Contract {
    function myInternalFunction(){
        return _myInternalFunction()
    }
}

I understand that they would not be possible to get from the interface, but they should from the contract, and all of them should respond to _functionName.

Since they would be impossible to call with Contract._functionName() I'd say some naming could be Contract.internal_functionName()

0xGorilla commented 3 years ago

I believe that when using the returns functionality of fakes or mocks, there would be no need to call internal functions, instead, you could just pre-program the public function return value.

We can re-open this issue if we find a specific use case necessary. But I don't know if it is even possible 😁