{-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Test.Cardano.Ledger.Shelley.Binary.CddlSpec (spec) where import Cardano.Ledger.Address (Addr, RewardAccount) import Cardano.Ledger.Core import Cardano.Ledger.Crypto (StandardCrypto) import Cardano.Ledger.Keys (KeyRole (Staking)) import Cardano.Ledger.Keys.Bootstrap (BootstrapWitness) import Cardano.Ledger.PoolParams (StakePoolRelay) import Cardano.Ledger.Shelley (Shelley) import Cardano.Ledger.Shelley.API ( Credential, MultiSig, ProposedPPUpdates, Update, ) import Cardano.Ledger.TxIn (TxIn) import Test.Cardano.Ledger.Binary.Cddl ( beforeAllCddlFile, cddlRoundTripAnnCborSpec, cddlRoundTripCborSpec, ) import Test.Cardano.Ledger.Binary.Cuddle ( huddleRoundTripAnnCborSpec, huddleRoundTripCborSpec, specWithHuddle, ) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Shelley.Binary.Cddl (readShelleyCddlFiles) import qualified Test.Cardano.Ledger.Shelley.CDDL as ShelleyCDDL spec :: Spec spec :: Spec spec = do Spec newSpec forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "CDDL" forall a b. (a -> b) -> a -> b $ HasCallStack => Int -> IO [ByteString] -> SpecWith CddlData -> Spec beforeAllCddlFile Int 3 IO [ByteString] readShelleyCddlFiles forall a b. (a -> b) -> a -> b $ do let v :: Version v = forall era. Era era => Version eraProtVerLow @Shelley forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CddlData cddlRoundTripAnnCborSpec @(BootstrapWitness StandardCrypto) Version v Text "bootstrap_witness" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(Addr StandardCrypto) Version v Text "address" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(RewardAccount StandardCrypto) Version v Text "reward_account" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(Credential 'Staking StandardCrypto) Version v Text "stake_credential" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CddlData cddlRoundTripAnnCborSpec @(TxBody Shelley) Version v Text "transaction_body" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(TxOut Shelley) Version v Text "transaction_output" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @StakePoolRelay Version v Text "relay" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(TxCert Shelley) Version v Text "certificate" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(TxIn StandardCrypto) Version v Text "transaction_input" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CddlData cddlRoundTripAnnCborSpec @(TxAuxData Shelley) Version v Text "transaction_metadata" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CddlData cddlRoundTripAnnCborSpec @(MultiSig Shelley) Version v Text "multisig_script" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(Update Shelley) Version v Text "update" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(ProposedPPUpdates Shelley) Version v Text "proposed_protocol_parameter_updates" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CddlData cddlRoundTripCborSpec @(PParamsUpdate Shelley) Version v Text "protocol_param_update" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CddlData cddlRoundTripAnnCborSpec @(Tx Shelley) Version v Text "transaction" newSpec :: Spec newSpec :: Spec newSpec = forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "Huddle" forall a b. (a -> b) -> a -> b $ Huddle -> Int -> SpecWith CuddleData -> Spec specWithHuddle Huddle ShelleyCDDL.shelley Int 100 forall a b. (a -> b) -> a -> b $ do let v :: Version v = forall era. Era era => Version eraProtVerHigh @Shelley forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(Addr StandardCrypto) Version v Text "address" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(BootstrapWitness StandardCrypto) Version v Text "bootstrap_witness" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(RewardAccount StandardCrypto) Version v Text "reward_account" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(Credential 'Staking StandardCrypto) Version v Text "stake_credential" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(TxBody Shelley) Version v Text "transaction_body" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(TxOut Shelley) Version v Text "transaction_output" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @StakePoolRelay Version v Text "relay" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(TxCert Shelley) Version v Text "certificate" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(TxIn StandardCrypto) Version v Text "transaction_input" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(TxAuxData Shelley) Version v Text "transaction_metadata" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(MultiSig Shelley) Version v Text "multisig_script" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(Update Shelley) Version v Text "update" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(ProposedPPUpdates Shelley) Version v Text "proposed_protocol_parameter_updates" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR a) => Version -> Text -> SpecWith CuddleData huddleRoundTripCborSpec @(PParamsUpdate Shelley) Version v Text "protocol_param_update" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(Tx Shelley) Version v Text "transaction" forall a. (HasCallStack, Eq a, Show a, EncCBOR a, DecCBOR (Annotator a)) => Version -> Text -> SpecWith CuddleData huddleRoundTripAnnCborSpec @(TxWits Shelley) Version v Text "transaction_witness_set"