diff --git a/eras/allegra/impl/CHANGELOG.md b/eras/allegra/impl/CHANGELOG.md index b564ddba483..8d200f0bd16 100644 --- a/eras/allegra/impl/CHANGELOG.md +++ b/eras/allegra/impl/CHANGELOG.md @@ -14,6 +14,7 @@ ### `testlib` +* Make `Test.Cardano.Ledger.Allegra.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Allegra.Examples`: - Remove `mkAllegraBasedExampleTx`, `exampleAllegraBasedTxBody`, `exampleAllegraBasedShelleyTxBody` - Add `exampleAllegraBasedTx` diff --git a/eras/allegra/impl/test/Main.hs b/eras/allegra/impl/test/Main.hs index 69e71417db6..05dcd8e2591 100644 --- a/eras/allegra/impl/test/Main.hs +++ b/eras/allegra/impl/test/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where @@ -8,18 +9,21 @@ import qualified Test.Cardano.Ledger.Allegra.Binary.Golden as Golden import qualified Test.Cardano.Ledger.Allegra.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Allegra.Imp as Imp import Test.Cardano.Ledger.Allegra.ImpTest () -import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec) +import Test.Cardano.Ledger.Era +import qualified Test.Cardano.Ledger.Shelley.Imp as Imp (shelleyEraSpecificSpec) import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec AllegraEra where + eraImpSpec era = do + Imp.shelleyEraSpecificSpec era + Imp.spec era + main :: IO () main = - ledgerTestMain $ - describe "Allegra" $ do - BinarySpec.spec - CddlSpec.spec - describe "Imp" $ do - Imp.spec @AllegraEra - roundTripJsonEraSpec @AllegraEra - roundTripJsonShelleyEraSpec @AllegraEra - Golden.spec @AllegraEra + ledgerEraTestMain @AllegraEra $ do + BinarySpec.spec + CddlSpec.spec + roundTripJsonEraSpec @AllegraEra + roundTripJsonShelleyEraSpec @AllegraEra + Golden.spec @AllegraEra diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs index efc44def7f7..8345836a408 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs @@ -1,30 +1,23 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Allegra.Imp (spec) where -import Cardano.Ledger.Allegra (AllegraEra) import Cardano.Ledger.Core import Cardano.Ledger.Shelley.Rules import Test.Cardano.Ledger.Allegra.ImpTest import Test.Cardano.Ledger.Imp.Common -import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp +import qualified Test.Cardano.Ledger.Shelley.Imp as Shelley spec :: - forall era. ( ShelleyEraImp era - , EraSpecificSpec era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - ShelleyImp.spec @era - -instance EraSpecificSpec AllegraEra where - eraSpecificSpec = ShelleyImp.shelleyEraSpecificSpec +spec era = do + Shelley.spec era + describe "AllegraEra Onwards" $ pure () diff --git a/eras/alonzo/impl/CHANGELOG.md b/eras/alonzo/impl/CHANGELOG.md index 9ce79b82842..084277c706d 100644 --- a/eras/alonzo/impl/CHANGELOG.md +++ b/eras/alonzo/impl/CHANGELOG.md @@ -44,6 +44,8 @@ ### `testlib` +* Add `proxy era` argument to `alonzoEraSpecificSpec` +* Make `Test.Cardano.Ledger.Alonzo.Imp.spec` accept `Proxy era` * Add `genDatumPresent` * Added `Proxy era` argument to `exUnitsRule` * `TranslationInstance` has a new field `tiPlutusPurpose` diff --git a/eras/alonzo/impl/cardano-ledger-alonzo.cabal b/eras/alonzo/impl/cardano-ledger-alonzo.cabal index 895417ce352..7b47fc744dd 100644 --- a/eras/alonzo/impl/cardano-ledger-alonzo.cabal +++ b/eras/alonzo/impl/cardano-ledger-alonzo.cabal @@ -98,7 +98,7 @@ library cardano-ledger-allegra ^>=1.10, cardano-ledger-binary ^>=1.9, cardano-ledger-core:{cardano-ledger-core, internal} ^>=1.21, - cardano-ledger-mary ^>=1.10.1, + cardano-ledger-mary ^>=1.11, cardano-ledger-shelley ^>=1.19, cardano-slotting, cardano-strict-containers, diff --git a/eras/alonzo/impl/test/Main.hs b/eras/alonzo/impl/test/Main.hs index 26965346028..f4aec8ba30d 100644 --- a/eras/alonzo/impl/test/Main.hs +++ b/eras/alonzo/impl/test/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where @@ -11,27 +12,32 @@ import qualified Test.Cardano.Ledger.Alonzo.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as Golden import qualified Test.Cardano.Ledger.Alonzo.GoldenTranslation as GoldenTranslation import qualified Test.Cardano.Ledger.Alonzo.Imp as Imp -import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfoImp +import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfo import Test.Cardano.Ledger.Alonzo.ImpTest () import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec) +import Test.Cardano.Ledger.Era +import qualified Test.Cardano.Ledger.Shelley.Imp as Shelley import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec AlonzoEra where + eraImpSpec era = do + Shelley.shelleyEraSpecificSpec era + Imp.alonzoEraSpecificSpec era + Imp.spec era + main :: IO () main = - ledgerTestMain $ - describe "Alonzo" $ do - BinarySpec.spec - Canonical.spec - CddlSpec.spec - roundTripJsonEraSpec @AlonzoEra - roundTripJsonShelleyEraSpec @AlonzoEra - GoldenTranslation.tests - Golden.spec - describe "Imp" $ do - Imp.spec @AlonzoEra - describe "CostModels" $ do - CostModelsSpec.spec @AlonzoEra - describe "TxWits" $ do - TxWitsSpec.spec @AlonzoEra - TxInfoImp.spec + ledgerEraTestMain @AlonzoEra $ do + BinarySpec.spec + Canonical.spec + CddlSpec.spec + roundTripJsonEraSpec @AlonzoEra + roundTripJsonShelleyEraSpec @AlonzoEra + GoldenTranslation.tests + Golden.spec + describe "CostModels" $ do + CostModelsSpec.spec @AlonzoEra + describe "TxWits" $ do + TxWitsSpec.spec @AlonzoEra + TxInfo.spec diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp.hs index e45ffcd094b..e3ee8d04690 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp.hs @@ -1,51 +1,39 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Alonzo.Imp where -import Cardano.Ledger.Alonzo (AlonzoEra) import Cardano.Ledger.Core import Cardano.Ledger.Shelley.Core (ShelleyEraTxCert) import Cardano.Ledger.Shelley.Rules -import qualified Test.Cardano.Ledger.Alonzo.Imp.BbodySpec as Bbody -import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxoSpec as Utxo -import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxosSpec as Utxos -import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec as Utxow +import qualified Test.Cardano.Ledger.Alonzo.Imp.BbodySpec as BBODY +import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxoSpec as UTXO +import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxosSpec as UTXOS +import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec as UTXOW import Test.Cardano.Ledger.Alonzo.ImpTest import Test.Cardano.Ledger.Imp.Common -import qualified Test.Cardano.Ledger.Mary.Imp as MaryImp -import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp +import qualified Test.Cardano.Ledger.Mary.Imp as Mary spec :: - forall era. ( AlonzoEraImp era - , EraSpecificSpec era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - MaryImp.spec @era - describe "AlonzoImpSpec" . withEachEraVersion @era $ do - Bbody.spec - Utxo.spec - Utxos.spec - Utxow.spec +spec era = do + Mary.spec era + describe "AlonzoEra Onwards" $ withImpInitEachEraVersion era $ do + BBODY.spec + UTXO.spec + UTXOS.spec + UTXOW.spec alonzoEraSpecificSpec :: - forall era. (AlonzoEraImp era, ShelleyEraTxCert era) => - SpecWith (ImpInit (LedgerSpec era)) -alonzoEraSpecificSpec = do - describe "Alonzo era specific Imp spec" $ - describe "Certificates without deposits" $ do - Utxow.alonzoEraSpecificSpec - -instance EraSpecificSpec AlonzoEra where - eraSpecificSpec = - ShelleyImp.shelleyEraSpecificSpec >> alonzoEraSpecificSpec + proxy era -> + Spec +alonzoEraSpecificSpec era = withImpInitEachEraVersion era $ do + describe "AlonzoEra Specific" $ do + UTXOW.alonzoEraSpecificSpec diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec.hs index 878aa7cfb6e..8a936e1fa0c 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec.hs @@ -23,5 +23,6 @@ alonzoEraSpecificSpec :: forall era. (AlonzoEraImp era, ShelleyEraTxCert era) => SpecWith (ImpInit (LedgerSpec era)) alonzoEraSpecificSpec = do describe "UTXOW" $ do - Valid.alonzoEraSpecificSpec - Invalid.alonzoEraSpecificSpec + describe "Certificates without deposits" $ do + Valid.alonzoEraSpecificSpec + Invalid.alonzoEraSpecificSpec diff --git a/eras/babbage/impl/CHANGELOG.md b/eras/babbage/impl/CHANGELOG.md index caab6b5c405..548a3b6129f 100644 --- a/eras/babbage/impl/CHANGELOG.md +++ b/eras/babbage/impl/CHANGELOG.md @@ -29,6 +29,8 @@ ### `testlib` +* Add `proxy era` argument to `babbageEraSpecificSpec` +* Make `Test.Cardano.Ledger.Babbage.Imp.spec` accept `Proxy era` * Add `Test.Cardano.Ledger.Babbage.Imp.PoolSpec` module with `babbageEraSpecificSpec` * In `Test.Cardano.Ledger.Babbage.Examples`: - Remove `mkBabbageBasedExampleTx`, `exampleBabbageBasedTxBody` diff --git a/eras/babbage/impl/cardano-ledger-babbage.cabal b/eras/babbage/impl/cardano-ledger-babbage.cabal index afa80c46a14..bd76cf02278 100644 --- a/eras/babbage/impl/cardano-ledger-babbage.cabal +++ b/eras/babbage/impl/cardano-ledger-babbage.cabal @@ -94,7 +94,7 @@ library cardano-ledger-alonzo ^>=1.16, cardano-ledger-binary >=1.6, cardano-ledger-core:{cardano-ledger-core, internal} >=1.20, - cardano-ledger-mary ^>=1.10.1, + cardano-ledger-mary ^>=1.11, cardano-ledger-shelley ^>=1.19, cardano-strict-containers, containers, diff --git a/eras/babbage/impl/test/Main.hs b/eras/babbage/impl/test/Main.hs index 2840d8861ce..4e73db65ddd 100644 --- a/eras/babbage/impl/test/Main.hs +++ b/eras/babbage/impl/test/Main.hs @@ -1,10 +1,12 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where import Cardano.Ledger.Babbage (BabbageEra) import qualified Test.Cardano.Ledger.Alonzo.Binary.CostModelsSpec as CostModelsSpec import qualified Test.Cardano.Ledger.Alonzo.Binary.TxWitsSpec as TxWitsSpec +import qualified Test.Cardano.Ledger.Alonzo.Imp as Alonzo import qualified Test.Cardano.Ledger.Babbage.Binary.CddlSpec as CddlSpec import qualified Test.Cardano.Ledger.Babbage.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Babbage.GoldenSpec as Golden @@ -14,22 +16,28 @@ import Test.Cardano.Ledger.Babbage.ImpTest () import qualified Test.Cardano.Ledger.Babbage.TxInfoSpec as TxInfo import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec) +import Test.Cardano.Ledger.Era +import qualified Test.Cardano.Ledger.Shelley.Imp as Shelley import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec BabbageEra where + eraImpSpec era = do + Shelley.shelleyEraSpecificSpec era + Alonzo.alonzoEraSpecificSpec era + Imp.babbageEraSpecificSpec era + Imp.spec era + main :: IO () main = - ledgerTestMain $ - describe "Babbage" $ do - TxInfo.spec @BabbageEra - GoldenTranslation.spec - Golden.spec - BinarySpec.spec - CddlSpec.spec - roundTripJsonEraSpec @BabbageEra - roundTripJsonShelleyEraSpec @BabbageEra - describe "Imp" $ do - Imp.spec @BabbageEra - describe "CostModels" $ do - CostModelsSpec.spec @BabbageEra - describe "TxWits" $ do - TxWitsSpec.spec @BabbageEra + ledgerEraTestMain @BabbageEra $ do + TxInfo.spec @BabbageEra + GoldenTranslation.spec + Golden.spec + BinarySpec.spec + CddlSpec.spec + roundTripJsonEraSpec @BabbageEra + roundTripJsonShelleyEraSpec @BabbageEra + describe "CostModels" $ do + CostModelsSpec.spec @BabbageEra + describe "TxWits" $ do + TxWitsSpec.spec @BabbageEra diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs index 4806ebc0ad2..c40dd28751a 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs @@ -8,50 +8,40 @@ {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} -module Test.Cardano.Ledger.Babbage.Imp (spec) where +module Test.Cardano.Ledger.Babbage.Imp (spec, babbageEraSpecificSpec) where -import Cardano.Ledger.Babbage (BabbageEra) import Cardano.Ledger.Babbage.Core import Cardano.Ledger.Babbage.State import Cardano.Ledger.Shelley.Rules -import qualified Test.Cardano.Ledger.Alonzo.Imp as AlonzoImp +import qualified Test.Cardano.Ledger.Alonzo.Imp as Alonzo import Test.Cardano.Ledger.Alonzo.ImpTest -import qualified Test.Cardano.Ledger.Babbage.Imp.PoolSpec as Pool -import qualified Test.Cardano.Ledger.Babbage.Imp.UtxoSpec as Utxo -import qualified Test.Cardano.Ledger.Babbage.Imp.UtxosSpec as Utxos -import qualified Test.Cardano.Ledger.Babbage.Imp.UtxowSpec as Utxow +import qualified Test.Cardano.Ledger.Babbage.Imp.PoolSpec as POOL +import qualified Test.Cardano.Ledger.Babbage.Imp.UtxoSpec as UTXO +import qualified Test.Cardano.Ledger.Babbage.Imp.UtxosSpec as UTXOS +import qualified Test.Cardano.Ledger.Babbage.Imp.UtxowSpec as UTXOW import Test.Cardano.Ledger.Babbage.ImpTest (BabbageEraImp) import Test.Cardano.Ledger.Imp.Common -import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp spec :: - forall era. ( BabbageEraImp era - , EraSpecificSpec era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - AlonzoImp.spec @era - withEachEraVersion @era $ - describe "BabbageImpSpec - era generic tests" $ do - Utxo.spec - Utxow.spec - Utxos.spec @era +spec era = do + Alonzo.spec era + describe "BabbageEra Onwards" $ withImpInitEachEraVersion era $ do + UTXO.spec + UTXOW.spec + UTXOS.spec babbageEraSpecificSpec :: - forall era. ( BabbageEraImp era , ShelleyEraAccounts era , Event (EraRule "NEWEPOCH" era) ~ ShelleyNewEpochEvent era ) => - SpecWith (ImpInit (LedgerSpec era)) -babbageEraSpecificSpec = do - describe "Babbage era specific Imp spec" $ - describe "POOL" Pool.babbageEraSpecificSpec - -instance EraSpecificSpec BabbageEra where - eraSpecificSpec = - ShelleyImp.shelleyEraSpecificSpec - >> AlonzoImp.alonzoEraSpecificSpec - >> babbageEraSpecificSpec + proxy era -> + Spec +babbageEraSpecificSpec era = do + describe "BabbageEra Specific" $ withImpInitEachEraVersion era $ do + POOL.babbageEraSpecificSpec diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/PoolSpec.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/PoolSpec.hs index 2b1488d6787..9c2d31d15d4 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/PoolSpec.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/PoolSpec.hs @@ -33,7 +33,7 @@ babbageEraSpecificSpec :: , Event (EraRule "NEWEPOCH" era) ~ ShelleyNewEpochEvent era ) => SpecWith (ImpInit (LedgerSpec era)) -babbageEraSpecificSpec = do +babbageEraSpecificSpec = describe "POOL" $ do it "Pool to pool member rewards" $ do -- This test attempts to reproduce the issue that appeared with the release of -- `cardano-db-sync-10.6.1` (using `cardano-ledger-shelley-1.17.0.0`), diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index ca9a1bb70e2..d9ead9735f3 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -46,6 +46,8 @@ ### `testlib` +* Export `conwayEraSpecificSpec` +* Make `Test.Cardano.Ledger.Conway.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Conway.Examples`: - Remove `mkConwayBasedExampleTx`, `exampleConwayBasedTxBody` - Add `exampleConwayBasedTx`, `exampleConwayBasedTopTx` diff --git a/eras/conway/impl/cardano-ledger-conway.cabal b/eras/conway/impl/cardano-ledger-conway.cabal index cbda15829f7..89d5e942fe2 100644 --- a/eras/conway/impl/cardano-ledger-conway.cabal +++ b/eras/conway/impl/cardano-ledger-conway.cabal @@ -112,7 +112,7 @@ library cardano-ledger-babbage ^>=1.14, cardano-ledger-binary ^>=1.9, cardano-ledger-core:{cardano-ledger-core, internal} ^>=1.21, - cardano-ledger-mary ^>=1.10.1, + cardano-ledger-mary ^>=1.11, cardano-ledger-shelley ^>=1.19, cardano-slotting, cardano-strict-containers, diff --git a/eras/conway/impl/test/Main.hs b/eras/conway/impl/test/Main.hs index ed4af01abf1..c7d68255c2b 100644 --- a/eras/conway/impl/test/Main.hs +++ b/eras/conway/impl/test/Main.hs @@ -1,23 +1,33 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Conway (ConwayEra) import Cardano.Ledger.Conway.Tx (tierRefScriptFee) +import qualified Test.Cardano.Ledger.Alonzo.Imp as Alonzo import Test.Cardano.Ledger.Common import qualified Test.Cardano.Ledger.Conway.Binary.CddlSpec as Cddl import qualified Test.Cardano.Ledger.Conway.GenesisSpec as Genesis import qualified Test.Cardano.Ledger.Conway.GoldenSpec as GoldenSpec import qualified Test.Cardano.Ledger.Conway.GoldenTranslation as GoldenTranslation import qualified Test.Cardano.Ledger.Conway.GovActionReorderSpec as GovActionReorder +import qualified Test.Cardano.Ledger.Conway.Imp as Imp import Test.Cardano.Ledger.Conway.Plutus.PlutusSpec as PlutusSpec import qualified Test.Cardano.Ledger.Conway.Spec as ConwaySpec import qualified Test.Cardano.Ledger.Conway.TxInfoSpec as TxInfo +import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec ConwayEra where + eraImpSpec era = do + Alonzo.alonzoEraSpecificSpec era + Imp.conwayEraSpecificSpec + Imp.spec era + main :: IO () -main = ledgerTestMain $ do +main = ledgerEraTestMain @ConwayEra $ do describe "Conway era-generic" $ ConwaySpec.spec @ConwayEra describe "Conway era-specific" $ do GoldenTranslation.spec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs index 16f3d9df6f0..e93fc702996 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs @@ -7,7 +7,7 @@ {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} -module Test.Cardano.Ledger.Conway.Imp (spec) where +module Test.Cardano.Ledger.Conway.Imp (spec, conwayEraSpecificSpec) where import Cardano.Ledger.Conway (ConwayEra) import Cardano.Ledger.Conway.Core @@ -18,67 +18,52 @@ import Cardano.Ledger.Conway.Rules ( ) import Cardano.Ledger.Shelley.Rules (RupdEvent) import Control.State.Transition.Extended -import qualified Test.Cardano.Ledger.Alonzo.Imp as AlonzoImp -import qualified Test.Cardano.Ledger.Babbage.Imp as BabbageImp -import qualified Test.Cardano.Ledger.Conway.Imp.BbodySpec as Bbody -import qualified Test.Cardano.Ledger.Conway.Imp.CertsSpec as Certs -import qualified Test.Cardano.Ledger.Conway.Imp.DelegSpec as Deleg -import qualified Test.Cardano.Ledger.Conway.Imp.EnactSpec as Enact -import qualified Test.Cardano.Ledger.Conway.Imp.EpochSpec as Epoch -import qualified Test.Cardano.Ledger.Conway.Imp.GovCertSpec as GovCert -import qualified Test.Cardano.Ledger.Conway.Imp.GovSpec as Gov -import qualified Test.Cardano.Ledger.Conway.Imp.HardForkSpec as HardFork -import qualified Test.Cardano.Ledger.Conway.Imp.LedgerSpec as Ledger -import qualified Test.Cardano.Ledger.Conway.Imp.RatifySpec as Ratify -import qualified Test.Cardano.Ledger.Conway.Imp.UtxoSpec as Utxo -import qualified Test.Cardano.Ledger.Conway.Imp.UtxosSpec as Utxos -import qualified Test.Cardano.Ledger.Conway.Imp.UtxowSpec as Utxow +import Data.Proxy +import qualified Test.Cardano.Ledger.Babbage.Imp as Babbage +import qualified Test.Cardano.Ledger.Conway.Imp.BbodySpec as BBODY +import qualified Test.Cardano.Ledger.Conway.Imp.CertsSpec as CERTS +import qualified Test.Cardano.Ledger.Conway.Imp.DelegSpec as DELEG +import qualified Test.Cardano.Ledger.Conway.Imp.EnactSpec as ENACT +import qualified Test.Cardano.Ledger.Conway.Imp.EpochSpec as EPOCH +import qualified Test.Cardano.Ledger.Conway.Imp.GovCertSpec as GOVCERT +import qualified Test.Cardano.Ledger.Conway.Imp.GovSpec as GOV +import qualified Test.Cardano.Ledger.Conway.Imp.HardForkSpec as HARDFORK +import qualified Test.Cardano.Ledger.Conway.Imp.LedgerSpec as LEDGER +import qualified Test.Cardano.Ledger.Conway.Imp.RatifySpec as RATIFY +import qualified Test.Cardano.Ledger.Conway.Imp.UtxoSpec as UTXO +import qualified Test.Cardano.Ledger.Conway.Imp.UtxosSpec as UTXOS +import qualified Test.Cardano.Ledger.Conway.Imp.UtxowSpec as UTXOW import Test.Cardano.Ledger.Conway.ImpTest import Test.Cardano.Ledger.Imp.Common spec :: - forall era. ( ConwayEraImp era - , EraSpecificSpec era , Event (EraRule "HARDFORK" era) ~ ConwayHardForkEvent era , Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era , Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - BabbageImp.spec @era - withEachEraVersion @era $ conwayEraGenericSpec @era +spec era = do + Babbage.spec era + describe "ConwayEra Onwards" $ withImpInitEachEraVersion era $ do + BBODY.spec + DELEG.spec + ENACT.spec + EPOCH.spec + GOV.spec + GOVCERT.spec + LEDGER.spec + HARDFORK.spec + RATIFY.spec + UTXO.spec + UTXOS.spec + UTXOW.spec -conwayEraGenericSpec :: - forall era. - ( ConwayEraImp era - , Event (EraRule "HARDFORK" era) ~ ConwayHardForkEvent era - , Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era - , Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era - ) => - SpecWith (ImpInit (LedgerSpec era)) -conwayEraGenericSpec = do - describe "BBODY" Bbody.spec - describe "DELEG" Deleg.spec - describe "ENACT" Enact.spec - describe "EPOCH" Epoch.spec - describe "GOV" Gov.spec - describe "GOVCERT" GovCert.spec - describe "LEDGER" Ledger.spec - describe "HARDFORK" HardFork.spec - describe "RATIFY" Ratify.spec - describe "UTXO" Utxo.spec - describe "UTXOS" Utxos.spec - describe "UTXOW" Utxow.spec - -conwayEraSpecificSpec :: SpecWith (ImpInit (LedgerSpec ConwayEra)) +conwayEraSpecificSpec :: Spec conwayEraSpecificSpec = do - describe "Conway era specific Imp spec" $ do - describe "CERTS" Certs.spec - describe "UTXO" Utxo.conwayEraSpecificSpec - -instance EraSpecificSpec ConwayEra where - eraSpecificSpec = - AlonzoImp.alonzoEraSpecificSpec - >> conwayEraSpecificSpec + describe "ConwayEra Specific" $ withImpInitEachEraVersion (Proxy @ConwayEra) $ do + -- TODO: move to `spec` when ready: https://github.com/IntersectMBO/cardano-ledger/issues/5805 + CERTS.spec + UTXO.conwayEraSpecificSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs index 65bbf336c86..712c8b04e59 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs @@ -39,7 +39,7 @@ import Test.Cardano.Ledger.Plutus.Examples (alwaysFailsNoDatum, purposeIsWellfor spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "BBODY" $ do it "BodyRefScriptsSizeTooBig" $ do plutusScript <- mkPlutusScript @era $ purposeIsWellformedNoDatum SPlutusV2 let scriptSize = originalBytesSize plutusScript diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/CertsSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/CertsSpec.hs index b651457d207..a1129e064d6 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/CertsSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/CertsSpec.hs @@ -28,7 +28,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "CERTS" $ do describe "Withdrawals" $ do it "Withdrawing from an unregistered staking address" $ do modifyPParams $ ppGovActionLifetimeL .~ EpochInterval 2 diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/DelegSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/DelegSpec.hs index 8444aca3ce9..48e1ca933db 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/DelegSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/DelegSpec.hs @@ -55,7 +55,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "DELEG" $ do describe "Register stake credential" $ do it "With correct deposit" $ do expectedDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EnactSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EnactSpec.hs index 76d3c5c619f..98fc79017d9 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EnactSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EnactSpec.hs @@ -48,7 +48,7 @@ spec :: , Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era ) => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "ENACT" $ do committeeSpec treasuryWithdrawalsSpec noConfidenceSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EpochSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EpochSpec.hs index 14c442fc8c7..fdc6cd8a223 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EpochSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EpochSpec.hs @@ -46,7 +46,7 @@ spec :: , Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era ) => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "EPOCH" $ do dRepVotingSpec treasurySpec proposalsSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovCertSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovCertSpec.hs index 0766d60b099..f186f98bfb4 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovCertSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovCertSpec.hs @@ -27,7 +27,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "GOVCERT" $ do it "Resigning proposed CC key" $ do ccColdCred <- KeyHashObj <$> freshKeyHash proposal <- mkUpdateCommitteeProposal Nothing mempty [(ccColdCred, EpochInterval 1234)] (1 %! 2) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs index 2c1fc2545e5..b7c3f864034 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs @@ -47,7 +47,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "GOV" $ do constitutionSpec proposalsSpec votingSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/HardForkSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/HardForkSpec.hs index dafc63cacbd..4a758443828 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/HardForkSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/HardForkSpec.hs @@ -24,7 +24,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "HARDFORK" $ do it "VRF Keyhashes get populated at v11 HardFork" $ do -- Since we're testing the HardFork to 11, the test only makes sense for protocol version 10 whenMajorVersion @10 $ do diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs index 3376333f5c3..1c994bee030 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs @@ -52,7 +52,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "LEDGER" $ do it "TxRefScriptsSizeTooBig" $ do -- we use here the largest script we currently have as many times as necessary to -- trigger the predicate failure diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs index 47a3e241429..4fbedbffcaf 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs @@ -39,7 +39,7 @@ spec :: forall era. (HasCallStack, ConwayEraImp era) => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "RATIFY" $ do votingSpec delayingActionsSpec committeeMinSizeAffectsInFlightProposalsSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs index 10ad91062dd..a8b15910a68 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs @@ -38,7 +38,7 @@ import Test.Cardano.Ledger.Imp.Common import Test.Cardano.Ledger.Plutus.Examples (alwaysSucceedsNoDatum) spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "UTXO" $ do describe "Certificates" $ do it "Reg/UnReg collect and refund correct amounts" $ do utxoStart <- getUTxO @@ -157,7 +157,7 @@ conwayEraSpecificSpec :: , ShelleyEraTxCert era ) => SpecWith (ImpInit (LedgerSpec era)) -conwayEraSpecificSpec = do +conwayEraSpecificSpec = describe "UTXO" $ do describe "Certificates" $ do it "Reg/UnReg collect and refund correct amounts" $ do utxoStart <- getUTxO diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs index 5cc877e46f6..f9e1c3d888b 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxosSpec.hs @@ -56,7 +56,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "UTXOS" $ do govPolicySpec costModelsSpec datumAndReferenceInputsSpec diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxowSpec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxowSpec.hs index 9351d4020e0..03b291d565b 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxowSpec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxowSpec.hs @@ -53,7 +53,7 @@ spec :: forall era. ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "UTXOW" $ do -- https://github.com/IntersectMBO/formal-ledger-specifications/issues/1029 -- TODO: Re-enable after issue is resolved, by removing this override disableInConformanceIt "Fails with PPViewHashesDontMatch before PV 11" . whenMajorVersionAtMost @10 $ do diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Spec.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Spec.hs index 47d600f5040..af687585890 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Spec.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Spec.hs @@ -8,15 +8,7 @@ module Test.Cardano.Ledger.Conway.Spec (spec) where -import Cardano.Ledger.Conway.Core -import Cardano.Ledger.Conway.Rules ( - ConwayEpochEvent, - ConwayHardForkEvent, - ConwayNewEpochEvent, - ) import Cardano.Ledger.Plutus.Language (SLanguage (..)) -import Cardano.Ledger.Shelley.Rules (RupdEvent) -import Control.State.Transition (STS (..)) import qualified Test.Cardano.Ledger.Alonzo.Binary.CostModelsSpec as CostModelsSpec import qualified Test.Cardano.Ledger.Alonzo.Binary.TxWitsSpec as TxWitsSpec import qualified Test.Cardano.Ledger.Babbage.TxInfoSpec as BabbageTxInfo @@ -26,8 +18,7 @@ import qualified Test.Cardano.Ledger.Conway.Binary.Regression as Regression import qualified Test.Cardano.Ledger.Conway.BinarySpec as Binary import qualified Test.Cardano.Ledger.Conway.CommitteeRatifySpec as CommitteeRatify import qualified Test.Cardano.Ledger.Conway.DRepRatifySpec as DRepRatify -import qualified Test.Cardano.Ledger.Conway.Imp as Imp -import Test.Cardano.Ledger.Conway.ImpTest (ConwayEraImp, EraSpecificSpec) +import Test.Cardano.Ledger.Conway.ImpTest (ConwayEraImp) import qualified Test.Cardano.Ledger.Conway.Proposals as Proposals import qualified Test.Cardano.Ledger.Conway.SPORatifySpec as SPORatifySpec import Test.Cardano.Ledger.Core.Binary.RoundTrip (RuleListEra) @@ -37,11 +28,6 @@ spec :: forall era. ( RuleListEra era , ConwayEraImp era - , EraSpecificSpec era - , Event (EraRule "HARDFORK" era) ~ ConwayHardForkEvent era - , Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era - , Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era - , Event (EraRule "RUPD" era) ~ RupdEvent ) => Spec spec = @@ -54,8 +40,6 @@ spec = roundTripJsonEraSpec @era Golden.spec @era Golden.goldenListRedeemers @era - describe "Imp" $ do - Imp.spec @era describe "CostModels" $ do CostModelsSpec.spec @era describe "TxWits" $ do diff --git a/eras/dijkstra/impl/CHANGELOG.md b/eras/dijkstra/impl/CHANGELOG.md index d2e58747205..9f165be798a 100644 --- a/eras/dijkstra/impl/CHANGELOG.md +++ b/eras/dijkstra/impl/CHANGELOG.md @@ -69,6 +69,7 @@ ### testlib +* Make `Test.Cardano.Ledger.Dijkstra.Imp.spec` accept `Proxy era` * Add `ToExpr` instance for `DijkstraBlockBody` * Add `DecCBOR` instance for `DijkstraBlockBodyRaw` * Add `genNonEmptyAccountBalanceIntervals` diff --git a/eras/dijkstra/impl/test/Main.hs b/eras/dijkstra/impl/test/Main.hs index 597cef6adc2..17914ece730 100644 --- a/eras/dijkstra/impl/test/Main.hs +++ b/eras/dijkstra/impl/test/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where @@ -17,22 +18,23 @@ import qualified Test.Cardano.Ledger.Dijkstra.GoldenSpec as GoldenSpec import qualified Test.Cardano.Ledger.Dijkstra.Imp as Imp import Test.Cardano.Ledger.Dijkstra.ImpTest () import qualified Test.Cardano.Ledger.Dijkstra.TxInfoSpec as DijkstraTxInfoSpec +import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec DijkstraEra where + eraImpSpec = Imp.spec + main :: IO () main = - ledgerTestMain $ - describe "Dijkstra" $ do - describe "RoundTrip" $ do - roundTripConwayCommonSpec @DijkstraEra - Cddl.spec - GoldenSpec.spec - roundTripJsonShelleyEraSpec @DijkstraEra - describe "Imp" $ do - Imp.spec @DijkstraEra - describe "TxInfo" $ do - BabbageTxInfo.spec @DijkstraEra - txInfoSpec @DijkstraEra SPlutusV3 - txInfoSpec @DijkstraEra SPlutusV4 - DijkstraTxInfoSpec.spec @DijkstraEra - Golden.spec @DijkstraEra + ledgerEraTestMain @DijkstraEra $ do + describe "RoundTrip" $ do + roundTripConwayCommonSpec @DijkstraEra + Cddl.spec + GoldenSpec.spec + roundTripJsonShelleyEraSpec @DijkstraEra + describe "TxInfo" $ do + BabbageTxInfo.spec @DijkstraEra + txInfoSpec @DijkstraEra SPlutusV3 + txInfoSpec @DijkstraEra SPlutusV4 + DijkstraTxInfoSpec.spec @DijkstraEra + Golden.spec @DijkstraEra diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp.hs index a815e9345cc..24e1be982cb 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp.hs @@ -1,7 +1,4 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -9,42 +6,31 @@ module Test.Cardano.Ledger.Dijkstra.Imp where import Cardano.Ledger.Conway.Rules -import Cardano.Ledger.Dijkstra (DijkstraEra) import Cardano.Ledger.Dijkstra.Core import Cardano.Ledger.Shelley.Rules import Test.Cardano.Ledger.Common import qualified Test.Cardano.Ledger.Conway.Imp as ConwayImp -import qualified Test.Cardano.Ledger.Dijkstra.Imp.CertSpec as Cert -import qualified Test.Cardano.Ledger.Dijkstra.Imp.CertsSpec as Certs -import qualified Test.Cardano.Ledger.Dijkstra.Imp.LedgerSpec as Ledger -import qualified Test.Cardano.Ledger.Dijkstra.Imp.UtxoSpec as Utxo -import qualified Test.Cardano.Ledger.Dijkstra.Imp.UtxowSpec as Utxow +import qualified Test.Cardano.Ledger.Dijkstra.Imp.CertSpec as CERT +import qualified Test.Cardano.Ledger.Dijkstra.Imp.CertsSpec as CERTS +import qualified Test.Cardano.Ledger.Dijkstra.Imp.LedgerSpec as LEDGER +import qualified Test.Cardano.Ledger.Dijkstra.Imp.UtxoSpec as UTXO +import qualified Test.Cardano.Ledger.Dijkstra.Imp.UtxowSpec as UTXOW import Test.Cardano.Ledger.Dijkstra.ImpTest spec :: - forall era. ( DijkstraEraImp era - , EraSpecificSpec era , Event (EraRule "EPOCH" era) ~ ConwayEpochEvent era , Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era , Event (EraRule "HARDFORK" era) ~ ConwayHardForkEvent era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - ConwayImp.spec @era - withEachEraVersion @era $ dijkstraEraGenericSpec @era - -dijkstraEraGenericSpec :: - forall era. - DijkstraEraImp era => - SpecWith (ImpInit (LedgerSpec era)) -dijkstraEraGenericSpec = do - describe "LEDGER" Ledger.spec - describe "CERTS" $ do - Cert.spec - Certs.spec - describe "UTXOW" Utxow.spec - describe "UTXO" Utxo.spec - -instance EraSpecificSpec DijkstraEra +spec era = do + ConwayImp.spec era + describe "DijkstraEra Onwards" $ withImpInitEachEraVersion era $ do + LEDGER.spec + CERT.spec + CERTS.spec + UTXOW.spec + UTXO.spec diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertSpec.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertSpec.hs index edbc2b6fa20..ade26024fe5 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertSpec.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertSpec.hs @@ -18,7 +18,7 @@ import Test.Cardano.Ledger.Dijkstra.ImpTest import Test.Cardano.Ledger.Imp.Common spec :: forall era. DijkstraEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "CERT" $ do xit "Subtransaction consumes correct refund after keyDeposit is changed" $ do stakingCred <- KeyHashObj <$> freshKeyHash _ <- registerStakeCredential stakingCred diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertsSpec.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertsSpec.hs index 9f8c4cf764d..91bd03edeb4 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertsSpec.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/CertsSpec.hs @@ -21,7 +21,7 @@ import Test.Cardano.Ledger.Dijkstra.ImpTest import Test.Cardano.Ledger.Imp.Common spec :: forall era. DijkstraEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "CERTS" $ do describe "Withdrawals" $ do it "Withdrawing from an unregistered staking address" $ do modifyPParams $ ppGovActionLifetimeL .~ EpochInterval 2 diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/LedgerSpec.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/LedgerSpec.hs index fb4a3e5135c..03985939fe1 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/LedgerSpec.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/LedgerSpec.hs @@ -22,7 +22,7 @@ import Test.Cardano.Ledger.Dijkstra.ImpTest import Test.Cardano.Ledger.Imp.Common spec :: forall era. DijkstraEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "LEDGER" $ do -- TODO: re-enable after Imp fixup of subtransactions is implemented xdescribe "Spending sub-transaction outputs" $ do it "Fails when top-level transaction spends output from its own sub-transaction" $ do diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxoSpec.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxoSpec.hs index 6305562a377..d152adee497 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxoSpec.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxoSpec.hs @@ -33,7 +33,7 @@ spec :: forall era. DijkstraEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = +spec = describe "UTXO" $ do describe "Collaterals" $ do it "Fails to submit a transaction containing a Ptr in collateral return" $ do cred <- KeyHashObj <$> freshKeyHash diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxowSpec.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxowSpec.hs index 5c06ea6ee7d..61d8def6f3a 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxowSpec.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/UtxowSpec.hs @@ -25,7 +25,7 @@ spec :: forall era. DijkstraEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = +spec = describe "UTXOW" $ do describe "RequireGuard native scripts" $ do it "Spending inputs locked by script requiring a keyhash guard" $ do guardKeyHash <- KeyHashObj <$> freshKeyHash diff --git a/eras/mary/impl/CHANGELOG.md b/eras/mary/impl/CHANGELOG.md index 6a1f4e7f28e..2c901b3af34 100644 --- a/eras/mary/impl/CHANGELOG.md +++ b/eras/mary/impl/CHANGELOG.md @@ -1,6 +1,6 @@ # Version history for `cardano-ledger-mary` -## 1.10.1.0 +## 1.11.0.0 * Add `ApplyTick` instance for `MaryEra` * Add `EraForecast` and `ShelleyEraForecast` instances for `MaryEra`. @@ -11,6 +11,7 @@ ### `testlib` +* Make `Test.Cardano.Ledger.Mary.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Mary.Examples`: - Remove `exampleMaryBasedShelleyTxBody`, `exampleMaryBasedTxBody` - Add `exampleMaryBasedTx` diff --git a/eras/mary/impl/cardano-ledger-mary.cabal b/eras/mary/impl/cardano-ledger-mary.cabal index 1cea8c61c63..6819a754380 100644 --- a/eras/mary/impl/cardano-ledger-mary.cabal +++ b/eras/mary/impl/cardano-ledger-mary.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: cardano-ledger-mary -version: 1.10.1.0 +version: 1.11.0.0 license: Apache-2.0 maintainer: operations@iohk.io author: IOHK diff --git a/eras/mary/impl/test/Main.hs b/eras/mary/impl/test/Main.hs index 9c315dc508f..462f4e20fe5 100644 --- a/eras/mary/impl/test/Main.hs +++ b/eras/mary/impl/test/Main.hs @@ -1,27 +1,31 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where import Cardano.Ledger.Mary (MaryEra) import qualified Test.Cardano.Ledger.Allegra.Binary.Golden as Golden -import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec) +import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Mary.Binary.CddlSpec as CddlSpec import qualified Test.Cardano.Ledger.Mary.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Mary.Imp as Imp import Test.Cardano.Ledger.Mary.ImpTest () import qualified Test.Cardano.Ledger.Mary.ValueSpec as ValueSpec +import qualified Test.Cardano.Ledger.Shelley.Imp as Imp (shelleyEraSpecificSpec) import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec MaryEra where + eraImpSpec era = do + Imp.shelleyEraSpecificSpec era + Imp.spec era + main :: IO () main = - ledgerTestMain $ - describe "Mary" $ do - ValueSpec.spec - BinarySpec.spec - CddlSpec.spec - describe "Imp" $ do - Imp.spec @MaryEra - roundTripJsonEraSpec @MaryEra - roundTripJsonShelleyEraSpec @MaryEra - Golden.spec @MaryEra + ledgerEraTestMain @MaryEra $ do + ValueSpec.spec + BinarySpec.spec + CddlSpec.spec + roundTripJsonEraSpec @MaryEra + roundTripJsonShelleyEraSpec @MaryEra + Golden.spec @MaryEra diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs index 1e60d5744b8..717019305f3 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs @@ -1,8 +1,5 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -10,26 +7,20 @@ module Test.Cardano.Ledger.Mary.Imp (spec) where import Cardano.Ledger.Core -import Cardano.Ledger.Mary (MaryEra) import Cardano.Ledger.Shelley.Rules -import qualified Test.Cardano.Ledger.Allegra.Imp as AllegraImp +import qualified Test.Cardano.Ledger.Allegra.Imp as Allegra import Test.Cardano.Ledger.Imp.Common -import qualified Test.Cardano.Ledger.Mary.Imp.UtxoSpec as Utxo +import qualified Test.Cardano.Ledger.Mary.Imp.UtxoSpec as UTXO import Test.Cardano.Ledger.Mary.ImpTest -import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp spec :: - forall era. ( MaryEraImp era - , EraSpecificSpec era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - AllegraImp.spec @era - describe "MaryImpSpec" $ - withEachEraVersion @era $ - Utxo.spec - -instance EraSpecificSpec MaryEra where - eraSpecificSpec = ShelleyImp.shelleyEraSpecificSpec +spec era = do + Allegra.spec era + describe "MaryEra Onwards" $ + withImpInitEachEraVersion era $ do + UTXO.spec diff --git a/eras/shelley/impl/CHANGELOG.md b/eras/shelley/impl/CHANGELOG.md index 5513a4ed395..7aee1da3318 100644 --- a/eras/shelley/impl/CHANGELOG.md +++ b/eras/shelley/impl/CHANGELOG.md @@ -60,6 +60,10 @@ ### `testlib` +* Add `proxy era` argument to `shelleyEraSpecificSpec` +* Remove `EraSpecificSpec` +* Make `Test.Cardano.Ledger.Shelley.Imp.spec` accept `Proxy era` +* Add `withImpInitEachEraVersion` and deprecate `withEachEraVersion` in its favor * Export `exampleVrfVerKeyHash` from `Test.Cardano.Ledger.Shelley.Examples` * Add `HuddleRule "int32" ShelleyEra` instance * Add `withIssuerAndTxsInBlock_` and `withIssuerAndTxsInBlock` diff --git a/eras/shelley/impl/test/Main.hs b/eras/shelley/impl/test/Main.hs index 11776e7800b..14feee936a4 100644 --- a/eras/shelley/impl/test/Main.hs +++ b/eras/shelley/impl/test/Main.hs @@ -1,21 +1,25 @@ {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where import Cardano.Ledger.Shelley (ShelleyEra) -import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec) +import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Shelley.Binary.CddlSpec as Cddl import qualified Test.Cardano.Ledger.Shelley.BinarySpec as Binary import qualified Test.Cardano.Ledger.Shelley.Imp as Imp import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) +instance EraSpec ShelleyEra where + eraImpSpec era = do + Imp.shelleyEraSpecificSpec era + Imp.spec era + main :: IO () main = - ledgerTestMain $ - describe "Shelley" $ do - Binary.spec - Cddl.spec - Imp.spec @ShelleyEra - roundTripJsonEraSpec @ShelleyEra - roundTripJsonShelleyEraSpec @ShelleyEra + ledgerEraTestMain @ShelleyEra $ do + Binary.spec + Cddl.spec + roundTripJsonEraSpec @ShelleyEra + roundTripJsonShelleyEraSpec @ShelleyEra diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp.hs index fbe5c56a906..b70e604b6d1 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -9,49 +8,43 @@ module Test.Cardano.Ledger.Shelley.Imp (spec, shelleyEraSpecificSpec) where import Cardano.Ledger.Core (EraRule) -import Cardano.Ledger.Shelley (ShelleyEra) import Cardano.Ledger.Shelley.Rules (RupdEvent) import Cardano.Ledger.Shelley.State (ShelleyEraAccounts) import Control.State.Transition (Event) import Test.Cardano.Ledger.Imp.Common -import qualified Test.Cardano.Ledger.Shelley.Imp.DelegSpec as Deleg -import qualified Test.Cardano.Ledger.Shelley.Imp.EpochSpec as Epoch -import qualified Test.Cardano.Ledger.Shelley.Imp.LedgerSpec as Ledger -import qualified Test.Cardano.Ledger.Shelley.Imp.PoolSpec as Pool -import qualified Test.Cardano.Ledger.Shelley.Imp.UtxoSpec as Utxo -import qualified Test.Cardano.Ledger.Shelley.Imp.UtxowSpec as Utxow +import qualified Test.Cardano.Ledger.Shelley.Imp.DelegSpec as DELEG +import qualified Test.Cardano.Ledger.Shelley.Imp.EpochSpec as EPOCH +import qualified Test.Cardano.Ledger.Shelley.Imp.LedgerSpec as LEDGER +import qualified Test.Cardano.Ledger.Shelley.Imp.PoolSpec as POOL +import qualified Test.Cardano.Ledger.Shelley.Imp.UtxoSpec as UTXO +import qualified Test.Cardano.Ledger.Shelley.Imp.UtxowSpec as UTXOW import Test.Cardano.Ledger.Shelley.ImpTest import qualified Test.Cardano.Ledger.Shelley.UnitTests.InstantStakeTest as Instant spec :: - forall era. + forall proxy era. ( ShelleyEraImp era - , EraSpecificSpec era , Event (EraRule "RUPD" era) ~ RupdEvent ) => + proxy era -> Spec -spec = do - describe "Era specific tests" . withEachEraVersion @era $ eraSpecificSpec - describe "ShelleyImpSpec" $ withEachEraVersion @era $ do - describe "DELEG" Deleg.spec - Epoch.spec - Ledger.spec - Pool.spec - Utxow.spec - Utxo.spec - describe "ShelleyPureTests" $ do +spec era = do + describe "ShelleyEra Onwards" $ withImpInitEachEraVersion era $ do + DELEG.spec + EPOCH.spec + LEDGER.spec + POOL.spec + UTXOW.spec + UTXO.spec + describe "ShelleyEraPureTests" $ do Instant.spec @era shelleyEraSpecificSpec :: - forall era. ( ShelleyEraImp era , ShelleyEraAccounts era ) => - SpecWith (ImpInit (LedgerSpec era)) -shelleyEraSpecificSpec = do - describe "Shelley era specific Imp spec" $ - describe "DELEG" $ - Deleg.shelleyEraSpecificSpec - -instance EraSpecificSpec ShelleyEra where - eraSpecificSpec = shelleyEraSpecificSpec + proxy era -> + Spec +shelleyEraSpecificSpec era = withImpInitEachEraVersion era $ do + describe "ShelleyEra Specific" $ + DELEG.shelleyEraSpecificSpec diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/DelegSpec.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/DelegSpec.hs index 865f1b0e9c8..552aa7a2bff 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/DelegSpec.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp/DelegSpec.hs @@ -38,7 +38,7 @@ shelleyEraSpecificSpec :: , ShelleyEraAccounts era ) => SpecWith (ImpInit (LedgerSpec era)) -shelleyEraSpecificSpec = do +shelleyEraSpecificSpec = describe "DELEG" $ do it "Twice the same certificate in the same transaction" $ do freshKeyHash >>= \kh -> do regTxCert <- genRegTxCert (KeyHashObj kh) @@ -136,7 +136,7 @@ shelleyEraSpecificSpec = do spec :: ShelleyEraImp era => SpecWith (ImpInit (LedgerSpec era)) -spec = do +spec = describe "DELEG" $ do describe "Register stake credential" $ do it "With correct deposit or without any deposit" $ do cred <- KeyHashObj <$> freshKeyHash diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs index 280db7914b2..24828439e3c 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs @@ -25,7 +25,6 @@ module Test.Cardano.Ledger.Shelley.ImpTest ( ImpTestM, LedgerSpec, - EraSpecificSpec (..), SomeSTSEvent (..), ImpTestState, ImpTestEnv (..), @@ -140,6 +139,7 @@ module Test.Cardano.Ledger.Shelley.ImpTest ( whenMajorVersionAtMost, unlessMajorVersion, getsPParams, + withImpInitEachEraVersion, withEachEraVersion, impSatisfyMNativeScripts, impSatisfySignature, @@ -343,10 +343,6 @@ instance ShelleyEraImp era => ImpSpec (LedgerSpec era) where -- number of the current era impPrepAction = passTick -class EraTest era => EraSpecificSpec era where - eraSpecificSpec :: SpecWith (ImpInit (LedgerSpec era)) - eraSpecificSpec = pure () - data SomeSTSEvent era = forall (rule :: Symbol). ( Typeable (Event (EraRule rule era)) @@ -697,10 +693,19 @@ withEachEraVersion :: ShelleyEraImp era => SpecWith (ImpInit (LedgerSpec era)) -> Spec -withEachEraVersion specWith = +withEachEraVersion = withImpInitEachEraVersion (Proxy @era) +{-# DEPRECATED withEachEraVersion "In favor of `withImpInitEachEraVersion`" #-} + +withImpInitEachEraVersion :: + forall proxy era. + ShelleyEraImp era => + proxy era -> + SpecWith (ImpInit (LedgerSpec era)) -> + Spec +withImpInitEachEraVersion _proxy specWith = withImpInit @(LedgerSpec era) $ do forM_ (eraProtVersions @era) $ \protVer -> - describe ("Protocol " <> show protVer) $ + describe ("Version " <> show protVer) $ modifyImpInitProtVer protVer specWith shelleyModifyImpInitProtVer :: diff --git a/libs/cardano-ledger-api/cardano-ledger-api.cabal b/libs/cardano-ledger-api/cardano-ledger-api.cabal index f301738e6b3..64962d23bf7 100644 --- a/libs/cardano-ledger-api/cardano-ledger-api.cabal +++ b/libs/cardano-ledger-api/cardano-ledger-api.cabal @@ -77,7 +77,7 @@ library cardano-ledger-conway >=1.22, cardano-ledger-core:{cardano-ledger-core, internal} >=1.20, cardano-ledger-dijkstra >=0.3, - cardano-ledger-mary ^>=1.10.1, + cardano-ledger-mary >=1.10.1 && <1.12, cardano-ledger-shelley ^>=1.19, cardano-strict-containers, containers, diff --git a/libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/Imp/QuerySpec.hs b/libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/Imp/QuerySpec.hs index 47e68fd5a38..effe389e9f2 100644 --- a/libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/Imp/QuerySpec.hs +++ b/libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/Imp/QuerySpec.hs @@ -33,6 +33,7 @@ import Cardano.Ledger.DRep import Cardano.Ledger.Keys (KeyRole (..)) import Cardano.Ledger.Shelley.LedgerState import qualified Data.Map.Strict as Map +import Data.Proxy import qualified Data.Set as Set import Lens.Micro import Lens.Micro.Mtl @@ -44,7 +45,7 @@ spec :: forall era. ConwayEraImp era => Spec -spec = withEachEraVersion @era $ do +spec = withImpInitEachEraVersion (Proxy @era) $ do describe "DRep" $ do describe "Expiries are reported correctly" $ do let drepStateFromQuery :: diff --git a/libs/cardano-ledger-core/CHANGELOG.md b/libs/cardano-ledger-core/CHANGELOG.md index 3540fb4b246..02e4c66b70c 100644 --- a/libs/cardano-ledger-core/CHANGELOG.md +++ b/libs/cardano-ledger-core/CHANGELOG.md @@ -37,6 +37,7 @@ ### `testlib` +* Add `EraSpec` and `ledgerEraTestMain` * Add `toPackageGolden` and `itGolden` * Add `goldenForToJSON`, `itGoldenToJSON`, `aesonGoldenSpec` and `roundTripAesonProperty` * Add `fullAnnCddlSpec`, `fullAnnGenCddlSpec`, `fullCddlSpec` and `fullGenCddlSpec` diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs index 033cfb4fdda..3ec83d57612 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs @@ -2,10 +2,14 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE UndecidableSuperClasses #-} module Test.Cardano.Ledger.Era ( EraTest (..), + EraSpec (..), + ledgerEraTestMain, registerTestAccount, ) where @@ -104,6 +108,24 @@ class accountsFromAccountsMap :: Map.Map (Credential Staking) (AccountState era) -> Accounts era +class EraTest era => EraSpec era where + -- | All of Imp spec that is applicable to this era + eraImpSpec :: Proxy era -> Spec + +-- | This is the main entry point for every era's test suite. It contains all tests that must be +-- supplied by each era through `EraSpec` type class and then some through the extra argument +ledgerEraTestMain :: + forall era. + EraSpec era => + -- | Tests that are specific to this era, if any. + Spec -> + IO () +ledgerEraTestMain extraEraSpec = + ledgerTestMain $ + describe (eraName @era) $ do + describe "Imp" $ eraImpSpec (Proxy @era) + extraEraSpec + -- | This is a helper function that uses `mkTestAccountState` to register an account. registerTestAccount :: (HasCallStack, EraTest era) =>