Skip to content

Commit

Permalink
Run Imp tests with non-zero DRep thresholds
Browse files Browse the repository at this point in the history
when no DReps are involved in the test cases
  • Loading branch information
teodanciu committed May 8, 2024
1 parent bd69e9c commit 311234a
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 163 deletions.
28 changes: 14 additions & 14 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ spec = do
BabbageImp.spec @era
describe "ConwayImpSpec - post bootstrap (protocol version 10)" $
withImpStateWithProtVer @era (natVersion @10) $ do
Enact.spec @era
Epoch.spec @era
Gov.spec @era
GovCert.spec @era
Utxo.spec @era
Utxos.spec @era
Ratify.spec @era
describe "ENACT" $ Enact.spec @era
describe "EPOCH" $ Epoch.spec @era
describe "GOV" $ Gov.spec @era
describe "GOVCERT" $ GovCert.spec @era
describe "UTXO" $ Utxo.spec @era
describe "UTXOS" $ Utxos.spec @era
describe "RATIFY" $ Ratify.spec @era
describe "ConwayImpSpec - bootstrap phase (protocol version 9)" $
withImpState @era $ do
Enact.relevantDuringBootstrapSpec @era
Epoch.relevantDuringBootstrapSpec @era
Gov.relevantDuringBootstrapSpec @era
GovCert.relevantDuringBootstrapSpec @era
Utxo.spec @era
Utxos.relevantDuringBootstrapSpec @era
Ratify.relevantDuringBootstrapSpec @era
describe "ENACT" $ Enact.relevantDuringBootstrapSpec @era
describe "EPOCH" $ Epoch.relevantDuringBootstrapSpec @era
describe "GOV" $ Gov.relevantDuringBootstrapSpec @era
describe "GOVCERT" $ GovCert.relevantDuringBootstrapSpec @era
describe "UTXO" $ Utxo.spec @era
describe "UTXOS" $ Utxos.relevantDuringBootstrapSpec @era
describe "RATIFY" $ Ratify.relevantDuringBootstrapSpec @era
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ spec ::
, Typeable (Event (EraRule "ENACT" era))
) =>
SpecWith (ImpTestState era)
spec =
describe "ENACT" $ do
relevantDuringBootstrapSpec
treasuryWithdrawalsSpec
noConfidenceSpec
constitutionSpec
actionPriorityCommitteePurposeSpec
hardForkInitiationSpec
spec = do
relevantDuringBootstrapSpec
treasuryWithdrawalsSpec
noConfidenceSpec
constitutionSpec
actionPriorityCommitteePurposeSpec
hardForkInitiationSpec

relevantDuringBootstrapSpec ::
ConwayEraImp era =>
Expand Down Expand Up @@ -225,10 +224,8 @@ hardForkInitiationNoDRepsSpec :: ConwayEraImp era => SpecWith (ImpTestState era)
hardForkInitiationNoDRepsSpec =
it "HardForkInitiation without DRep voting" $ do
(committeeMember :| _) <- registerInitialCommittee
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL . dvtHardForkInitiationL .~ def
& ppPoolVotingThresholdsL . pvtHardForkInitiationL .~ 2 %! 3
modifyPParams $ ppPoolVotingThresholdsL . pvtHardForkInitiationL .~ 2 %! 3
whenPostBootstrap (modifyPParams $ ppDRepVotingThresholdsL . dvtHardForkInitiationL .~ def)
_ <- setupPoolWithStake $ Coin 22_000_000
(stakePoolId1, _, _) <- setupPoolWithStake $ Coin 22_000_000
(stakePoolId2, _, _) <- setupPoolWithStake $ Coin 22_000_000
Expand Down Expand Up @@ -402,10 +399,8 @@ actionPrioritySpec =
let val3 = Coin 1_000_003

it "proposals of same priority are enacted in order of submission" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
modifyPParams $ ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
whenPostBootstrap (modifyPParams $ ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def)

(committeeC :| _) <- registerInitialCommittee
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
Expand Down Expand Up @@ -435,10 +430,9 @@ actionPrioritySpec =
`shouldReturn` val3

it "only the first action of a transaction gets enacted" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
modifyPParams $ ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
whenPostBootstrap (modifyPParams $ ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def)

(committeeC :| _) <- registerInitialCommittee
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
gaids <-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ spec ::
, Event (EraRule "NEWEPOCH" era) ~ ConwayNewEpochEvent era
) =>
SpecWith (ImpTestState era)
spec =
describe "EPOCH" $ do
relevantDuringBootstrapSpec
dRepVotingSpec
treasurySpec
spec = do
relevantDuringBootstrapSpec
dRepVotingSpec
treasurySpec

relevantDuringBootstrapSpec ::
forall era.
Expand Down Expand Up @@ -215,12 +214,7 @@ dRepVotingSpec ::
dRepVotingSpec =
describe "DRep" $ do
it "proposal is accepted after two epochs" $ do
modifyPParams $ \pp ->
pp
& ppDRepVotingThresholdsL
.~ def
{ dvtPPEconomicGroup = 1 %! 1
}
modifyPParams $ ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ 1 %! 1
let getParamValue = getsNES (nesEsL . curPParamsEpochStateL . ppMinFeeAL)
initialParamValue <- getParamValue

Expand Down Expand Up @@ -363,8 +357,8 @@ eventsSpec = describe "Events" $ do
modifyPParams $ \pp ->
pp
& ppGovActionLifetimeL .~ EpochInterval actionLifetime
& ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def
& ppPoolVotingThresholdsL . pvtPPSecurityGroupL .~ 1 %! 1
whenPostBootstrap (modifyPParams $ ppDRepVotingThresholdsL . dvtPPEconomicGroupL .~ def)
propDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppGovActionDepositL
let
proposeCostModel = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ spec ::
SpecWith (ImpTestState era)
spec = do
relevantDuringBootstrapSpec
describe "GOVCERT"
$ it
"A CC that has resigned will need to be first voted out and then voted in to be considered active"
it
"A CC that has resigned will need to be first voted out and then voted in to be considered active"
$ do
(drepCred, _, _) <- setupSingleDRep 1_000_000
passNEpochs 2
Expand Down
23 changes: 9 additions & 14 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/GovSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ spec ::
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
) =>
SpecWith (ImpTestState era)
spec =
describe "GOV" $ do
relevantDuringBootstrapSpec
constitutionSpec
proposalsWithVotingSpec
votingSpec
policySpec
networkIdWithdrawalsSpec
predicateFailuresSpec
unknownCostModelsSpec
spec = do
relevantDuringBootstrapSpec
constitutionSpec
proposalsWithVotingSpec
votingSpec
policySpec
networkIdWithdrawalsSpec
predicateFailuresSpec
unknownCostModelsSpec

relevantDuringBootstrapSpec ::
forall era.
Expand Down Expand Up @@ -848,10 +847,6 @@ votingSpec =
modifyPParams $ \pp ->
pp
& ppGovActionLifetimeL .~ EpochInterval 3
& ppDRepVotingThresholdsL
.~ def
{ dvtUpdateToConstitution = 1 %! 2
}
& ppCommitteeMinSizeL .~ 2
(dRepCred, _, _) <- setupSingleDRep 1_000_000
ccColdCred0 <- KeyHashObj <$> freshKeyHash
Expand Down
Loading

0 comments on commit 311234a

Please sign in to comment.