This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Test.Cardano.Chain.Slotting.Slotting | ||
( prop_mkSlottingData | ||
, prop_mkSlottingDataInvalidIndices | ||
, prop_mkSlottingDataTooFewIndices | ||
, prop_localSlotIndexToEnumOverflow | ||
, prop_localSlotIndexToEnumUnderflow | ||
) | ||
where | ||
|
||
import Cardano.Prelude | ||
import Test.Cardano.Prelude | ||
|
||
import Hedgehog (Property,withTests,property, forAll) | ||
import qualified Hedgehog.Gen as Gen | ||
import qualified Hedgehog.Range as Range | ||
|
||
import Cardano.Chain.Slotting (SlottingData, SlotCount (..), mkSlottingData, getSlottingDataMap, localSlotIndexToEnum, validateSlottingDataMap) | ||
|
||
import Test.Cardano.Chain.Slotting.Gen (genSlotCount, genSlottingData, genSlottingDataCustom, genSlottingDataInvalidIndicies,genSlottingDataTooFewIndicies) | ||
|
||
prop_mkSlottingData :: Property | ||
prop_mkSlottingData = eachOf 1000 (getSlottingDataMap <$> genSlottingData) (assertEitherIsRight mkSlottingData) | ||
|
||
prop_mkSlottingDataTooFewIndices :: Property | ||
prop_mkSlottingDataTooFewIndices = eachOf 10 (getSlottingDataMap <$> genSlottingDataTooFewIndicies) (assertEitherIsLeft validateSlottingDataMap) | ||
|
||
prop_mkSlottingDataInvalidIndices :: Property | ||
prop_mkSlottingDataInvalidIndices = eachOf 1000 (getSlottingDataMap <$> genSlottingDataInvalidIndicies) (assertEitherIsLeft validateSlottingDataMap) | ||
|
||
-------------------------------------------------------------------------------- | ||
-- LocalSlotIndex | ||
-------------------------------------------------------------------------------- | ||
|
||
prop_localSlotIndexToEnumOverflow :: Property | ||
prop_localSlotIndexToEnumOverflow = withTests 1000 . property $ do | ||
sc <- forAll genSlotCount | ||
let newSc = 1 + getSlotCount sc | ||
assertEitherIsLeft (localSlotIndexToEnum sc) (fromIntegral newSc) | ||
|
||
prop_localSlotIndexToEnumUnderflow :: Property | ||
prop_localSlotIndexToEnumUnderflow = withTests 1000 . property $ do | ||
tVal <- forAll (Gen.int (Range.constant (negate 1) minBound)) | ||
sc <- forAll genSlotCount | ||
assertEitherIsLeft (localSlotIndexToEnum sc) tVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters