Skip to content

Commit 36d94f9

Browse files
committed
Wire in ImpTest skeleton for Dijkstra era
1 parent b6ed6df commit 36d94f9

File tree

5 files changed

+101
-16
lines changed

5 files changed

+101
-16
lines changed

eras/dijkstra/cardano-ledger-dijkstra.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ library testlib
106106
Test.Cardano.Ledger.Dijkstra.Binary.Annotator
107107
Test.Cardano.Ledger.Dijkstra.Binary.RoundTrip
108108
Test.Cardano.Ledger.Dijkstra.Era
109+
Test.Cardano.Ledger.Dijkstra.Imp
109110
Test.Cardano.Ledger.Dijkstra.ImpTest
110111
Test.Cardano.Ledger.Dijkstra.TreeDiff
111112
Test.Cardano.Ledger.Dijkstra.TxInfoSpec
@@ -123,6 +124,8 @@ library testlib
123124

124125
build-depends:
125126
base,
127+
cardano-ledger-alonzo,
128+
cardano-ledger-babbage,
126129
cardano-ledger-binary,
127130
cardano-ledger-conway:{cardano-ledger-conway, testlib},
128131
cardano-ledger-core:{cardano-ledger-core, testlib},
@@ -152,7 +155,6 @@ test-suite tests
152155

153156
build-depends:
154157
base,
155-
cardano-ledger-conway:testlib,
156158
cardano-ledger-core:testlib,
157159
cardano-ledger-dijkstra:{cardano-ledger-dijkstra, testlib},
158160
cardano-ledger-shelley:testlib,

eras/dijkstra/test/Main.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ module Main where
55
import Cardano.Ledger.Dijkstra (DijkstraEra)
66
import Cardano.Ledger.Dijkstra.Rules ()
77
import Test.Cardano.Ledger.Common
8-
import qualified Test.Cardano.Ledger.Conway.Spec as ConwaySpec
98
import Test.Cardano.Ledger.Dijkstra.Binary.Annotator ()
109
import Test.Cardano.Ledger.Dijkstra.Binary.RoundTrip ()
10+
import qualified Test.Cardano.Ledger.Dijkstra.Imp as Imp
1111
import Test.Cardano.Ledger.Dijkstra.ImpTest ()
12+
import Test.Cardano.Ledger.Dijkstra.TxInfoSpec as TxInfo
1213
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
1314

