{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Cardano.Ledger.Conformance.ExecSpecRule.Conway.Ledgers () where
import Cardano.Ledger.Binary (EncCBOR (encCBOR))
import Cardano.Ledger.Conway (ConwayEra)
import Cardano.Ledger.Conway.Governance (EnactState)
import Cardano.Ledger.MempoolTx.Internal (MempoolTx (UnsafeMkMempoolTx))
import Control.State.Transition.Extended (TRC (..))
import qualified MAlonzo.Code.Ledger.Conway.Foreign.API as Agda
import Test.Cardano.Ledger.Conformance.ExecSpecRule.Base (
externalFunctions,
)
import Test.Cardano.Ledger.Conformance.ExecSpecRule.Core (
ExecSpecRule (..),
SpecTRC (..),
runFromAgdaFunction,
)
import Test.Cardano.Ledger.Conformance.SpecTranslate.Base (
SpecTranslate (..),
withCtxSpecTransM,
)
import Test.Cardano.Ledger.Conformance.SpecTranslate.Conway ()
import Test.Cardano.Ledger.Conway.ImpTest ()
instance ExecSpecRule "LEDGERS" ConwayEra where
type ExecContext "LEDGERS" ConwayEra = EnactState ConwayEra
encodeSignal :: Signal (EraRule "LEDGERS" ConwayEra) -> Encoding
encodeSignal = Seq (MempoolTx ConwayEra) -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR (Seq (MempoolTx ConwayEra) -> Encoding)
-> (Seq (Tx TopTx ConwayEra) -> Seq (MempoolTx ConwayEra))
-> Seq (Tx TopTx ConwayEra)
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tx TopTx ConwayEra -> MempoolTx ConwayEra)
-> Seq (Tx TopTx ConwayEra) -> Seq (MempoolTx ConwayEra)
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tx TopTx ConwayEra -> MempoolTx ConwayEra
forall era. Tx TopTx era -> MempoolTx era
UnsafeMkMempoolTx
translateInputs :: HasCallStack =>
TRC (EraRule "LEDGERS" ConwayEra)
-> SpecTransM
ConwayEra
(ExecContext "LEDGERS" ConwayEra)
(SpecTRC "LEDGERS" ConwayEra)
translateInputs (TRC (Environment (EraRule "LEDGERS" ConwayEra)
env, State (EraRule "LEDGERS" ConwayEra)
st, Signal (EraRule "LEDGERS" ConwayEra)
sig)) = do
agdaEnv <- ShelleyLedgersEnv ConwayEra
-> SpecTransM
ConwayEra
(SpecContext ConwayEra (ShelleyLedgersEnv ConwayEra))
(SpecRep ConwayEra (ShelleyLedgersEnv ConwayEra))
forall era a.
SpecTranslate era a =>
a -> SpecTransM era (SpecContext era a) (SpecRep era a)
toSpecRep ShelleyLedgersEnv ConwayEra
Environment (EraRule "LEDGERS" ConwayEra)
env
agdaSt <- withCtxSpecTransM () $ toSpecRep st
agdaSig <- withCtxSpecTransM () $ toSpecRep sig
pure $ SpecTRC agdaEnv agdaSt agdaSig
runAgdaRule :: HasCallStack =>
SpecTRC "LEDGERS" ConwayEra
-> Either Text (SpecState "LEDGERS" ConwayEra)
runAgdaRule = (SpecEnvironment "LEDGERS" ConwayEra
-> SpecState "LEDGERS" ConwayEra
-> SpecSignal "LEDGERS" ConwayEra
-> ComputationResult Text (SpecState "LEDGERS" ConwayEra))
-> SpecTRC "LEDGERS" ConwayEra
-> Either Text (SpecState "LEDGERS" ConwayEra)
forall (rule :: Symbol) era.
(SpecEnvironment rule era
-> SpecState rule era
-> SpecSignal rule era
-> ComputationResult Text (SpecState rule era))
-> SpecTRC rule era -> Either Text (SpecState rule era)
runFromAgdaFunction (T_ExternalFunctions_8
-> LEnv -> LState -> [Tx] -> T_HSComputationResult_116 Text LState
Agda.ledgersStep T_ExternalFunctions_8
externalFunctions)