From 87a4ce1313a5c05a10ae4ddbd62a4734e3d88ad4 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 31 May 2024 17:21:42 +0200 Subject: [PATCH] Add tallying of votes to the "Motion of no confidence" test --- .../Cardano/Testnet/Test/Gov/NoConfidence.hs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs index 4366cf82c58..9dd7f0c3f22 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/NoConfidence.hs @@ -27,6 +27,7 @@ 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 (()) @@ -34,6 +35,7 @@ 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 @@ -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 @@ -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 @@ -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)