From bfa6dfe4dfd071b4fdc37ce650e74fd44447d9f6 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Wed, 13 Nov 2024 19:20:30 -0700 Subject: [PATCH] Add `eraProtVersions` --- eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs | 2 +- libs/cardano-ledger-api/test/Tests.hs | 2 +- libs/cardano-ledger-core/CHANGELOG.md | 1 + libs/cardano-ledger-core/src/Cardano/Ledger/Core/Era.hs | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) 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 b43bb85e483..749b5930c04 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs @@ -98,7 +98,7 @@ spec :: spec = do BabbageImp.spec @era withImpInit @(LedgerSpec era) $ - forM_ [eraProtVerLow @era .. eraProtVerHigh @era] $ \protVer -> + forM_ (eraProtVersions @era) $ \protVer -> describe ("ConwayImpSpec - " <> show protVer) $ modifyImpInitProtVer protVer $ do describe "BBODY" Bbody.spec diff --git a/libs/cardano-ledger-api/test/Tests.hs b/libs/cardano-ledger-api/test/Tests.hs index ab0449f4750..acce1fe5520 100644 --- a/libs/cardano-ledger-api/test/Tests.hs +++ b/libs/cardano-ledger-api/test/Tests.hs @@ -26,7 +26,7 @@ apiSpec = StateQuery.spec describe "Imp" $ withImpInit @(LedgerSpec Conway) $ - forM_ [eraProtVerLow @Conway .. eraProtVerHigh @Conway] $ \v -> + forM_ (eraProtVersions @Conway) $ \v -> modifyImpInitProtVer v $ do ImpQuery.spec @Conway diff --git a/libs/cardano-ledger-core/CHANGELOG.md b/libs/cardano-ledger-core/CHANGELOG.md index c7831b5e330..03edd4eee05 100644 --- a/libs/cardano-ledger-core/CHANGELOG.md +++ b/libs/cardano-ledger-core/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.16.0.0 +* Add `eraProtVersions` * Remove deprecated `_unTxId` and `adaOnly` * Remove deprecated module `Cardano.Ledger.Serialization` * Remove deprecated `fromSLanguage` diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Core/Era.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Core/Era.hs index b9a388d0f08..38998f49954 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Core/Era.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Core/Era.hs @@ -41,6 +41,7 @@ module Cardano.Ledger.Core.Era ( notSupportedInThisEraL, eraProtVerLow, eraProtVerHigh, + eraProtVersions, toEraCBOR, fromEraCBOR, fromEraShareCBOR, @@ -237,6 +238,10 @@ eraProtVerLow = natVersion @(ProtVerLow era) eraProtVerHigh :: forall era. Era era => Version eraProtVerHigh = natVersion @(ProtVerHigh era) +-- | List with all major versions that are used in the particular era. +eraProtVersions :: forall era. Era era => [Version] +eraProtVersions = [eraProtVerLow @era .. eraProtVerHigh @era] + -- | Enforce era to be at least the specified era at the type level. In other words -- compiler will produce type error when applied to eras prior to the specified era. -- This function should be used in order to avoid redundant constraints warning.