88{-# LANGUAGE TupleSections #-}
99{-# LANGUAGE TypeApplications #-}
1010
11- module Test.Cardano.Ledger.Conformance.Spec.Conway (
12- spec ,
13- genFromBundle ,
14- genFromBundle_ ,
15- ) where
11+ module Test.Cardano.Ledger.Conformance.Spec.Conway ( spec ) where
1612
17- import Cardano.Ledger.Core (EraRule )
18- import Constrained.API
19- import Control.Monad.Cont (ContT (.. ))
20- import Control.Monad.Trans (MonadTrans (.. ))
21- import Control.State.Transition.Extended (STS (.. ), TRC (.. ))
2213import Data.Map.Strict qualified as Map
23- import Test.Cardano.Ledger.Conformance (ExecSpecRule (.. ), ForAllExecTypes , testConformance )
2414import Test.Cardano.Ledger.Conformance.ExecSpecRule.Conway (ConwayCertExecContext (.. ))
2515import Test.Cardano.Ledger.Constrained.Conway (genUtxoExecContext )
2616import Test.Cardano.Ledger.Constrained.Conway.MiniTrace (
27- ConstrainedGeneratorBundle (.. ),
2817 ConwayCertGenContext (.. ),
2918 constrainedCert ,
3019 constrainedCerts ,
@@ -37,79 +26,8 @@ import Test.Cardano.Ledger.Constrained.Conway.MiniTrace (
3726 constrainedRatify ,
3827 constrainedUtxo ,
3928 )
40- import Test.Cardano.Ledger.Conway.ImpTest (ImpTestM , impAnn )
4129import Test.Cardano.Ledger.Imp.Common
42- import UnliftIO (MonadIO (.. ), evaluateDeep )
43-
44- conformsToImpl ::
45- forall rule era .
46- ExecSpecRule rule era =>
47- Gen (ExecContext rule era , TRC (EraRule rule era )) ->
48- Property
49- conformsToImpl genInputs = property @ (ImpTestM era Property ) . (`runContT` pure ) $ do
50- let
51- deepEvalAnn s = " Deep evaluating " <> s
52- deepEval x s = do
53- _ <- lift $ impAnn (deepEvalAnn s) (liftIO (evaluateDeep x))
54- pure ()
55- (ctx, trc@ (TRC (env, st, sig))) <- lift $ liftGen genInputs
56- deepEval ctx " context"
57- deepEval env " environment"
58- deepEval st " state"
59- deepEval sig " signal"
60- pure $ testConformance @ rule @ era ctx trc
61-
62- genFromBundle_ ::
63- ( HasSpec (Environment (EraRule rule era ))
64- , HasSpec (State (EraRule rule era ))
65- , HasSpec (Signal (EraRule rule era ))
66- , Arbitrary (ExecContext rule era )
67- ) =>
68- ConstrainedGeneratorBundle ctx rule era ->
69- Gen (ExecContext rule era , TRC (EraRule rule era ))
70- genFromBundle_ x = genFromBundle x $ \ _ _ _ _ -> arbitrary
71-
72- genFromBundle ::
73- ForAllExecTypes HasSpec rule era =>
74- ConstrainedGeneratorBundle ctx rule era ->
75- ( ctx ->
76- Environment (EraRule rule era ) ->
77- State (EraRule rule era ) ->
78- Signal (EraRule rule era ) ->
79- Gen (ExecContext rule era )
80- ) ->
81- Gen (ExecContext rule era , TRC (EraRule rule era ))
82- genFromBundle ConstrainedGeneratorBundle {.. } genExecContext = do
83- ctx <- cgbContextGen
84- env <- genFromSpec $ cgbEnvironmentSpec ctx
85- st <- genFromSpec $ cgbStateSpec ctx env
86- sig <- genFromSpec $ cgbSignalSpec ctx env st
87- (,TRC (env, st, sig)) <$> genExecContext ctx env st sig
88-
89- conformsToImplConstrained ::
90- forall ctx rule era .
91- ( ExecSpecRule rule era
92- , ForAllExecTypes HasSpec rule era
93- ) =>
94- ConstrainedGeneratorBundle ctx rule era ->
95- ( ctx ->
96- Environment (EraRule rule era ) ->
97- State (EraRule rule era ) ->
98- Signal (EraRule rule era ) ->
99- Gen (ExecContext rule era )
100- ) ->
101- Property
102- conformsToImplConstrained bundle genExecContext =
103- conformsToImpl @ rule @ era $ genFromBundle bundle genExecContext
104-
105- conformsToImplConstrained_ ::
106- ( ExecSpecRule rule era
107- , ForAllExecTypes HasSpec rule era
108- , Arbitrary (ExecContext rule era )
109- ) =>
110- ConstrainedGeneratorBundle ctx rule era ->
111- Property
112- conformsToImplConstrained_ bundle = conformsToImplConstrained bundle $ \ _ _ _ _ -> arbitrary
30+ import Test.Cardano.Ledger.Conformance.Spec.Core
11331
11432spec :: Spec
11533spec = do
0 commit comments