Skip to content

Commit

Permalink
Merge pull request #5870 from IntersectMBO/add-tallying-to-no-confide…
Browse files Browse the repository at this point in the history
…nce-test

Add tallying of votes to the "Motion of no confidence" test
  • Loading branch information
palas authored Jun 3, 2024
2 parents 532cac9 + 87a4ce1 commit 6c3a95a
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import qualified Data.Map.Strict as Map
import Data.Maybe.Strict
import Data.String
import qualified Data.Text as Text
import GHC.Exts (IsList (toList))
import Lens.Micro
import System.FilePath ((</>))

import Testnet.Components.Configuration
import Testnet.Components.Query
import Testnet.Components.TestWatchdog
import Testnet.Defaults
import Testnet.EpochStateProcessing (waitForGovActionVotes)
import qualified Testnet.Process.Cli.DRep as DRep
import Testnet.Process.Cli.Keys
import qualified Testnet.Process.Cli.SPO as SPO
Expand Down Expand Up @@ -66,7 +68,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat
era = toCardanoEra sbe
cEra = AnyCardanoEra era
fastTestnetOptions = cardanoDefaultTestnetOptions
{ cardanoEpochLength = 100
{ cardanoEpochLength = 200
, cardanoNodeEra = cEra
}
execConfigOffline <- H.mkExecConfigOffline tempBaseAbsPath
Expand Down Expand Up @@ -195,9 +197,9 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat
pure $ maybeExtractGovernanceActionIndex (fromString governanceActionTxId) anyNewEpochState

let spoVotes :: [(String, Int)]
spoVotes = [("yes", 1), ("yes", 2), ("yes", 3)]
spoVotes = [("yes", 1), ("yes", 2), ("no", 3)]
drepVotes :: [(String, Int)]
drepVotes = [("yes", 1), ("yes", 2), ("yes", 3)]
drepVotes = [("yes", 1), ("yes", 2), ("no", 3)]

spoVoteFiles <- SPO.generateVoteFiles ceo execConfig work "spo-vote-files"
governanceActionTxId governanceActionIndex
Expand All @@ -221,6 +223,23 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat

submitTx execConfig cEra voteTxFp

-- Tally votes
waitForGovActionVotes epochStateView (EpochInterval 1)

govState <- getGovState epochStateView ceo
govActionState <- H.headM $ govState ^. L.cgsProposalsL . L.pPropsL . to toList
let gaDRepVotes = govActionState ^. L.gasDRepVotesL . to toList
gaSpoVotes = govActionState ^. L.gasStakePoolVotesL . to toList

length (filter ((== L.VoteYes) . snd) gaDRepVotes) === 2
length (filter ((== L.VoteNo) . snd) gaDRepVotes) === 1
length (filter ((== L.Abstain) . snd) gaDRepVotes) === 0
length drepVotes === length gaDRepVotes
length (filter ((== L.VoteYes) . snd) gaSpoVotes) === 2
length (filter ((== L.VoteNo) . snd) gaSpoVotes) === 1
length (filter ((== L.Abstain) . snd) gaSpoVotes) === 0
length spoVotes === length gaSpoVotes

-- Step 4. We confirm the no confidence motion has been ratified by checking
-- for an empty constitutional committee.
H.nothingFailM $ watchEpochStateUpdate epochStateView (EpochInterval 10) (return . committeeIsPresent False)
Expand Down

0 comments on commit 6c3a95a

Please sign in to comment.