diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index 44ff8bf27ae..08a69a7f1d1 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -5,6 +5,12 @@ * Deprecate `Conway` type synonym * Remove crypto parametrization from `ConwayEra` +### testlib + +* Add arbitrary functions to choose registration and unregistration certs in imp-tests. # + * `arbitraryRegTxCert` to choose between `RegTxCert` and `RegDepositTxCert` + * `arbitraryUnRegTxCert` to choose between `UnRegTxCert` and `UnRegDepositTxCert` + ## 1.18.0.0 * Remove `SlotNo` from `CertEnv` and `CertsEnv` diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs index 9c449bd19a9..4e896108cf5 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs @@ -43,6 +43,8 @@ module Test.Cardano.Ledger.Conway.ImpTest ( submitYesVote_, submitFailingVote, trySubmitVote, + arbitraryRegTxCert, + arbitraryUnRegTxCert, registerDRep, unRegisterDRep, updateDRep, @@ -390,6 +392,34 @@ unRegisterDRep drep = do & bodyTxL . certsTxBodyL .~ SSeq.singleton (UnRegDRepTxCert drep refund) +arbitraryUnRegTxCert :: + forall era. + ( ShelleyEraImp era + , ConwayEraTxCert era + ) => + Credential 'Staking -> + ImpTestM era (TxCert era) +arbitraryUnRegTxCert stakingCredential = do + keyDeposit <- getsNES (nesEsL . curPParamsEpochStateL . ppKeyDepositL) + elements + [ UnRegTxCert stakingCredential + , UnRegDepositTxCert stakingCredential keyDeposit + ] + +arbitraryRegTxCert :: + forall era. + ( ShelleyEraImp era + , ConwayEraTxCert era + ) => + Credential 'Staking -> + ImpTestM era (TxCert era) +arbitraryRegTxCert stakingCredential = do + keyDeposit <- getsNES (nesEsL . curPParamsEpochStateL . ppKeyDepositL) + elements + [ RegTxCert stakingCredential + , RegDepositTxCert stakingCredential keyDeposit + ] + -- | Submit a transaction that updates a given DRep updateDRep :: forall era.