-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generators for EraBasedProtocolParametersUpdate
- Loading branch information
1 parent
95dbeb7
commit e86eba6
Showing
2 changed files
with
124 additions
and
20 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
cardano-api/gen/Test/Gen/Cardano/Api/ProtocolParameters.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
module Test.Gen.Cardano.Api.ProtocolParameters where | ||
|
||
import Cardano.Api | ||
import Cardano.Api.Ledger | ||
import Cardano.Api.ProtocolParameters | ||
|
||
import Test.Gen.Cardano.Api.Typed (genCostModels) | ||
|
||
import Test.Cardano.Ledger.Alonzo.Arbitrary () | ||
import Test.Cardano.Ledger.Conway.Arbitrary () | ||
|
||
import Hedgehog (MonadGen) | ||
import qualified Hedgehog.Gen as Gen | ||
import qualified Hedgehog.Gen.QuickCheck as Q | ||
|
||
genStrictMaybe :: MonadGen m => m a -> m (StrictMaybe a) | ||
genStrictMaybe gen = | ||
Gen.sized $ \n -> | ||
Gen.frequency [ | ||
(2, pure SNothing), | ||
(1 + fromIntegral n, SJust<$> gen) | ||
] | ||
|
||
genCommonProtocolParametersUpdate :: MonadGen m => m CommonProtocolParametersUpdate | ||
genCommonProtocolParametersUpdate = | ||
CommonProtocolParametersUpdate | ||
<$> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
|
||
genDeprecatedAfterMaryPParams :: MonadGen m => m (DeprecatedAfterMaryPParams era) | ||
genDeprecatedAfterMaryPParams = DeprecatedAfterMaryPParams <$> genStrictMaybe Q.arbitrary | ||
|
||
genShelleyToAlonzoPParams :: MonadGen m => m (ShelleyToAlonzoPParams era) | ||
genShelleyToAlonzoPParams = | ||
ShelleyToAlonzoPParams | ||
<$> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
|
||
genAlonzoOnwardsPParams :: MonadGen m => m (AlonzoOnwardsPParams era) | ||
genAlonzoOnwardsPParams = | ||
AlonzoOnwardsPParams | ||
<$> genStrictMaybe genCostModels | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
|
||
genIntroducedInBabbagePParams :: MonadGen m => m (IntroducedInBabbagePParams era) | ||
genIntroducedInBabbagePParams = IntroducedInBabbagePParams <$> genStrictMaybe Q.arbitrary | ||
|
||
genIntroducedInConwayPParams :: MonadGen m => m (IntroducedInConwayPParams era) | ||
genIntroducedInConwayPParams = | ||
IntroducedInConwayPParams | ||
<$> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
<*> genStrictMaybe Q.arbitrary | ||
|
||
genShelleyEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate ShelleyEra) | ||
genShelleyEraBasedProtocolParametersUpdate = | ||
ShelleyEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genDeprecatedAfterMaryPParams | ||
<*> genShelleyToAlonzoPParams | ||
|
||
genAllegraEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate AllegraEra) | ||
genAllegraEraBasedProtocolParametersUpdate = | ||
AllegraEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genDeprecatedAfterMaryPParams | ||
<*> genShelleyToAlonzoPParams | ||
|
||
genMaryEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate MaryEra) | ||
genMaryEraBasedProtocolParametersUpdate = | ||
MaryEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genDeprecatedAfterMaryPParams | ||
<*> genShelleyToAlonzoPParams | ||
|
||
genAlonzoEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate AlonzoEra) | ||
genAlonzoEraBasedProtocolParametersUpdate = | ||
AlonzoEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genShelleyToAlonzoPParams | ||
<*> genAlonzoOnwardsPParams | ||
|
||
genBabbageEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate BabbageEra) | ||
genBabbageEraBasedProtocolParametersUpdate = | ||
BabbageEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genAlonzoOnwardsPParams | ||
<*> genIntroducedInBabbagePParams | ||
|
||
genConwayEraBasedProtocolParametersUpdate :: MonadGen m => m (EraBasedProtocolParametersUpdate ConwayEra) | ||
genConwayEraBasedProtocolParametersUpdate = | ||
ConwayEraBasedProtocolParametersUpdate | ||
<$> genCommonProtocolParametersUpdate | ||
<*> genAlonzoOnwardsPParams | ||
<*> genIntroducedInBabbagePParams | ||
<*> genIntroducedInConwayPParams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters