{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

module Test.Cardano.Ledger.State.StakePoolSpec (spec) where

import Cardano.Ledger.Coin
import Cardano.Ledger.State
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 -> ((PoolParams, CompactForm Coin) -> Property) -> Spec
forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"mkStakePoolState/stakePoolStateToPoolParams round-trip" (((PoolParams, CompactForm Coin) -> Property) -> Spec)
-> ((PoolParams, CompactForm Coin) -> Property) -> Spec
forall a b. (a -> b) -> a -> b
$
      \(PoolParams
poolParams :: PoolParams, CompactForm Coin
deposit :: CompactForm Coin) ->
        let poolId :: KeyHash 'StakePool
poolId = PoolParams -> KeyHash 'StakePool
ppId PoolParams
poolParams
            stakePoolState :: StakePoolState
stakePoolState = CompactForm Coin -> PoolParams -> StakePoolState
mkStakePoolState CompactForm Coin
deposit PoolParams
poolParams
            poolParams' :: PoolParams
poolParams' = KeyHash 'StakePool -> StakePoolState -> PoolParams
stakePoolStateToPoolParams KeyHash 'StakePool
poolId StakePoolState
stakePoolState
         in PoolParams
poolParams PoolParams -> PoolParams -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== PoolParams
poolParams'