Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write goverance unit tests and examples for conway features #3152

Closed
9 of 10 tasks
JaredCorduan opened this issue Nov 18, 2022 · 3 comments
Closed
9 of 10 tasks

write goverance unit tests and examples for conway features #3152

JaredCorduan opened this issue Nov 18, 2022 · 3 comments

Comments

@JaredCorduan
Copy link
Contributor

JaredCorduan commented Nov 18, 2022

Here is a non-comprehensive list of unit tests we might wish for conway:

  • if you submit a governance action, it is add to the governance state as the latest action
  • you can add a governance action and vote on the action at the same time. or vote on a different existing action.
  • if a CC/DRep/SPO votes on a governance action, their vote appears in the governance state
  • if a stake credential delegates to a DRep, the delegation relation is updated as expected
  • CC members cannot vote votes do not count after their term expires
  • The CC enters a state of no confidence CC votes are counted as No if too many members retire
  • If a stake credential delegates to a pre-defined DRep (abstain or no confidence), their stake is accounted for in ratification
  • a governance action with enough votes is staged for enactment on the epoch boundary (we probably want a test for each action type)
  • governance actions that never get enough votes are eventually expired
  • governance actions are dropped when a motion of no confidence is enacted
@lehins
Copy link
Collaborator

lehins commented Mar 8, 2024

I think at this point we just need to confirm that we already have implemented all these scenarios.

From a quick glance I think this is the case, but it would be nice for someone to lookup those individual tests and confirm this for sure

@lehins lehins added this to Conway May 20, 2024
@lehins lehins moved this to To do in Conway May 20, 2024
@teodanciu teodanciu moved this from To do to In progress in Conway Jul 29, 2024
@teodanciu
Copy link
Contributor

teodanciu commented Jul 29, 2024

CC members cannot vote votes do not count after their term expires

A test for this exists in RatifySpec , so ticking it off the list.

@lehins
Copy link
Collaborator

lehins commented Sep 6, 2024

If a stake credential delegates to a pre-defined DRep (abstain or no confidence), their stake is accounted for in ratification

Test for this exists in

describe "Predefined DReps" $ do
it "acceptedRatio with default DReps" $ do
(drep1, _, committeeGovId) <- electBasicCommittee
(drep2, drep2Staking, _) <- setupSingleDRep 1_000_000
paramChangeGovId <- submitParameterChange SNothing $ def & ppuMinFeeAL .~ SJust (Coin 3000)
submitYesVote_ (DRepVoter drep1) paramChangeGovId
passEpoch
calculateDRepAcceptedRatio paramChangeGovId `shouldReturn` 1 % 2
_ <- delegateToDRep 1_000_000 DRepAlwaysNoConfidence
passEpoch
-- AlwaysNoConfidence vote acts like a 'No' vote for actions other than NoConfidence
calculateDRepAcceptedRatio paramChangeGovId `shouldReturn` 1 % 3
redelegateDRep drep2 DRepAlwaysAbstain drep2Staking
passEpoch
-- AlwaysAbstain vote acts like 'Abstain' vote
calculateDRepAcceptedRatio paramChangeGovId `shouldReturn` 1 % 2
noConfidenceGovId <- submitGovAction $ NoConfidence (SJust committeeGovId)
submitYesVote_ (DRepVoter drep1) noConfidenceGovId
passEpoch
-- AlwaysNoConfidence vote acts like 'Yes' for NoConfidence actions
calculateDRepAcceptedRatio noConfidenceGovId `shouldReturn` 2 % 2
it "AlwaysNoConfidence" $ do
(drep1, _, committeeGovId) <- electBasicCommittee
initialMembers <- getCommitteeMembers
-- drep2 won't explicitly vote, but eventually delegate to AlwaysNoConfidence
(drep2, drep2Staking, _) <- setupSingleDRep 1_000_000
-- we register another drep with the same stake as drep1, which will vote No -
-- in order to make it necessary to redelegate to AlwaysNoConfidence,
-- rather than just unregister
(drep3, _, _) <- setupSingleDRep 1_000_000
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
noConfidenceGovId <- submitGovAction $ NoConfidence (SJust committeeGovId)
submitYesVote_ (DRepVoter drep1) noConfidenceGovId
submitVote_ VoteNo (DRepVoter drep3) noConfidenceGovId
submitYesVote_ (StakePoolVoter spoC) noConfidenceGovId
passEpoch
-- drep1 doesn't have enough stake to enact NoConfidence
isDRepAccepted noConfidenceGovId `shouldReturn` False
passEpoch
getCommitteeMembers `shouldReturn` initialMembers
-- drep2 unregisters, but NoConfidence still doesn't pass, because there's a tie between drep1 and drep3
unRegisterDRep drep2
passEpoch
isDRepAccepted noConfidenceGovId `shouldReturn` False
submitTxAnn_ "Redelegate to AlwaysNoConfidence " $
mkBasicTx mkBasicTxBody
& bodyTxL . certsTxBodyL
.~ SSeq.fromList
[ DelegTxCert @era
drep2Staking
(DelegVote DRepAlwaysNoConfidence)
]
passEpoch
isDRepAccepted noConfidenceGovId `shouldReturn` True
passEpoch
getCommitteeMembers `shouldReturn` mempty
it "AlwaysAbstain" $ do
let getTreasury = getsNES (nesEsL . esAccountStateL . asTreasuryL)
(drep1, comMember, _) <- electBasicCommittee
initialTreasury <- getTreasury
(drep2, drep2Staking, _) <- setupSingleDRep 1_000_000
rewardAccount <- registerRewardAccount
govId <- submitTreasuryWithdrawals [(rewardAccount, initialTreasury)]
submitYesVote_ (CommitteeVoter comMember) govId
submitYesVote_ (DRepVoter drep1) govId
submitVote_ VoteNo (DRepVoter drep2) govId
passEpoch
-- drep1 doesn't have enough stake to enact the withdrawals
isDRepAccepted govId `shouldReturn` False
passEpoch
getTreasury `shouldReturn` initialTreasury
redelegateDRep drep2 DRepAlwaysAbstain drep2Staking
passEpoch
-- the delegation turns the No vote into an Abstain, enough to pass the action
isDRepAccepted govId `shouldReturn` True
passEpoch
getTreasury `shouldReturn` zero
it "DRepAlwaysNoConfidence is sufficient to pass NoConfidence" $ do
modifyPParams $ \pp ->
pp
& ppPoolVotingThresholdsL . pvtMotionNoConfidenceL .~ 0 %! 1
& ppDRepVotingThresholdsL . dvtMotionNoConfidenceL .~ 1 %! 1
& ppCoinsPerUTxOByteL .~ CoinPerByte (Coin 1)
(drep, _, committeeId) <- electBasicCommittee
_ <- delegateToDRep 300 DRepAlwaysNoConfidence
noConfidence <- submitGovAction (NoConfidence (SJust committeeId))
submitYesVote_ (DRepVoter drep) noConfidence
logAcceptedRatio noConfidence
passNEpochs 2
getLastEnactedCommittee `shouldReturn` SJust (GovPurposeId noConfidence)

Closing as that was the last point in the list we needed to check.

@lehins lehins closed this as completed Sep 6, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Conway Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants