Skip to content

Commit

Permalink
Rename ppParamsRoundtrip and improve its comment
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Apr 15, 2024
1 parent d8ceb93 commit 527f16c
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ tests =
, testProperty "BabbageEra" $ protocolParametersAreCompatible BabbageEra
]
, testGroup "PParams roundtrip"
[ testProperty "ShelleyEra" $ ppParamsRoundtrip ShelleyEra
, testProperty "AlonzoEra" $ ppParamsRoundtrip AlonzoEra
, testProperty "BabbageEra" $ ppParamsRoundtrip BabbageEra
[ testProperty "ShelleyEra" $ roundtripBetweenPParamsAndLegacyProtocolParameters ShelleyEra
, testProperty "AlonzoEra" $ roundtripBetweenPParamsAndLegacyProtocolParameters AlonzoEra
, testProperty "BabbageEra" $ roundtripBetweenPParamsAndLegacyProtocolParameters BabbageEra
]
]

Expand All @@ -74,12 +74,14 @@ protocolParametersAreCompatible era =
void (leftFail (eitherDecode serializedProtocolParameters :: Either String (PParams (ShelleyLedgerEra era))))
success

-- | Ensure that deserializing using PParams FromJSON instance and then serializing again using PParams ToJSON
-- instance results in the same thing
ppParamsRoundtrip :: forall era. ( FromJSON (PParams (ShelleyLedgerEra era))
, ToJSON (PParams (ShelleyLedgerEra era))
) => CardanoEra era -> Property
ppParamsRoundtrip era =
-- | This tests that, for protocol parameter sets that can roundtrip between PParams and ProtocolParameters
-- (i.e. sets of parameters that are valid/work according to the constraints in both PParams and ProtocolParameters
-- and their conversion functions), deserializing them using PParams FromJSON instance and then serializing
-- again using PParams ToJSON instance results in the same thing.
roundtripBetweenPParamsAndLegacyProtocolParameters :: forall era. ( FromJSON (PParams (ShelleyLedgerEra era))
, ToJSON (PParams (ShelleyLedgerEra era))
) => CardanoEra era -> Property
roundtripBetweenPParamsAndLegacyProtocolParameters era =
property $ do ValidatedSerializedPair { serializedProtocolParameters
, serializedPParams = _
} <- forAll $ genValidSerializedPair era
Expand Down

0 comments on commit 527f16c

Please sign in to comment.