-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5063 from input-output-hk/newhoggy/improve-roundt…
…rip-functions-to-report-annotations-on-callsite Improve roundtrip functions to report annotations on callsite
- Loading branch information
Showing
5 changed files
with
26 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module Test.Hedgehog.Roundtrip.CBOR | ||
( roundtrip_CBOR | ||
, roundtrip_CDDL_Tx | ||
) where | ||
|
||
import Cardano.Api | ||
import Hedgehog (Gen, Property) | ||
|
||
import Data.Proxy (Proxy (..)) | ||
import Data.Typeable (typeRep) | ||
import GHC.Stack (HasCallStack) | ||
import qualified GHC.Stack as GHC | ||
import Hedgehog (Gen, Property) | ||
import qualified Hedgehog as H | ||
import qualified Hedgehog.Extras.Test.Base as H | ||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
roundtrip_CBOR | ||
:: (SerialiseAsCBOR a, Eq a, Show a) | ||
=> AsType a -> Gen a -> Property | ||
:: forall a. (SerialiseAsCBOR a, Eq a, Show a, HasCallStack) | ||
=> AsType a | ||
-> Gen a | ||
-> Property | ||
roundtrip_CBOR typeProxy gen = | ||
H.property $ do | ||
GHC.withFrozenCallStack $ H.noteShow_ $ typeRep $ Proxy @a | ||
val <- H.forAll gen | ||
H.tripping val serialiseToCBOR (deserialiseFromCBOR typeProxy) | ||
|
||
|
||
roundtrip_CDDL_Tx | ||
:: IsCardanoEra era => CardanoEra era -> Gen (Tx era) -> Property | ||
:: (IsCardanoEra era, HasCallStack) | ||
=> CardanoEra era | ||
-> Gen (Tx era) | ||
-> Property | ||
roundtrip_CDDL_Tx era gen = | ||
H.property $ do | ||
GHC.withFrozenCallStack $ H.noteShow_ era | ||
val <- H.forAll gen | ||
H.tripping val serialiseTxLedgerCddl (deserialiseTxLedgerCddl era) |
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