1415
main :: IO ()
1516
main =
1617
ledgerTestMain $ do
17-
describe "Dijkstra" $ do
18-
ConwaySpec.spec @DijkstraEra
18+
describe "Dijkstra era-generic" $ do
19+
TxInfo.spec -- @DijkstraEra
20+
describe "Imp" $ do
21+
Imp.spec @DijkstraEra
22+
describe "Dijkstra era-specific" $ do
23+
-- TODO
24+
pure ()
1925
roundTripJsonShelleyEraSpec @DijkstraEra
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
{-# LANGUAGE UndecidableSuperClasses #-}
12
{-# OPTIONS_GHC -Wno-orphans #-}
23

3-
module Test.Cardano.Ledger.Dijkstra.Era () where
4+
module Test.Cardano.Ledger.Dijkstra.Era (
5+
module Test.Cardano.Ledger.Conway.Era,
6+
DijkstraEraTest,
7+
) where
48

59
import Cardano.Ledger.Dijkstra (DijkstraEra)
6-
import Test.Cardano.Ledger.Conway.Era (
7-
AllegraEraTest,
8-
AlonzoEraTest,
9-
BabbageEraTest,
10-
ConwayEraTest,
11-
EraTest,
12-
MaryEraTest,
13-
ShelleyEraTest,
14-
)
10+
import Test.Cardano.Ledger.Conway.Era
1511
import Test.Cardano.Ledger.Dijkstra.Arbitrary ()
1612
import Test.Cardano.Ledger.Dijkstra.TreeDiff ()
1713

14+
class
15+
ConwayEraTest era =>
16+
DijkstraEraTest era
17+
1818
instance EraTest DijkstraEra
1919

2020
instance ShelleyEraTest DijkstraEra
@@ -28,3 +28,5 @@ instance AlonzoEraTest DijkstraEra
2828
instance BabbageEraTest DijkstraEra
2929

3030
instance ConwayEraTest DijkstraEra
31+
32+
instance DijkstraEraTest DijkstraEra
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{-# LANGUAGE AllowAmbiguousTypes #-}
2+
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE FlexibleContexts #-}
4+
{-# LANGUAGE ScopedTypeVariables #-}
5+
{-# LANGUAGE TypeApplications #-}
6+
{-# LANGUAGE TypeOperators #-}
7+
8+
module Test.Cardano.Ledger.Dijkstra.Imp where
9+
10+
import Cardano.Ledger.Alonzo.Plutus.Context
11+
import Cardano.Ledger.Alonzo.Rules
12+
import Cardano.Ledger.Babbage.Rules
13+
import Cardano.Ledger.Babbage.TxInfo
14+
import Cardano.Ledger.BaseTypes
15+
import Cardano.Ledger.Conway.Rules
16+
import Cardano.Ledger.Conway.TxInfo
17+
import Cardano.Ledger.Dijkstra.Core
18+
import Cardano.Ledger.Plutus
19+
import Cardano.Ledger.Shelley.API
20+
import Cardano.Ledger.Shelley.Rules
21+
import Data.Typeable (Typeable)
22+
import Test.Cardano.Ledger.Common
23+
import Test.Cardano.Ledger.Conway.Imp as ConwayImp
24+
import Test.Cardano.Ledger.Dijkstra.ImpTest
25+
import Test.Cardano.Ledger.Imp.Common
26+
27+
spec ::
28+
forall era.
29+
( DijkstraEraImp era
30+
, EraPlutusTxInfo 'PlutusV2 era
31+
, Inject (BabbageContextError era) (ContextError era)
32+
, Inject (ConwayContextError era) (ContextError era)
33+
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
34+
, InjectRuleFailure "LEDGER" ConwayCertsPredFailure era
35+
, InjectRuleFailure "LEDGER" BabbageUtxoPredFailure era
36+
, InjectRuleFailure "LEDGER" BabbageUtxowPredFailure era
37+
, InjectRuleFailure "LEDGER" AlonzoUtxoPredFailure era
38+
, InjectRuleFailure "LEDGER" AlonzoUtxosPredFailure era
39+
, InjectRuleFailure "LEDGER" AlonzoUtxowPredFailure era
40+
, InjectRuleFailure "LEDGER" ShelleyDelegPredFailure era
41+
, InjectRuleFailure "LEDGER" ShelleyUtxoPredFailure era
42+
, InjectRuleFailure "LEDGER" ShelleyUtxowPredFailure era
43+
, InjectRuleFailure "LEDGER" ConwayDelegPredFailure era
44+
, InjectRuleFailure "LEDGER" ConwayGovCertPredFailure era
45+
, InjectRuleFailure "LEDGER" ConwayLedgerPredFailure era
46+
, InjectRuleFailure "LEDGER" ConwayUtxoPredFailure era
47+
, InjectRuleFailure "BBODY" ConwayBbodyPredFailure era
48+
, InjectRuleEvent "TICK" ConwayEpochEvent era
49+
, Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era
50+
, Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era
51+
, Event (EraRule "HARDFORK" era) ~ ConwayHardForkEvent era
52+
, ApplyTx era
53+
, NFData (Event (EraRule "ENACT" era))
54+
, ToExpr (Event (EraRule "ENACT" era))
55+
, Eq (Event (EraRule "ENACT" era))
56+
, Typeable (Event (EraRule "ENACT" era))
57+
) =>
58+
Spec
59+
spec = do
60+
ConwayImp.spec @era
61+
withImpInit @(LedgerSpec era) $ do
62+
-- TODO
63+
pure ()

eras/dijkstra/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
{-# LANGUAGE MultiParamTypeClasses #-}
33
{-# LANGUAGE TypeApplications #-}
44
{-# LANGUAGE TypeFamilies #-}
5+
{-# LANGUAGE UndecidableSuperClasses #-}
56
{-# OPTIONS_GHC -Wno-orphans #-}
67

7-
module Test.Cardano.Ledger.Dijkstra.ImpTest () where
8+
module Test.Cardano.Ledger.Dijkstra.ImpTest (
9+
module Test.Cardano.Ledger.Conway.ImpTest,
10+
DijkstraEraImp,
11+
) where
812

913
import Cardano.Ledger.BaseTypes (EpochInterval (..), addEpochInterval)
1014
import Cardano.Ledger.Conway.Governance (ConwayEraGov (..), committeeMembersL)
@@ -23,7 +27,7 @@ import Cardano.Ledger.Shelley.Rules (ShelleyDelegPredFailure)
2327
import qualified Cardano.Ledger.Shelley.Rules as Shelley
2428
import Lens.Micro ((%~), (&))
2529
import Test.Cardano.Ledger.Conway.ImpTest
26-
import Test.Cardano.Ledger.Dijkstra.Era ()
30+
import Test.Cardano.Ledger.Dijkstra.Era
2731

2832
instance ShelleyEraImp DijkstraEra where
2933
initGenesis = pure DijkstraGenesis
@@ -53,6 +57,14 @@ instance AlonzoEraImp DijkstraEra where
5357

5458
instance ConwayEraImp DijkstraEra
5559

60+
class
61+
( ConwayEraImp era
62+
, DijkstraEraTest era
63+
) =>
64+
DijkstraEraImp era
65+
66+
instance DijkstraEraImp DijkstraEra
67+
5668
-- Partial implementation used for checking predicate failures
5769
instance InjectRuleFailure "LEDGER" ShelleyDelegPredFailure DijkstraEra where
5870
injectFailure = ConwayCertsFailure . injectFailure

0 commit comments

Comments
 (0)