Skip to content

Commit d9e6924

Browse files
authored
Merge pull request #4821 from IntersectMBO/aniketd/conformance
Enable Imp conformance for DELEG
2 parents 5e1ed75 + caa8898 commit d9e6924

File tree

4 files changed

+86
-70
lines changed
  • eras
  • libs/cardano-ledger-conformance/test/Test/Cardano/Ledger/Conformance

4 files changed

+86
-70
lines changed

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

Lines changed: 74 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ spec = do
211211
mkBasicTxBody
212212
& certsTxBodyL
213213
.~ SSeq.fromList
214-
[UnRegTxCert stakeCred]
214+
-- https://github.com/IntersectMBO/formal-ledger-specifications/issues/636
215+
-- we use this inplace of UnRegTxCert to make conformance-spec happy
216+
[UnRegDepositTxCert stakeCred keyDeposit]
215217
& withdrawalsTxBodyL
216218
.~ Withdrawals
217219
( Map.fromList
@@ -476,6 +478,77 @@ spec = do
476478
expectNotRegistered cred
477479
expectNotDelegatedVote cred
478480

481+
describe "Delegate both stake and vote - separated out for conformance mismatch" $
482+
-- https://github.com/IntersectMBO/formal-ledger-specifications/issues/640
483+
-- TODO: Re-enable after issue is resolved, by removing this override
484+
disableImpInitExpectLedgerRuleConformance $ do
485+
it "Delegate, retire and re-register pool" $ do
486+
expectedDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL
487+
cred <- KeyHashObj <$> freshKeyHash
488+
poolKh <- freshKeyHash
489+
rewardAccount <- registerRewardAccount
490+
registerPool poolKh
491+
drepCred <- KeyHashObj <$> registerDRep
492+
493+
submitTx_ $
494+
mkBasicTx mkBasicTxBody
495+
& bodyTxL . certsTxBodyL
496+
.~ [ RegDepositDelegTxCert
497+
cred
498+
(DelegStakeVote poolKh (DRepCredential drepCred))
499+
expectedDeposit
500+
]
501+
expectDelegatedToPool cred poolKh
502+
expectDelegatedVote cred (DRepCredential drepCred)
503+
504+
let poolLifetime = 2
505+
let poolExpiry = getsNES nesELL <&> \n -> addEpochInterval n $ EpochInterval poolLifetime
506+
507+
poolExpiry >>= \pe ->
508+
submitTx_ $
509+
mkBasicTx mkBasicTxBody
510+
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe]
511+
512+
-- when pool is re-registered after its expiration, all delegations are cleared
513+
passNEpochs $ fromIntegral poolLifetime
514+
expectNotDelegatedToPool cred
515+
registerPoolWithRewardAccount poolKh rewardAccount
516+
expectNotDelegatedToPool cred
517+
-- the vote delegation is kept
518+
expectDelegatedVote cred (DRepCredential drepCred)
519+
520+
-- re-delegate
521+
submitTx_ $
522+
mkBasicTx mkBasicTxBody
523+
& bodyTxL . certsTxBodyL
524+
.~ [ DelegTxCert
525+
cred
526+
(DelegStake poolKh)
527+
]
528+
expectDelegatedToPool cred poolKh
529+
530+
-- when pool is re-registered before its expiration, delegations are kept
531+
poolExpiry >>= \pe ->
532+
submitTx_ $
533+
mkBasicTx mkBasicTxBody
534+
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe]
535+
-- re-register the pool before the expiration time
536+
passNEpochs $ fromIntegral poolLifetime - 1
537+
registerPoolWithRewardAccount poolKh rewardAccount
538+
expectDelegatedToPool cred poolKh
539+
passNEpochs 2
540+
expectDelegatedToPool cred poolKh
541+
542+
-- when pool is retired and re-registered in the same transaction, delegations are kept
543+
pps <- poolParams poolKh rewardAccount
544+
poolExpiry >>= \pe ->
545+
submitTx_ $
546+
mkBasicTx mkBasicTxBody
547+
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe, RegPoolTxCert pps]
548+
549+
expectDelegatedToPool cred poolKh
550+
passNEpochs $ fromIntegral poolLifetime
551+
expectDelegatedToPool cred poolKh
479552
describe "Delegate both stake and vote" $ do
480553
it "Delegate and unregister credentials" $ do
481554
expectedDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL
@@ -531,74 +604,6 @@ spec = do
531604
.~ [DelegTxCert cred (DelegStake poolKh')]
532605
expectDelegatedToPool cred poolKh'
533606
expectDelegatedVote cred (DRepCredential drepCred)
534-
535-
it "Delegate, retire and re-register pool" $ do
536-
expectedDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL
537-
cred <- KeyHashObj <$> freshKeyHash
538-
poolKh <- freshKeyHash
539-
rewardAccount <- registerRewardAccount
540-
registerPool poolKh
541-
drepCred <- KeyHashObj <$> registerDRep
542-
543-
submitTx_ $
544-
mkBasicTx mkBasicTxBody
545-
& bodyTxL . certsTxBodyL
546-
.~ [ RegDepositDelegTxCert
547-
cred
548-
(DelegStakeVote poolKh (DRepCredential drepCred))
549-
expectedDeposit
550-
]
551-
expectDelegatedToPool cred poolKh
552-
expectDelegatedVote cred (DRepCredential drepCred)
553-
554-
let poolLifetime = 2
555-
let poolExpiry = getsNES nesELL <&> \n -> addEpochInterval n $ EpochInterval poolLifetime
556-
557-
poolExpiry >>= \pe ->
558-
submitTx_ $
559-
mkBasicTx mkBasicTxBody
560-
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe]
561-
562-
-- when pool is re-registered after its expiration, all delegations are cleared
563-
passNEpochs $ fromIntegral poolLifetime
564-
expectNotDelegatedToPool cred
565-
registerPoolWithRewardAccount poolKh rewardAccount
566-
expectNotDelegatedToPool cred
567-
-- the vote delegation is kept
568-
expectDelegatedVote cred (DRepCredential drepCred)
569-
570-
-- re-delegate
571-
submitTx_ $
572-
mkBasicTx mkBasicTxBody
573-
& bodyTxL . certsTxBodyL
574-
.~ [ DelegTxCert
575-
cred
576-
(DelegStake poolKh)
577-
]
578-
expectDelegatedToPool cred poolKh
579-
580-
-- when pool is re-registered before its expiration, delegations are kept
581-
poolExpiry >>= \pe ->
582-
submitTx_ $
583-
mkBasicTx mkBasicTxBody
584-
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe]
585-
-- re-register the pool before the expiration time
586-
passNEpochs $ fromIntegral poolLifetime - 1
587-
registerPoolWithRewardAccount poolKh rewardAccount
588-
expectDelegatedToPool cred poolKh
589-
passNEpochs 2
590-
expectDelegatedToPool cred poolKh
591-
592-
-- when pool is retired and re-registered in the same transaction, delegations are kept
593-
pps <- poolParams poolKh rewardAccount
594-
poolExpiry >>= \pe ->
595-
submitTx_ $
596-
mkBasicTx mkBasicTxBody
597-
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert poolKh pe, RegPoolTxCert pps]
598-
599-
expectDelegatedToPool cred poolKh
600-
passNEpochs $ fromIntegral poolLifetime
601-
expectDelegatedToPool cred poolKh
602607
where
603608
expectRegistered cred = do
604609
umap <- getsNES $ nesEsL . esLStateL . lsCertStateL . certDStateL . dsUnifiedL

