Skip to content

Commit 5ee671e

Browse files
committed
Add Imp tests to cover more cases of active/inactive committee
1 parent 7c30e13 commit 5ee671e

File tree

1 file changed

+188
-42
lines changed
  • eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp

1 file changed

+188
-42
lines changed

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

Lines changed: 188 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,48 @@ spoAndCCVotingSpec = do
143143

144144
getLastEnactedParameterChange `shouldReturn` SNothing
145145
getsPParams ppMinFeeRefScriptCostPerByteL `shouldReturn` initialRefScriptBaseFee
146+
-- https://github.com/IntersectMBO/cardano-ledger/issues/5418
147+
-- TODO: Re-enable after issue is resolved, by removing this override
148+
disableInConformanceIt "Committee proposals pass" $
149+
whenPostBootstrap $ do
150+
modifyPParams $ \pp ->
151+
pp
152+
& ppCommitteeMinSizeL .~ 2
153+
& ppCommitteeMaxTermLengthL .~ EpochInterval 50
154+
coldCommitteeActive <- KeyHashObj <$> freshKeyHash
155+
coldCommitteeInactive <- KeyHashObj <$> freshKeyHash
156+
startingEpoch <- getsNES nesELL
157+
maxTermLength <- getsPParams ppCommitteeMaxTermLengthL
158+
(drep, _, _) <- setupSingleDRep 1_000_000_000
159+
(spo, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
160+
let
161+
committeeMap =
162+
[ (coldCommitteeActive, addEpochInterval startingEpoch maxTermLength)
163+
, (coldCommitteeInactive, addEpochInterval startingEpoch $ EpochInterval 5)
164+
]
165+
initialCommittee <- getCommitteeMembers
166+
committeeActionId <-
167+
impAnn "Submit committee update"
168+
. submitGovAction
169+
$ UpdateCommittee
170+
SNothing
171+
initialCommittee
172+
committeeMap
173+
(1 %! 1)
174+
submitYesVote_ (DRepVoter drep) committeeActionId
175+
submitYesVote_ (StakePoolVoter spo) committeeActionId
176+
passNEpochs 5
177+
getCommitteeMembers `shouldReturn` Map.keysSet committeeMap
178+
committeeProposal <-
179+
elements
180+
[ NoConfidence (SJust (GovPurposeId committeeActionId))
181+
, UpdateCommittee (SJust (GovPurposeId committeeActionId)) Set.empty [] (0 %! 1)
182+
]
183+
committeeActionId2 <- submitGovAction committeeProposal
184+
submitYesVote_ (DRepVoter drep) committeeActionId2
185+
submitYesVote_ (StakePoolVoter spo) committeeActionId2
186+
passNEpochs 2
187+
getLastEnactedCommittee `shouldReturn` SJust (GovPurposeId committeeActionId2)
146188
describe "When CC threshold is 0" $ do
147189
-- During the bootstrap phase, proposals that modify the committee are not allowed,
148190
-- hence we need to directly set the threshold for the initial members
@@ -234,50 +276,154 @@ spoAndCCVotingSpec = do
234276
newConstitution <- arbitrary
235277
constitutionActionId <- submitGovAction $ NewConstitution SNothing newConstitution
236278
logRatificationChecks constitutionActionId
279+
passEpoch
280+
ccShouldBeExpired coldCommitteeInactive
281+
passEpoch
282+
ccShouldNotBeExpired coldCommitteeActive
283+
getConstitution `shouldNotReturn` newConstitution
284+
-- https://github.com/IntersectMBO/cardano-ledger/issues/5418
285+
-- TODO: Re-enable after issue is resolved, by removing this override
286+
disableInConformanceIt
287+
"Constitution cannot be changed if committee is not active because it doesn't have registered hot credentials"
288+
$ whenPostBootstrap
289+
$ do
290+
modifyPParams $ \pp ->
291+
pp
292+
& ppCommitteeMinSizeL .~ 2
293+
modifyCommittee $ fmap (committeeThresholdL .~ 0 %! 1)
294+
(drep, _, _) <- setupSingleDRep 1_000_000_000
295+
SJust committee <- getCommittee
296+
committeeThreshold committee `shouldBe` 0 %! 1
297+
Map.size (committeeMembers committee) `shouldBe` 2
298+
forM_ (Map.keys $ committeeMembers committee) ccShouldNotBeExpired
299+
oldConstitution <- getConstitution
300+
(proposal, _) <- mkConstitutionProposal SNothing
301+
gaiConstitution <- submitProposal proposal
302+
submitYesVote_ (DRepVoter drep) gaiConstitution
303+
passNEpochs 2
304+
getConstitution `shouldReturn` oldConstitution
305+
it
306+
"Constitution can be changed when an active committee doesn't vote"
307+
$ whenPostBootstrap
308+
$ do
309+
modifyPParams $ \pp ->
310+
pp
311+
& ppCommitteeMinSizeL .~ 2
312+
modifyCommittee $ fmap (committeeThresholdL .~ 0 %! 1)
313+
(drep, _, _) <- setupSingleDRep 1_000_000_000
314+
SJust committee <- getCommittee
315+
committeeThreshold committee `shouldBe` 0 %! 1
316+
Map.size (committeeMembers committee) `shouldBe` 2
317+
forM_ (Map.keys $ committeeMembers committee) ccShouldNotBeExpired
318+
(proposal, newConstitution) <- mkConstitutionProposal SNothing
319+
gaiConstitution <- submitProposal proposal
320+
submitYesVote_ (DRepVoter drep) gaiConstitution
321+
mapM_ registerCommitteeHotKey (Map.keys $ committeeMembers committee)
322+
passNEpochs 2
323+
getConstitution `shouldReturn` newConstitution
324+
it
325+
"Constitution can be changed regardless of active committee votes"
326+
$ whenPostBootstrap
327+
$ do
328+
modifyPParams $ \pp ->
329+
pp
330+
& ppCommitteeMinSizeL .~ 2
331+
modifyCommittee $ fmap (committeeThresholdL .~ 0 %! 1)
332+
(drep, _, _) <- setupSingleDRep 1_000_000_000
333+
SJust committee <- getCommittee
334+
committeeThreshold committee `shouldBe` 0 %! 1
335+
Map.size (committeeMembers committee) `shouldBe` 2
336+
forM_ (Map.keys $ committeeMembers committee) ccShouldNotBeExpired
337+
(proposal, newConstitution) <- mkConstitutionProposal SNothing
338+
gaiConstitution <- submitProposal proposal
339+
submitYesVote_ (DRepVoter drep) gaiConstitution
340+
hotKeys <- mapM registerCommitteeHotKey (Map.keys $ committeeMembers committee)
341+
forM_ hotKeys $ \c ->
342+
oneof
343+
[ return ()
344+
, submitYesVote_ (CommitteeVoter c) gaiConstitution
345+
, submitVote_ VoteNo (CommitteeVoter c) gaiConstitution
346+
]
347+
passNEpochs 2
348+
getConstitution `shouldReturn` newConstitution
349+
it
350+
"Constitution can be changed if min committee size is 0"
351+
. whenPostBootstrap
352+
$ do
353+
modifyPParams $ \pp ->
354+
pp
355+
& ppDRepVotingThresholdsL . dvtUpdateToConstitutionL .~ (0 %! 1)
356+
& ppCommitteeMinSizeL .~ 0
357+
& ppCommitteeMaxTermLengthL .~ EpochInterval 50
358+
coldCommitteeActive <- KeyHashObj <$> freshKeyHash
359+
coldCommitteeInactive <- KeyHashObj <$> freshKeyHash
360+
startingEpoch <- getsNES nesELL
361+
maxTermLength <- getsPParams ppCommitteeMaxTermLengthL
362+
(dRep, _, _) <- setupSingleDRep 1_000_000_000
363+
(spo, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
364+
let
365+
committeeMap =
366+
[ (coldCommitteeActive, addEpochInterval startingEpoch maxTermLength)
367+
, (coldCommitteeInactive, addEpochInterval startingEpoch $ EpochInterval 5)
368+
]
369+
initialCommittee <- getCommitteeMembers
370+
committeeActionId <-
371+
impAnn "Submit committee update"
372+
. submitGovAction
373+
$ UpdateCommittee
374+
SNothing
375+
initialCommittee
376+
committeeMap
377+
(0 %! 1)
378+
submitYesVote_ (DRepVoter dRep) committeeActionId
379+
submitYesVote_ (StakePoolVoter spo) committeeActionId
380+
passNEpochs 2
381+
getCommitteeMembers `shouldReturn` Map.keysSet committeeMap
382+
passNEpochs 3
383+
newConstitution <- arbitrary
384+
constitutionActionId <- submitGovAction $ NewConstitution SNothing newConstitution
385+
logRatificationChecks constitutionActionId
386+
passNEpochs 2
387+
getConstitution `shouldReturn` newConstitution
388+
describe "When CC threshold is not 0" $ do
389+
it "Constitution cannot be changed if min committee size is 0"
390+
. whenPostBootstrap
391+
$ do
392+
modifyPParams $ \pp ->
393+
pp
394+
& ppDRepVotingThresholdsL . dvtUpdateToConstitutionL .~ (0 %! 1)
395+
& ppCommitteeMinSizeL .~ 0
396+
& ppCommitteeMaxTermLengthL .~ EpochInterval 50
397+
coldCommitteeActive <- KeyHashObj <$> freshKeyHash
398+
coldCommitteeInactive <- KeyHashObj <$> freshKeyHash
399+
startingEpoch <- getsNES nesELL
400+
maxTermLength <- getsPParams ppCommitteeMaxTermLengthL
401+
(dRep, _, _) <- setupSingleDRep 1_000_000_000
402+
(spo, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
403+
let
404+
committeeMap =
405+
[ (coldCommitteeActive, addEpochInterval startingEpoch maxTermLength)
406+
, (coldCommitteeInactive, addEpochInterval startingEpoch $ EpochInterval 5)
407+
]
408+
initialCommittee <- getCommitteeMembers
409+
committeeActionId <-
410+
impAnn "Submit committee update"
411+
. submitGovAction
412+
$ UpdateCommittee
413+
SNothing
414+
initialCommittee
415+
committeeMap
416+
(1 %! 1)
417+
submitYesVote_ (DRepVoter dRep) committeeActionId
418+
submitYesVote_ (StakePoolVoter spo) committeeActionId
419+
passNEpochs 2
420+
getCommitteeMembers `shouldReturn` Map.keysSet committeeMap
421+
passNEpochs 3
422+
newConstitution <- arbitrary
423+
constitutionActionId <- submitGovAction $ NewConstitution SNothing newConstitution
424+
logRatificationChecks constitutionActionId
237425
passNEpochs 2
238426
getConstitution `shouldNotReturn` newConstitution
239-
-- https://github.com/IntersectMBO/cardano-ledger/issues/5418
240-
-- TODO: Re-enable after issue is resolved, by removing this override
241-
disableInConformanceIt "Committee proposals pass with inactive committee" $
242-
whenPostBootstrap $ do
243-
modifyPParams $ \pp ->
244-
pp
245-
& ppCommitteeMinSizeL .~ 2
246-
& ppCommitteeMaxTermLengthL .~ EpochInterval 50
247-
coldCommitteeActive <- KeyHashObj <$> freshKeyHash
248-
coldCommitteeInactive <- KeyHashObj <$> freshKeyHash
249-
startingEpoch <- getsNES nesELL
250-
maxTermLength <- getsPParams ppCommitteeMaxTermLengthL
251-
(drep, _, _) <- setupSingleDRep 1_000_000_000
252-
(spo, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
253-
let
254-
committeeMap =
255-
[ (coldCommitteeActive, addEpochInterval startingEpoch maxTermLength)
256-
, (coldCommitteeInactive, addEpochInterval startingEpoch $ EpochInterval 5)
257-
]
258-
initialCommittee <- getCommitteeMembers
259-
committeeActionId <-
260-
impAnn "Submit committee update"
261-
. submitGovAction
262-
$ UpdateCommittee
263-
SNothing
264-
initialCommittee
265-
committeeMap
266-
(1 %! 1)
267-
submitYesVote_ (DRepVoter drep) committeeActionId
268-
submitYesVote_ (StakePoolVoter spo) committeeActionId
269-
passNEpochs 5
270-
getCommitteeMembers `shouldReturn` Map.keysSet committeeMap
271-
committeeProposal <-
272-
elements
273-
[ NoConfidence (SJust (GovPurposeId committeeActionId))
274-
, UpdateCommittee (SJust (GovPurposeId committeeActionId)) Set.empty [] (0 %! 1)
275-
]
276-
committeeActionId2 <- submitGovAction committeeProposal
277-
submitYesVote_ (DRepVoter drep) committeeActionId2
278-
submitYesVote_ (StakePoolVoter spo) committeeActionId2
279-
passNEpochs 2
280-
getLastEnactedCommittee `shouldReturn` SJust (GovPurposeId committeeActionId2)
281427

282428
committeeExpiryResignationDiscountSpec ::
283429
forall era.

0 commit comments

Comments
 (0)