Skip to content

Commit d90eb4d

Browse files
authored
Merge pull request #5002 from IntersectMBO/ldan/eratest-classes
Add `EraTest` classes
2 parents abe3004 + f78ab9f commit d90eb4d

File tree

39 files changed

+321
-72
lines changed

39 files changed

+321
-72
lines changed

eras/allegra/impl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* Deprecate `TimelockConstr`
1111
* Rename `atbrTxFee` to `atbrFee` for consistency
1212

13+
### `testlib`
14+
15+
* Added `Era` module with `AllegraEraTest` class
16+
1317
## 1.7.0.0
1418

1519
* Add `DecCBOR` instances for:

eras/allegra/impl/cardano-ledger-allegra.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ library testlib
8989
Test.Cardano.Ledger.Allegra.Binary.Annotator
9090
Test.Cardano.Ledger.Allegra.Binary.Cddl
9191
Test.Cardano.Ledger.Allegra.CDDL
92+
Test.Cardano.Ledger.Allegra.Era
9293
Test.Cardano.Ledger.Allegra.Imp
9394
Test.Cardano.Ledger.Allegra.Imp.UtxowSpec
9495
Test.Cardano.Ledger.Allegra.ImpTest
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{-# LANGUAGE UndecidableSuperClasses #-}
2+
{-# OPTIONS_GHC -Wno-orphans #-}
3+
4+
module Test.Cardano.Ledger.Allegra.Era (
5+
module Test.Cardano.Ledger.Shelley.Era,
6+
AllegraEraTest,
7+
) where
8+
9+
import Cardano.Ledger.Allegra
10+
import Cardano.Ledger.Allegra.Core
11+
import Cardano.Ledger.Allegra.Scripts
12+
import Test.Cardano.Ledger.Allegra.Arbitrary ()
13+
import Test.Cardano.Ledger.Allegra.TreeDiff ()
14+
import Test.Cardano.Ledger.Era
15+
import Test.Cardano.Ledger.Shelley.Era
16+
17+
class
18+
( ShelleyEraTest era
19+
, AllegraEraTxBody era
20+
, AllegraEraTxAuxData era
21+
, AllegraEraScript era
22+
) =>
23+
AllegraEraTest era
24+
25+
instance EraTest AllegraEra
26+
27+
instance ShelleyEraTest AllegraEra
28+
29+
instance AllegraEraTest AllegraEra

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import Test.Cardano.Ledger.Shelley.ImpTest
1616

1717
spec ::
1818
forall era.
19-
( Arbitrary (TxAuxData era)
20-
, ShelleyEraImp era
19+
( ShelleyEraImp era
2120
, InjectRuleFailure "LEDGER" ShelleyUtxoPredFailure era
2221
, InjectRuleFailure "LEDGER" ShelleyUtxowPredFailure era
2322
) =>

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import qualified Data.Map.Strict as Map
3131
import Data.Sequence.Strict (StrictSeq (..))
3232
import qualified Data.Set as Set
3333
import Lens.Micro ((^.))
34+
import Test.Cardano.Ledger.Allegra.Era ()
3435
import Test.Cardano.Ledger.Allegra.TreeDiff ()
3536
import Test.Cardano.Ledger.Core.KeyPair (KeyPair)
3637
import Test.Cardano.Ledger.Shelley.ImpTest

eras/alonzo/impl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* Deprecate `TxDats'` and `AlonzoTxWits'`
1515
* Deprecate `txwitsVKey'`, `txwitsBoot'`, `txscripts'`, `txdats'` and `txrdmrs'`
1616

17+
### `testlib`
18+
19+
* Added `Era` module with `AlonzoEraTest` class
20+
1721
## 1.13.0.0
1822

1923
* Add `DecCBOR` instances for:

eras/alonzo/impl/cardano-ledger-alonzo.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ library testlib
114114
Test.Cardano.Ledger.Alonzo.Binary.RoundTrip
115115
Test.Cardano.Ledger.Alonzo.Binary.TxWitsSpec
116116
Test.Cardano.Ledger.Alonzo.CDDL
117+
Test.Cardano.Ledger.Alonzo.Era
117118
Test.Cardano.Ledger.Alonzo.Imp
118119
Test.Cardano.Ledger.Alonzo.Imp.UtxoSpec
119120
Test.Cardano.Ledger.Alonzo.Imp.UtxosSpec
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{-# LANGUAGE FlexibleContexts #-}
2+
{-# LANGUAGE TypeFamilies #-}
3+
{-# LANGUAGE TypeOperators #-}
4+
{-# LANGUAGE UndecidableSuperClasses #-}
5+
{-# OPTIONS_GHC -Wno-orphans #-}
6+
7+
module Test.Cardano.Ledger.Alonzo.Era (
8+
module Test.Cardano.Ledger.Mary.Era,
9+
AlonzoEraTest,
10+
) where
11+
12+
import Cardano.Ledger.Alonzo
13+
import Cardano.Ledger.Alonzo.Core
14+
import Cardano.Ledger.Alonzo.Plutus.Context
15+
import Cardano.Ledger.Alonzo.Scripts ()
16+
import Cardano.Ledger.Alonzo.UTxO
17+
import Data.TreeDiff
18+
import Test.Cardano.Ledger.Alonzo.Arbitrary ()
19+
import Test.Cardano.Ledger.Alonzo.TreeDiff ()
20+
import Test.Cardano.Ledger.Mary.Era
21+
22+
class
23+
( MaryEraTest era
24+
, EraPlutusContext era
25+
, AlonzoEraTx era
26+
, AlonzoEraTxAuxData era
27+
, AlonzoEraUTxO era
28+
, ToExpr (PlutusScript era)
29+
, Script era ~ AlonzoScript era
30+
) =>
31+
AlonzoEraTest era
32+
33+
instance EraTest AlonzoEra
34+
35+
instance ShelleyEraTest AlonzoEra
36+
37+
instance AllegraEraTest AlonzoEra
38+
39+
instance MaryEraTest AlonzoEra
40+
41+
instance AlonzoEraTest AlonzoEra

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import qualified Test.Cardano.Ledger.Mary.Imp as MaryImp
2727

2828
spec ::
2929
forall era.
30-
( Arbitrary (TxAuxData era)
31-
, AlonzoEraImp era
30+
( AlonzoEraImp era
3231
, InjectRuleFailure "LEDGER" ShelleyDelegPredFailure era
3332
, InjectRuleFailure "LEDGER" ShelleyUtxoPredFailure era
3433
, InjectRuleFailure "LEDGER" ShelleyUtxowPredFailure era

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/ImpTest.hs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import Cardano.Ledger.Alonzo (AlonzoEra)
4646
import Cardano.Ledger.Alonzo.Core
4747
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..))
4848
import Cardano.Ledger.Alonzo.PParams (getLanguageView)
49-
import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusContext)
5049
import Cardano.Ledger.Alonzo.Plutus.Evaluate (
5150
collectPlutusScriptsWithContext,
5251
evalPlutusScriptsWithLogs,
@@ -61,7 +60,7 @@ import Cardano.Ledger.Alonzo.Scripts (plutusScriptLanguage, toAsItem, toAsIx)
6160
import Cardano.Ledger.Alonzo.Tx (IsValid (..), hashScriptIntegrity)
6261
import Cardano.Ledger.Alonzo.TxAuxData (AlonzoTxAuxData)
6362
import Cardano.Ledger.Alonzo.TxWits (unRedeemersL, unTxDatsL)
64-
import Cardano.Ledger.Alonzo.UTxO (AlonzoEraUTxO (..), AlonzoScriptsNeeded (..))
63+
import Cardano.Ledger.Alonzo.UTxO (AlonzoScriptsNeeded (..))
6564
import Cardano.Ledger.BaseTypes (Globals (..), StrictMaybe (..))
6665
import Cardano.Ledger.Coin (Coin (..))
6766
import Cardano.Ledger.Credential (Credential (..))
@@ -97,6 +96,7 @@ import qualified Data.Set as Set
9796
import Lens.Micro
9897
import Lens.Micro.Mtl (use)
9998
import qualified PlutusLedgerApi.Common as P
99+
import Test.Cardano.Ledger.Alonzo.Era
100100
import Test.Cardano.Ledger.Alonzo.TreeDiff ()
101101
import Test.Cardano.Ledger.Core.Arbitrary ()
102102
import Test.Cardano.Ledger.Core.Rational ((%!))
@@ -112,11 +112,7 @@ import Test.Cardano.Ledger.Plutus.Guardrail (guardrailScript)
112112

113113
class
114114
( MaryEraImp era
115-
, AlonzoEraScript era
116-
, AlonzoEraTxWits era
117-
, AlonzoEraTx era
118-
, AlonzoEraUTxO era
119-
, EraPlutusContext era
115+
, AlonzoEraTest era
120116
, ScriptsNeeded era ~ AlonzoScriptsNeeded era
121117
, TxAuxData era ~ AlonzoTxAuxData era
122118
) =>
@@ -440,7 +436,7 @@ instance ShelleyEraImp AlonzoEra where
440436

441437
instance MaryEraImp AlonzoEra
442438

443-
instance MaryEraImp AlonzoEra => AlonzoEraImp AlonzoEra where
439+
instance AlonzoEraImp AlonzoEra where
444440
scriptTestContexts = plutusTestScripts SPlutusV1
445441

446442
impLookupScriptContext ::

0 commit comments

Comments
 (0)