Skip to content

Commit

Permalink
Fixes to generators and conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Feb 26, 2024
1 parent 57ae4e6 commit f9359fd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Test.Cardano.Api.ProtocolParameters(tests) where

import Cardano.Api.Ledger (PParams(..))
import Cardano.Api.ProtocolParameters (ProtocolParameters (..), convertToLedgerProtocolParameters, LedgerProtocolParameters (..), fromLedgerPParams)
import Hedgehog (Property, property, forAll, (===), Gen, success, footnote)
import Hedgehog (Property, property, forAll, (===), Gen, success, footnote, discard, withDiscards, withTests)
import Cardano.Api (CardanoEra (..), inEonForEra, ToJSON, prettyPrintJSON, ProtocolParametersConversionError, FromJSON)
import Cardano.Api.Eon.ShelleyBasedEra(ShelleyBasedEra(..), ShelleyLedgerEra)
import Test.Gen.Cardano.Api.Typed (genProtocolParameters)
Expand Down Expand Up @@ -37,9 +37,11 @@ tests =

protocolParametersSerializeTheSame :: forall era. ToJSON (PParams (ShelleyLedgerEra era)) => CardanoEra era -> Property
protocolParametersSerializeTheSame era =
withTests 10000 $
withDiscards 10000 $
property $ do protocolParameters <- forAll (genProtocolParameters era :: Gen ProtocolParameters)
case convertToEraAndSerialize protocolParameters of
Left _ -> success -- fail (show err)
Left _ -> discard
Right (roundTrippedProtocolParams, pParamsBS) ->
do footnote $ "Decentralization parameter was: " <> show (protocolParamDecentralization protocolParameters)
pParamsBS === prettyPrintJSON roundTrippedProtocolParams
Expand Down

0 comments on commit f9359fd

Please sign in to comment.