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.
Move Ledger events CDDL conformance tests inside 'cddl' package.
This is hopefully temporary until I figure out why GHC can't compile cardano-node tests when relying on the 'cddl' package. At the moment, it panics with: ``` <command line>: dlopen([...]/dist-newstyle/build/aarch64-osx/ghc-8.10.7/cddl-1.0.0/build/libHScddl-1.0.0-inplace-ghc8.10.7.dylib, 0x0005): symbol not found in flat namespace '_CFRelease' ``` It could be similar to the issue describe here: yvan-sraka/cargo-cabal#2; and a possible work-around could be to build a dynamic library from Rust instead of static one.
- Loading branch information
1 parent
0dd222a
commit e2be704
Showing
4 changed files
with
47 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Cardano.Node.LedgerEventSpec where | ||
|
||
import Prelude | ||
|
||
import Cardano.Node.LedgerEvent | ||
import qualified Codec.CBOR.Schema as CDDL | ||
import qualified Data.ByteString.Base16 as Hex | ||
import Data.ByteString.Lazy (fromStrict) | ||
import Data.ByteString.Short (toShort) | ||
import Data.Text (Text) | ||
import qualified Data.Text.IO as TIO | ||
import Hedgehog (Property, discover, footnote, (===)) | ||
import qualified Hedgehog | ||
import qualified Hedgehog.Gen as Gen | ||
import qualified Hedgehog.Range as Range | ||
import System.IO.Unsafe (unsafePerformIO) | ||
import Test.Hspec (Spec, describe, specify) | ||
import Test.Hspec.Hedgehog (hedgehog) | ||
|
||
specification :: Text | ||
specification = | ||
unsafePerformIO $ TIO.readFile "../cardano-node/ledger_events.cddl" | ||
|
||
spec :: Spec | ||
spec = describe "Ledger Event CDDL" $ do | ||
specify "All events are compliant with their cddl definitions" $ hedgehog $ do | ||
version <- Hedgehog.forAll Gen.enumBounded | ||
event <- Hedgehog.forAll genEvent | ||
CDDL.validate specification (serializeAnchoredEvent version event) === Right () | ||
|
||
genEvent :: Hedgehog.Gen AnchoredEvent | ||
genEvent = | ||
AnchoredEvent | ||
<$> (toShort <$> Gen.bytes (Range.constant 32 32)) | ||
<*> (fromIntegral <$> Gen.word64 Range.constantBounded) | ||
<*> (LedgerNewEpochEvent . LedgerStartAtEpoch . fromIntegral <$> Gen.word16 Range.constantBounded) |