Skip to content

Commit

Permalink
Add randomised certs for Imptests.
Browse files Browse the repository at this point in the history
- arbitraryRegTxCert
- arbitraryUnRegTxCert
  • Loading branch information
aniketd committed Jan 10, 2025
1 parent 5e1ed75 commit 11858c9
Show file tree
Hide file tree
Showing 2 changed files with 36 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 @@ -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`
Expand Down
30 changes: 30 additions & 0 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module Test.Cardano.Ledger.Conway.ImpTest (
submitYesVote_,
submitFailingVote,
trySubmitVote,
arbitraryRegTxCert,
arbitraryUnRegTxCert,
registerDRep,
unRegisterDRep,
updateDRep,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 11858c9

Please sign in to comment.