{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} module Test.Cardano.Ledger.State.StakePoolSpec (spec) where import Cardano.Ledger.BaseTypes (EpochNo) import Cardano.Ledger.Coin import Cardano.Ledger.Core import Cardano.Ledger.Credential (Credential) import Cardano.Ledger.State import Data.Set (Set) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.Arbitrary () spec :: Spec spec :: Spec spec = do String -> Spec -> Spec forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "StakePoolState" (Spec -> Spec) -> Spec -> Spec forall a b. (a -> b) -> a -> b $ do String -> ((StakePoolParams (ZonkAny 0), CompactForm Coin, Set (Credential Staking), EpochNo) -> Property) -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "mkStakePoolState/stakePoolStateToPoolParams round-trip" (((StakePoolParams (ZonkAny 0), CompactForm Coin, Set (Credential Staking), EpochNo) -> Property) -> Spec) -> ((StakePoolParams (ZonkAny 0), CompactForm Coin, Set (Credential Staking), EpochNo) -> Property) -> Spec forall a b. (a -> b) -> a -> b $ \( StakePoolParams (ZonkAny 0) stakePoolParams :: StakePoolParams era , CompactForm Coin deposit :: CompactForm Coin , Set (Credential Staking) delegs :: Set (Credential Staking) , EpochNo epochNo :: EpochNo ) -> let poolId :: KeyHash StakePool poolId = StakePoolParams (ZonkAny 0) -> KeyHash StakePool forall era. StakePoolParams era -> KeyHash StakePool sppId StakePoolParams (ZonkAny 0) stakePoolParams network :: Network network = AccountAddress -> Network aaNetworkId (AccountAddress -> Network) -> AccountAddress -> Network forall a b. (a -> b) -> a -> b $ StakePoolParams (ZonkAny 0) -> AccountAddress forall era. StakePoolParams era -> AccountAddress sppAccountAddress StakePoolParams (ZonkAny 0) stakePoolParams stakePoolState :: StakePoolState stakePoolState = EpochNo -> CompactForm Coin -> Set (Credential Staking) -> StakePoolParams (ZonkAny 0) -> StakePoolState forall era. EpochNo -> CompactForm Coin -> Set (Credential Staking) -> StakePoolParams era -> StakePoolState mkStakePoolState EpochNo epochNo CompactForm Coin deposit Set (Credential Staking) delegs StakePoolParams (ZonkAny 0) stakePoolParams stakePoolParams' :: StakePoolParams (ZonkAny 0) stakePoolParams' = Network -> KeyHash StakePool -> StakePoolState -> StakePoolParams (ZonkAny 0) forall era. Network -> KeyHash StakePool -> StakePoolState -> StakePoolParams era stakePoolStateToStakePoolParams Network network KeyHash StakePool poolId StakePoolState stakePoolState in StakePoolParams (ZonkAny 0) stakePoolParams StakePoolParams (ZonkAny 0) -> StakePoolParams (ZonkAny 0) -> Property forall a. (Eq a, Show a) => a -> a -> Property === StakePoolParams (ZonkAny 0) stakePoolParams'