eras/shelley/impl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
* `FromByronTranslationContext`
1919
* `GenesisDelegCert`, `MIRTarget`, `MIRCert`, `ShelleyDelegCert`
2020

21+
### `testlib`
22+
23+
* Add `disableImpInitExpectLedgerRuleConformance`. #4821
24+
2125
## 1.15.0.0
2226

2327
* Change param of `PoolRank.desirability` to `Word16`

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ module Test.Cardano.Ledger.Shelley.ImpTest (
101101
impSetSeed,
102102
modifyImpInitProtVer,
103103
modifyImpInitExpectLedgerRuleConformance,
104+
disableImpInitExpectLedgerRuleConformance,
104105

105106
-- * Logging
106107
Doc,
@@ -644,6 +645,12 @@ modifyImpInitExpectLedgerRuleConformance f =
644645
& iteExpectLedgerRuleConformanceL .~ f
645646
}
646647

648+
disableImpInitExpectLedgerRuleConformance ::
649+
SpecWith (ImpInit (LedgerSpec era)) ->
650+
SpecWith (ImpInit (LedgerSpec era))
651+
disableImpInitExpectLedgerRuleConformance =
652+
modifyImpInitExpectLedgerRuleConformance $ \_ _ _ _ _ -> pure ()
653+
647654
impLedgerEnv :: EraGov era => NewEpochState era -> ImpTestM era (LedgerEnv era)
648655
impLedgerEnv nes = do
649656
slotNo <- gets impLastTick

libs/cardano-ledger-conformance/test/Test/Cardano/Ledger/Conformance/Imp.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ spec =
153153
describe "Conway Imp conformance" $ do
154154
describe "BBODY" Bbody.spec
155155
describe "CERTS" Certs.spec
156-
xdescribe "DELEG" Deleg.spec
156+
describe "DELEG" Deleg.spec
157157
xdescribe "ENACT" Enact.spec
158158
xdescribe "EPOCH" Epoch.spec
159159
xdescribe "GOV" Gov.spec

0 commit comments

Comments
 (0)