brownie
brownie copied to clipboard
Wrong test coverage of one specific method in coverage report
Environment information
-
brownie
Version: 1.7.0 - Python Version: 3.8.0
- OS: Ubuntu
What was wrong?
I have the simple initializer function
function initialize(
uint256 _overtimeWindow,
uint256 _auctionDuration,
uint256 _minStepNumerator,
uint256 _authorRoyaltyNumerator,
address _payableToken,
address _nft,
address _adminAddress,
address _treasury,
uint256 _feeTokenNumerator,
uint256 _feeETHNumerator
) external initializer {
require(
_adminAddress != address(0),
Errors.ZERO_ADDRESS
);
require(
_payableToken != address(0),
Errors.ZERO_ADDRESS
);
require(
_nft != address(0),
Errors.ZERO_ADDRESS
);
require(
_treasury != address(0),
Errors.ZERO_ADDRESS
);
_admin = _adminAddress;
payableToken = IERC20(_payableToken);
nft = IERC721(_nft);
treasury = _treasury;
setAuctionDuration(_auctionDuration);
setOvertimeWindow(_overtimeWindow);
setMinPriceStepNumerator(_minStepNumerator);
setAuthorRoyaltyNumerator(_authorRoyaltyNumerator);
setFeeTokenNumerator(_feeTokenNumerator);
setFeeETHNumerator(_feeETHNumerator);
}
I cover all the code and branches with my code
But I see in the report Auction.initialize - 50.0%
But in the coverage GUI I see that coverage and branches report are all GREEN:
All other methods in the contract are OK
It looks like coverage report in text gives me 50% instead of 100%
Also note that all setSomething(...) methods which are called from inside the initializer are also 100% covered
Auction.setAuctionDuration - 100.0%
Auction.setAuthorRoyaltyNumerator - 100.0%
Auction.setFeeETHNumerator - 100.0%
Auction.setFeeTokenNumerator - 100.0%
Auction.setMinPriceStepNumerator - 100.0%
Auction.setOvertimeWindow - 100.0%
Auction.setTreasury - 100.0%
Auction.initialize - 50.0%
It was gone after I remove initializer
modifier, but it still looks like a bug
Code coverage is definitely broken. Seeing similar and worse problems on Vyper.