Skip to content

Testing internal methods

gjgd edited this page Jul 24, 2018 · 2 revisions

Problem

In some contracts like ProviderPool.sol, methods like addProvider, removeProvider, updateProvider have internal visibility because they are only meant to be called by the main contract TransmuteDPOS.sol that will inherite those methods.

internal visibility means those methods aren't accessible in the contract's interface. However we still want to be able to call them with the web3js framework to be able to unit test them.

Solution

To solve that problem we used a TestProviderPool.sol that inherits from ProviderPool.sol except it has the same functions with public visibility:

function publicAddProvider(address _provider, uint _bondedAmount) public {
    addProvider(_provider, _bondedAmount);
}

Tests written for ProviderPool.sol are written using the TestProviderPool.sol contract in order to be able to access those public methods.

Clone this wiki locally