Open lukechampine opened 8 months ago
Hi @lukechampine i have raised a minor PR to increase coverage for update.go
and validate.go
, please review.
Here's a listing of the remaining uncovered code, with my suggestions on how to write a test for them:
storageProofRoot
(acc *ElementAccumulator) UnmarshalJSON
(acc *ElementAccumulator) containsChainIndex
(acc *ElementAccumulator) containsResolvedV2FileContractElement
(eau *elementApplyUpdate) updateElementProof
(eru *elementRevertUpdate) updateElementProof
(s State) MaxFutureTimestamp
(s State) BlockReward
InitialCoinbase != MinimumCoinbase
(s State) FoundationSubsidy
(s State) FileContractTax
(s State) StorageProofLeafIndex
(s State) StorageProofLeafHash
(s State) replayPrefix
WholeSigHash
at various heights and check that they do/do not match(ms *MidState) siacoinElement
(and similar)
(ts V1TransactionSupplement) storageProofWindowID
updateOakTime
updateOakTarget
adjustTarget
(ms *MidState) resolveFileContractElement
(ms *MidState) resolveV2FileContractElement
(ms *MidState) ApplyTransaction
(ms *MidState) ApplyV2Transaction
(ms *MidState) ApplyBlock
(ru RevertUpdate) UpdateElementProof
(ru RevertUpdate) ForEachFileContractElement
(ru RevertUpdate) ForEachV2FileContractElement
validateHeader
ValidateOrphan
validateSiacoins
validateSiafunds
validateFileContracts
validateArbitraryData
validateV2CurrencyValues
validateV2Siacoins
validateV2Siafunds
validateV2FileContracts
I know this seems like a lot, but many of them just need a trivial test case, and many others have substantial overlap (e.g. two good tests for v1 and v2 contracts would add a ton of coverage).
For absolute beginners/newcomers, I recommend starting with validateHeader
, ValidateOrphan
, or MaxFutureTimestamp
.
Even 100% coverage doesn't guarantee your code is bug-free, but it's certainly a great first step. Let's try to reach 100% coverage in
consensus
, testing every single edge case. :)Any increase in test coverage, even 1%, qualifies for our Hacktoberfest event, so don't be shy!