forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (failing) property for serialisation roundtrip of events
- Loading branch information
1 parent
b5624e3
commit 55c3753
Showing
4 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Test.Cardano.Node.LedgerEvent where | ||
|
||
import Cardano.Node.LedgerEvent | ||
import Data.ByteString.Short(toShort) | ||
import Hedgehog (Property, discover) | ||
import qualified Hedgehog | ||
import qualified Hedgehog.Gen as Gen | ||
import qualified Hedgehog.Range as Range | ||
|
||
|
||
prop_roundtrip_LedgerEvent_CBOR :: Property | ||
prop_roundtrip_LedgerEvent_CBOR = | ||
Hedgehog.property $ do | ||
event <- Hedgehog.forAll genEvent | ||
Hedgehog.tripping event (serializeEvent maxBound) (deserializeEvent maxBound) | ||
|
||
genEvent :: Hedgehog.Gen AnchoredEvent | ||
genEvent = | ||
AnchoredEvent | ||
<$> (toShort <$> Gen.bytes (Range.constant 16 16)) | ||
<*> (fromIntegral <$> Gen.word64 Range.constantBounded) | ||
<*> (LedgerStartAtEpoch . fromIntegral <$> Gen.word16 Range.constantBounded) | ||
|
||
tests :: IO Bool | ||
tests = | ||
Hedgehog.checkParallel $$discover |
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