Skip to content

Commit

Permalink
Add Arbitrary instances for:
Browse files Browse the repository at this point in the history
* `ConwayTallyPredFailure`
* `EnactState`
* `RatifyState`
* `ConwayGovernance`
  • Loading branch information
lehins committed Mar 22, 2023
1 parent 9669d18 commit e6c5ee8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

* Fix `Arbitrary` for `ConwayTallyState`. #3323
* Consolidate all `Arbitrary` instances from the test package to under a new `testlib`. #3285
* Add `Arbitrary` instances for:
* `ConwayTallyPredFailure`
* `EnactState`
* `RatifyState`
* `ConwayGovernance`


## 1.0.0.0

Expand Down
39 changes: 39 additions & 0 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@ instance Crypto c => Arbitrary (ConwayDCert c) where
-- Cardano.Ledger.Conway.Governance ------------------------------------------------------
------------------------------------------------------------------------------------------

instance
(Era era, Arbitrary (PParams era), Arbitrary (PParamsUpdate era)) =>
Arbitrary (ConwayGovernance era)
where
arbitrary =
ConwayGovernance
<$> arbitrary
<*> arbitrary
<*> arbitrary

instance
(Era era, Arbitrary (PParams era), Arbitrary (PParamsUpdate era)) =>
Arbitrary (RatifyState era)
where
arbitrary =
RatifyState
<$> arbitrary
<*> arbitrary

instance
(Era era, Arbitrary (PParams era), Arbitrary (PParamsUpdate era)) =>
Arbitrary (EnactState era)
where
arbitrary =
EnactState
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary

deriving instance (Era era, Arbitrary (PParamsUpdate era)) => Arbitrary (ConwayTallyState era)

instance (Era era, Arbitrary (PParamsUpdate era)) => Arbitrary (GovernanceActionState era) where
Expand Down Expand Up @@ -134,6 +166,13 @@ instance (Era era, Arbitrary (PParamsUpdate era)) => Arbitrary (GovernanceProced
, GovernanceProposalProcedure <$> arbitrary
]

instance Era era => Arbitrary (ConwayTallyPredFailure era) where
arbitrary =
oneof
[ VoterDoesNotHaveRole <$> arbitrary <*> arbitrary
, GovernanceActionDoesNotExist <$> arbitrary
]

instance
( Arbitrary (PredicateFailure (EraRule "UTXOW" era))
, Arbitrary (PredicateFailure (EraRule "DELEGS" era))
Expand Down

0 comments on commit e6c5ee8

Please sign in to comment.