Skip to content

Commit e630cf0

Browse files
committed
WIP - registerStakeCredential improvement
1 parent 231f8f7 commit e630cf0

File tree

10 files changed

+26
-15
lines changed

10 files changed

+26
-15
lines changed

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ instance ShelleyEraImp AllegraEra where
4242

4343
fixupTx = shelleyFixupTx
4444
expectTxSuccess = impShelleyExpectTxSuccess
45+
registerStakeCredential = shelleyRegisterStakeCredential
4546

4647
impAllegraSatisfyNativeScript ::
4748
( AllegraEraScript era

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ instance ShelleyEraImp AlonzoEra where
428428
impSatisfyNativeScript = impAllegraSatisfyNativeScript
429429
fixupTx = alonzoFixupTx
430430
expectTxSuccess = impAlonzoExpectTxSuccess
431+
registerStakeCredential = shelleyRegisterStakeCredential
431432

432433
instance MaryEraImp AlonzoEra
433434

eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ instance ShelleyEraImp BabbageEra where
5353
impSatisfyNativeScript = impAllegraSatisfyNativeScript
5454
fixupTx = babbageFixupTx
5555
expectTxSuccess = impBabbageExpectTxSuccess
56+
registerStakeCredential = shelleyRegisterStakeCredential
5657

5758
babbageFixupTx ::
5859
( HasCallStack

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/LedgerSpec.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ spec = do
8181
modifyPParams $ ppGovActionLifetimeL .~ EpochInterval 2
8282
kh <- freshKeyHash
8383
let cred = KeyHashObj kh
84-
ra <- registerStakeCredentialWithDeposit cred
84+
ra <- registerStakeCredential cred
8585
submitAndExpireProposalToMakeReward cred
8686
balance <- getBalance cred
8787

@@ -106,7 +106,7 @@ spec = do
106106
modifyPParams $ ppGovActionLifetimeL .~ EpochInterval 2
107107
kh <- freshKeyHash
108108
let cred = KeyHashObj kh
109-
ra <- registerStakeCredentialWithDeposit cred
109+
ra <- registerStakeCredential cred
110110
submitAndExpireProposalToMakeReward cred
111111
balance <- getBalance cred
112112

@@ -151,7 +151,7 @@ spec = do
151151
& ppDRepActivityL .~ EpochInterval 1
152152
kh <- freshKeyHash
153153
let cred = KeyHashObj kh
154-
ra <- registerStakeCredentialWithDeposit cred
154+
ra <- registerStakeCredential cred
155155
submitAndExpireProposalToMakeReward cred
156156
balance <- getBalance cred
157157

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ votingSpec =
812812
calculateDRepAcceptedRatio paramChangeGovId `shouldReturn` 1 % 2
813813

814814
kh <- freshKeyHash
815-
_ <- registerStakeCredentialWithDeposit (KeyHashObj kh)
815+
_ <- registerStakeCredential (KeyHashObj kh)
816816
_ <- delegateToDRep (KeyHashObj kh) (Coin 1_000_000) DRepAlwaysNoConfidence
817817
passEpoch
818818
-- AlwaysNoConfidence vote acts like a 'No' vote for actions other than NoConfidence

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module Test.Cardano.Ledger.Conway.ImpTest (
132132
FailBoth (..),
133133
delegateSPORewardAddressToDRep_,
134134
getCommittee,
135-
registerStakeCredentialWithDeposit,
135+
conwayRegisterStakeCredential,
136136
registerPoolWithDeposit,
137137
registerRewardAccountWithDeposit,
138138
) where
@@ -301,6 +301,7 @@ instance ShelleyEraImp ConwayEra where
301301

302302
fixupTx = babbageFixupTx
303303
expectTxSuccess = impBabbageExpectTxSuccess
304+
registerStakeCredential = conwayRegisterStakeCredential
304305

305306
instance MaryEraImp ConwayEra
306307

@@ -1794,12 +1795,14 @@ instance InjectRuleFailure "DELEG" ShelleyDelegPredFailure ConwayEra where
17941795
getCommittee :: ConwayEraGov era => ImpTestM era (StrictMaybe (Committee era))
17951796
getCommittee = getsNES $ nesEsL . epochStateGovStateL . committeeGovStateL
17961797

1797-
registerStakeCredentialWithDeposit ::
1798+
conwayRegisterStakeCredential ::
17981799
forall era.
1799-
ConwayEraImp era =>
1800+
( HasCallStack
1801+
, ConwayEraImp era
1802+
) =>
18001803
Credential 'Staking ->
18011804
ImpTestM era RewardAccount
1802-
registerStakeCredentialWithDeposit cred = do
1805+
conwayRegisterStakeCredential cred = do
18031806
deposit <- getsNES (nesEsL . curPParamsEpochStateL . ppKeyDepositL)
18041807
submitTxAnn_ ("Register Reward Account: " <> T.unpack (credToText cred)) $
18051808
mkBasicTx mkBasicTxBody
@@ -1813,12 +1816,12 @@ registerPoolWithDeposit ::
18131816
KeyHash 'StakePool ->
18141817
ImpTestM era ()
18151818
registerPoolWithDeposit khPool =
1816-
(freshKeyHash >>= registerStakeCredentialWithDeposit . KeyHashObj)
1819+
(freshKeyHash >>= registerStakeCredential . KeyHashObj)
18171820
>>= registerPoolWithRewardAccount khPool
18181821

18191822
registerRewardAccountWithDeposit ::
18201823
forall era.
18211824
ConwayEraImp era =>
18221825
ImpTestM era RewardAccount
18231826
registerRewardAccountWithDeposit = do
1824-
freshKeyHash >>= registerStakeCredentialWithDeposit . KeyHashObj
1827+
freshKeyHash >>= registerStakeCredential . KeyHashObj

eras/dijkstra/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ instance ShelleyEraImp DijkstraEra where
5353

5454
fixupTx = babbageFixupTx
5555
expectTxSuccess = impBabbageExpectTxSuccess
56+
registerStakeCredential = conwayRegisterStakeCredential
5657

5758
instance MaryEraImp DijkstraEra
5859

eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/ImpTest.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ instance ShelleyEraImp MaryEra where
2727
impSatisfyNativeScript = impAllegraSatisfyNativeScript
2828
fixupTx = shelleyFixupTx
2929
expectTxSuccess = impShelleyExpectTxSuccess
30+
registerStakeCredential = shelleyRegisterStakeCredential
3031

3132
class
3233
( ShelleyEraImp era

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module Test.Cardano.Ledger.Shelley.ImpTest (
6969
tryRunImpRuleNoAssertions,
7070
delegateStake,
7171
registerRewardAccount,
72-
registerStakeCredential,
72+
shelleyRegisterStakeCredential,
7373
getRewardAccountFor,
7474
getReward,
7575
lookupReward,
@@ -494,6 +494,8 @@ class
494494

495495
expectTxSuccess :: HasCallStack => Tx era -> ImpTestM era ()
496496

497+
registerStakeCredential :: HasCallStack => Credential 'Staking -> ImpTestM era RewardAccount
498+
497499
defaultInitNewEpochState ::
498500
forall era g s m.
499501
( MonadState s m
@@ -737,6 +739,7 @@ instance
737739

738740
fixupTx = shelleyFixupTx
739741
expectTxSuccess = impShelleyExpectTxSuccess
742+
registerStakeCredential = shelleyRegisterStakeCredential
740743

741744
-- | Figure out all the Byron Addresses that need witnesses as well as all of the
742745
-- KeyHashes for Shelley Key witnesses that are required.
@@ -1482,15 +1485,15 @@ getRewardAccountFor stakingC = do
14821485
networkId <- use (impGlobalsL . to networkId)
14831486
pure $ RewardAccount networkId stakingC
14841487

1485-
registerStakeCredential ::
1488+
shelleyRegisterStakeCredential ::
14861489
forall era.
14871490
( HasCallStack
14881491
, ShelleyEraImp era
14891492
, ShelleyEraTxCert era
14901493
) =>
14911494
Credential 'Staking ->
14921495
ImpTestM era RewardAccount
1493-
registerStakeCredential cred = do
1496+
shelleyRegisterStakeCredential cred = do
14941497
submitTxAnn_ ("Register Reward Account: " <> T.unpack (credToText cred)) $
14951498
mkBasicTx mkBasicTxBody
14961499
& bodyTxL . certsTxBodyL

libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/Imp/QuerySpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ spec = do
204204

205205
kh <- freshKeyHash
206206
let cred = KeyHashObj kh
207-
_ <- registerStakeCredentialWithDeposit cred
207+
_ <- registerStakeCredential cred
208208
_ <- delegateToDRep cred (Coin 2_000_000) DRepAlwaysAbstain
209209

210210
kh2 <- freshKeyHash
211211
let cred2 = KeyHashObj kh2
212-
_ <- registerStakeCredentialWithDeposit cred2
212+
_ <- registerStakeCredential cred2
213213
_ <- delegateToDRep cred2 (Coin 3_000_000) DRepAlwaysNoConfidence
214214

215215
let realDRepCred = DRepCredential credDrep

0 commit comments

Comments
 (0)