Skip to content

Commit

Permalink
Add bootstrap related SPO voting spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucsanszky committed Sep 26, 2024
1 parent ab4f8b2 commit ddf4e38
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ relevantDuringBootstrapSpec ::
relevantDuringBootstrapSpec = do
spoVotesForHardForkInitiation
initiateHardForkWithLessThanMinimalCommitteeSize
spoVotingSpecWhenCCExpired
it "Many CC Cold Credentials map to the same Hot Credential act as many votes" $ do
hotCred NE.:| _ <- registerInitialCommittee
(dRep, _, _) <- setupSingleDRep =<< uniformRM (10_000_000, 1_000_000_000)
Expand Down Expand Up @@ -104,6 +105,77 @@ initiateHardForkWithLessThanMinimalCommitteeSize =
passNEpochs 2
getLastEnactedHardForkInitiation `shouldReturn` SNothing

spoVotingSpecWhenCCExpired ::
forall era.
ConwayEraImp era =>
SpecWith (ImpTestState era)
spoVotingSpecWhenCCExpired = do
describe "When CC expired" $ do
let setup = do
hotCs <- registerInitialCommittee
-- TODO: change the maxtermlength to make the test faster
EpochInterval committeeMaxTermLength <-
getsNES $
nesEsL . curPParamsEpochStateL . ppCommitteeMaxTermLengthL
passNEpochs $ fromIntegral committeeMaxTermLength
ms <- getCommitteeMembers
-- Make sure that committee expired
forM_ ms ccShouldBeExpired
pure hotCs
it "SPOs alone can't enact hard-fork" $ do
hotCs <- setup
(spoC, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
protVer <- getProtVer
gai <- submitGovAction $ HardForkInitiation SNothing (majorFollow protVer)
submitYesVote_ (StakePoolVoter spoC) gai
-- CC members expired so their votes don't count - we are stuck!
submitYesVoteCCs_ hotCs gai
passNEpochs 2
getLastEnactedHardForkInitiation `shouldReturn` SNothing
it "SPOs alone can't enact security group parameter change" $ do
void setup
(spoC, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
gid <-
submitParameterChange SNothing $
emptyPParamsUpdate
& ppuMinFeeRefScriptCostPerByteL .~ SJust (25 %! 2)
submitYesVote_ (StakePoolVoter spoC) gid
passNEpochs 2
getLastEnactedParameterChange `shouldReturn` SNothing
describe "When CC threshold is 0" $ do
let
modifyCommittee f = modifyNES $ \nes ->
nes
& newEpochStateGovStateL . committeeGovStateL %~ f
& newEpochStateDRepPulsingStateL %~ modifyDRepPulser
where
modifyDRepPulser pulser =
case finishDRepPulser pulser of
(snapshot, rState) -> DRComplete snapshot (rState & rsEnactStateL . ensCommitteeL %~ f)
it "SPOs alone can enact hard-fork during bootstrap" $ do
(spoC, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
protVer <- getProtVer
modifyCommittee $ fmap (\cc -> cc {committeeThreshold = 0 %! 1})
gai <- submitGovAction $ HardForkInitiation SNothing (majorFollow protVer)
submitYesVote_ (StakePoolVoter spoC) gai
passNEpochs 2
if bootstrapPhase protVer
then getLastEnactedHardForkInitiation `shouldReturn` SJust (GovPurposeId gai)
else getLastEnactedHardForkInitiation `shouldReturn` SNothing
it "SPOs alone can enact security group parameter change during bootstrap" $ do
(spoC, _, _) <- setupPoolWithStake $ Coin 1_000_000_000
protVer <- getProtVer
modifyCommittee $ fmap (\cc -> cc {committeeThreshold = 0 %! 1})
gai <-
submitParameterChange SNothing $
emptyPParamsUpdate
& ppuMinFeeRefScriptCostPerByteL .~ SJust (25 %! 2)
submitYesVote_ (StakePoolVoter spoC) gai
passNEpochs 2
if bootstrapPhase protVer
then getLastEnactedParameterChange `shouldReturn` SJust (GovPurposeId gai)
else getLastEnactedParameterChange `shouldReturn` SNothing

committeeExpiryResignationDiscountSpec ::
forall era.
ConwayEraImp era =>
Expand Down

0 comments on commit ddf4e38

Please sign in to comment.