{-# LANGUAGE ScopedTypeVariables #-} module Test.Cardano.Ledger.StorableSpec (spec) where import Cardano.Ledger.Credential import Cardano.Ledger.Hashes import Cardano.Ledger.State import Foreign.Storable import Test.Cardano.Base.Properties (expectStorable) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.Arbitrary () spec :: Spec spec :: Spec spec = String -> Spec -> Spec forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "Storable" (Spec -> Spec) -> Spec -> Spec forall a b. (a -> b) -> a -> b $ do String -> ((KeyHash Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "KeyHash" (((KeyHash Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec) -> ((KeyHash Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall a b. (a -> b) -> a -> b $ \(KeyHash Witness hash :: KeyHash Witness, NonNegative Int offset, NonNegative Int slack) -> do KeyHash Witness -> Int forall a. Storable a => a -> Int sizeOf KeyHash Witness hash Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 28 KeyHash Witness -> Int forall a. Storable a => a -> Int alignment KeyHash Witness hash Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 32 KeyHash Witness -> NonNegative Int -> NonNegative Int -> IO () forall a. (Storable a, Show a, Eq a) => a -> NonNegative Int -> NonNegative Int -> IO () expectStorable KeyHash Witness hash NonNegative Int offset NonNegative Int slack String -> ((ScriptHash, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "ScriptHash" (((ScriptHash, NonNegative Int, NonNegative Int) -> IO ()) -> Spec) -> ((ScriptHash, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall a b. (a -> b) -> a -> b $ \(ScriptHash hash :: ScriptHash, NonNegative Int offset, NonNegative Int slack) -> do ScriptHash -> Int forall a. Storable a => a -> Int sizeOf ScriptHash hash Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 28 ScriptHash -> Int forall a. Storable a => a -> Int alignment ScriptHash hash Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 32 ScriptHash -> NonNegative Int -> NonNegative Int -> IO () forall a. (Storable a, Show a, Eq a) => a -> NonNegative Int -> NonNegative Int -> IO () expectStorable ScriptHash hash NonNegative Int offset NonNegative Int slack String -> ((Credential Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "Credential" (((Credential Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec) -> ((Credential Witness, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall a b. (a -> b) -> a -> b $ \(Credential Witness cred :: Credential Witness, NonNegative Int offset, NonNegative Int slack) -> do Credential Witness -> Int forall a. Storable a => a -> Int sizeOf Credential Witness cred Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 29 Credential Witness -> Int forall a. Storable a => a -> Int alignment Credential Witness cred Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 32 Credential Witness -> NonNegative Int -> NonNegative Int -> IO () forall a. (Storable a, Show a, Eq a) => a -> NonNegative Int -> NonNegative Int -> IO () expectStorable Credential Witness cred NonNegative Int offset NonNegative Int slack String -> ((StakeWithDelegation, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "StakeWithDelegation" (((StakeWithDelegation, NonNegative Int, NonNegative Int) -> IO ()) -> Spec) -> ((StakeWithDelegation, NonNegative Int, NonNegative Int) -> IO ()) -> Spec forall a b. (a -> b) -> a -> b $ \(StakeWithDelegation swd :: StakeWithDelegation, NonNegative Int offset, NonNegative Int slack) -> do StakeWithDelegation -> Int forall a. Storable a => a -> Int sizeOf StakeWithDelegation swd Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 36 StakeWithDelegation -> Int forall a. Storable a => a -> Int alignment StakeWithDelegation swd Int -> Int -> IO () forall a. (HasCallStack, Show a, Eq a) => a -> a -> IO () `shouldBe` Int 8 StakeWithDelegation -> NonNegative Int -> NonNegative Int -> IO () forall a. (Storable a, Show a, Eq a) => a -> NonNegative Int -> NonNegative Int -> IO () expectStorable StakeWithDelegation swd NonNegative Int offset NonNegative Int slack