From 18c228de734aff4f81ad92155d416d0d7152701a Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 23 Feb 2024 02:31:40 +0100 Subject: [PATCH] Work in progress 2 (will undo) --- cabal.project | 74 ++++++++++--------- .../Cardano/Api/ProtocolParameters.hs | 2 +- .../Test/Cardano/Api/ProtocolParameters.hs | 5 +- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/cabal.project b/cabal.project index 98219e6ec9..6ab599e1c6 100644 --- a/cabal.project +++ b/cabal.project @@ -19,6 +19,11 @@ index-state: packages: cardano-api cardano-api-gen + ../cardano-ledger/eras/alonzo/impl + ../cardano-ledger/eras/babbage/impl + ../cardano-ledger/eras/shelley/impl + ../cardano-ledger/eras/conway/impl + ../cardano-ledger/libs/cardano-ledger-core package cardano-api ghc-options: -Werror @@ -26,40 +31,41 @@ package cardano-api package cardano-api-gen ghc-options: -Werror -source-repository-package - type: git - location: https://github.com/IntersectMBO/cardano-ledger.git - tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 - subdir: eras/alonzo/impl - --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= - -source-repository-package - type: git - location: https://github.com/IntersectMBO/cardano-ledger.git - tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 - subdir: eras/babbage/impl - --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= - -source-repository-package - type: git - location: https://github.com/IntersectMBO/cardano-ledger.git - tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 - subdir: eras/shelley/impl - --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= - -source-repository-package - type: git - location: https://github.com/IntersectMBO/cardano-ledger.git - tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 - subdir: eras/conway/impl - --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= - -source-repository-package - type: git - location: https://github.com/IntersectMBO/cardano-ledger.git - tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 - subdir: libs/cardano-ledger-core - --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= + +-- source-repository-package +-- type: git +-- location: https://github.com/IntersectMBO/cardano-ledger.git +-- tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 +-- subdir: eras/alonzo/impl +-- --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= + +-- source-repository-package +-- type: git +-- location: https://github.com/IntersectMBO/cardano-ledger.git +-- tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 +-- subdir: eras/babbage/impl +-- --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= + +-- source-repository-package +-- type: git +-- location: https://github.com/IntersectMBO/cardano-ledger.git +-- tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 +-- subdir: eras/shelley/impl +-- --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= + +-- source-repository-package +-- type: git +-- location: https://github.com/IntersectMBO/cardano-ledger.git +-- tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 +-- subdir: eras/conway/impl +-- --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= + +-- source-repository-package +-- type: git +-- location: https://github.com/IntersectMBO/cardano-ledger.git +-- tag: 504253f1eb4b05158ff2df51ac0a22725a4e4a95 +-- subdir: libs/cardano-ledger-core +-- --sha256: sha256-xa5Dl2GEj6Q1bAPqjyAZAQDkINXdcYs2lPMsyLOVxbM= diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index 0a9ab34162..49c95899d9 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -1660,7 +1660,7 @@ toAlonzoPParams -- we won't be able to construct an Alonzo tx using the Babbage -- era's protocol parameter because our only other option is to -- error. - Nothing -> Right minBound + Nothing -> Left (PpceMissingParameter "Decentralization!!!") Just dParam -> boundRationalEither "D" dParam -- This is the correct implementation that should be the used instead: -- d <- requireParam "protocolParamDecentralization" diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs index c151075f39..034e7623bd 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/ProtocolParameters.hs @@ -5,7 +5,7 @@ module Test.Cardano.Api.ProtocolParameters(tests) where import Cardano.Api.Ledger (PParams(..)) import Cardano.Api.ProtocolParameters (ProtocolParameters (..), convertToLedgerProtocolParameters, LedgerProtocolParameters (..)) -import Hedgehog (Property, property, forAll, (===), Gen, success) +import Hedgehog (Property, property, forAll, (===), Gen, success, footnote) import Cardano.Api (CardanoEra (..), inEonForEra, ToJSON, prettyPrintJSON, ProtocolParametersConversionError, FromJSON) import Cardano.Api.Eon.ShelleyBasedEra(ShelleyBasedEra(..), ShelleyLedgerEra) import Test.Gen.Cardano.Api.Typed (genProtocolParameters) @@ -36,7 +36,8 @@ protocolParametersSerializeTheSame era = let protocolParametersBS = prettyPrintJSON protocolParameters :: ByteString case convertToEraAndSerialize protocolParameters of Left _ -> success -- fail (show err) - Right pParamsBS -> pParamsBS === protocolParametersBS + Right pParamsBS -> do footnote $ "Decentralization parameter was: " <> show (protocolParamDecentralization protocolParameters) + pParamsBS === protocolParametersBS where convertToEraAndSerialize :: ProtocolParameters -> Either ProtocolParametersConversionError ByteString convertToEraAndSerialize pp =