{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE BinaryLiterals #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.PlutusSpec (spec) where import Cardano.Ledger.BaseTypes ( EpochInterval (..), NonNegativeInterval, ProtVer (..), UnitInterval, ) import Cardano.Ledger.Binary.Version (Version) import Cardano.Ledger.Coin (Coin) import Cardano.Ledger.Plutus import Data.Map.Strict (Map) import Data.Word import Numeric.Natural (Natural) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.Arbitrary () import Test.Cardano.Ledger.Plutus.ToPlutusData (roundTripPlutusDataSpec) spec :: Spec spec :: Spec spec = do Spec costModelsSpec forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "roundtrip ToPlutusData" forall a b. (a -> b) -> a -> b $ do forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Version forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Word forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Word8 forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Word16 forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Word32 forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @[Word] forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @[Word8] forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @(Map Word Version) forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Coin forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @ExUnits forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Prices forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Natural forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @UnitInterval forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @EpochInterval forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @NonNegativeInterval forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @ProtVer forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @CostModels forall x. (HasCallStack, Typeable x, Show x, Eq x, Arbitrary x, ToPlutusData x) => Spec roundTripPlutusDataSpec @Integer costModelsSpec :: Spec costModelsSpec :: Spec costModelsSpec = do forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "CostModels" forall a b. (a -> b) -> a -> b $ do forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "flattenCostModels . mkCostModelsLenient" forall a b. (a -> b) -> a -> b $ \CostModels valid Map Word8 [Int64] unknown -> do let cms1Flat :: Map Word8 [Int64] cms1Flat = CostModels -> Map Word8 [Int64] flattenCostModels CostModels valid forall a. Semigroup a => a -> a -> a <> Map Word8 [Int64] unknown cms2Flat :: Map Word8 [Int64] cms2Flat = Map Word8 [Int64] unknown forall a. Semigroup a => a -> a -> a <> CostModels -> Map Word8 [Int64] flattenCostModels CostModels valid CostModels cms1 <- forall (m :: * -> *). MonadFail m => Map Word8 [Int64] -> m CostModels mkCostModelsLenient Map Word8 [Int64] cms1Flat CostModels cms2 <- forall (m :: * -> *). MonadFail m => Map Word8 [Int64] -> m CostModels mkCostModelsLenient Map Word8 [Int64] cms2Flat CostModels -> Map Word8 [Int64] flattenCostModels CostModels cms1 forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Map Word8 [Int64] cms1Flat CostModels -> Map Word8 [Int64] flattenCostModels CostModels cms2 forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Map Word8 [Int64] cms2Flat