diff --git a/cardano-testnet/src/Testnet/EpochStateProcessing.hs b/cardano-testnet/src/Testnet/EpochStateProcessing.hs index 63d1a962d35..9bf4b72da2a 100644 --- a/cardano-testnet/src/Testnet/EpochStateProcessing.hs +++ b/cardano-testnet/src/Testnet/EpochStateProcessing.hs @@ -5,10 +5,10 @@ module Testnet.EpochStateProcessing , findCondition ) where -import Cardano.Api (AnyNewEpochState (..), ConwayEra, EpochNo, File (File), - FoldBlocksError, LedgerStateCondition (..), MonadIO, ShelleyBasedEra, - ValidationMode (FullValidation), foldEpochState, runExceptT, - shelleyBasedEraConstraints) +import Cardano.Api (AnyNewEpochState (..), ConwayEra, ConwayEraOnwards, EpochNo, + File (File), FoldBlocksError, LedgerStateCondition (..), MonadIO, + ValidationMode (FullValidation), conwayEraOnwardsToShelleyBasedEra, + foldEpochState, runExceptT, shelleyBasedEraConstraints) import qualified Cardano.Api as Api import Cardano.Api.Ledger (GovActionId (..)) import qualified Cardano.Api.Ledger as L @@ -58,11 +58,13 @@ findCondition epochStateFoldFunc configurationFile socketPath maxEpochNo = withF Just x -> put (Just x) >> pure ConditionMet Nothing -> pure ConditionNotMet -maybeExtractGovernanceActionIndex :: ShelleyBasedEra ConwayEra -- ^ The era in which the test runs +maybeExtractGovernanceActionIndex :: () + => ConwayEraOnwards ConwayEra -- ^ The era in which the test runs -> Api.TxId -> AnyNewEpochState -> Maybe Word32 -maybeExtractGovernanceActionIndex sbe txid (AnyNewEpochState actualEra newEpochState) = +maybeExtractGovernanceActionIndex ceo txid (AnyNewEpochState actualEra newEpochState) = + let sbe = conwayEraOnwardsToShelleyBasedEra ceo in case testEquality sbe actualEra of Just Refl -> do let proposals = shelleyBasedEraConstraints sbe newEpochState diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/DRepActivity.hs index b0a74c48044..a1a2ba3b961 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/DRepActivity.hs @@ -307,7 +307,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat governanceActionTxId <- retrieveTransactionId execConfig signedProposalTx - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString governanceActionTxId)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString governanceActionTxId)) (unFile configurationFile) (unFile socketPath) (EpochNo timeout) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs index 655d68e9623..cca982bf58d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs @@ -55,7 +55,8 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t work <- H.createDirectoryIfMissing $ tempAbsPath' "work" - let sbe = ShelleyBasedEraConway + let ceo = ConwayEraOnwardsConway + sbe = conwayEraOnwardsToShelleyBasedEra ceo era = toCardanoEra sbe fastTestnetOptions = cardanoDefaultTestnetOptions { cardanoEpochLength = 100 @@ -149,7 +150,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t , "--tx-file", txbodySignedFp ] - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString txidString)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString txidString)) configurationFile socketPath (EpochNo 10) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs index 2c9e8bf50b0..8c90396d40d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedAbstainDRep.hs @@ -25,6 +25,7 @@ import Control.Monad.Catch (MonadCatch) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Lens as AL import Data.ByteString.Lazy.Char8 (pack) +import Data.Data (Typeable) import Data.String (fromString) import qualified Data.Text as Text import Data.Word (Word32) @@ -198,7 +199,6 @@ desiredPoolNumberProposalTest -> m (String, Word32) desiredPoolNumberProposalTest execConfig epochStateView configurationFile socketPath ceo work prefix wallet previousProposalInfo votes change expected epochsToWait = do - let sbe = conwayEraOnwardsToShelleyBasedEra ceo baseDir <- H.createDirectoryIfMissing $ work prefix @@ -210,7 +210,7 @@ desiredPoolNumberProposalTest execConfig epochStateView configurationFile socket makeDesiredPoolNumberChangeProposal execConfig epochStateView (File configurationFile) (File socketPath) ceo baseDir "proposal" previousProposalInfo (fromIntegral change) wallet - voteChangeProposal execConfig epochStateView sbe baseDir "vote" + voteChangeProposal execConfig epochStateView ceo baseDir "vote" governanceActionTxId governanceActionIndex propVotes [] wallet (EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView @@ -298,7 +298,7 @@ makeDesiredPoolNumberChangeProposal execConfig epochStateView configurationFile governanceActionTxId <- retrieveTransactionId execConfig signedProposalTx - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString governanceActionTxId)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString governanceActionTxId)) (unFile configurationFile) (unFile socketPath) (EpochNo 30) @@ -313,10 +313,10 @@ makeDesiredPoolNumberChangeProposal execConfig epochStateView configurationFile return (governanceActionTxId, governanceActionIndex) -voteChangeProposal :: (MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m) +voteChangeProposal :: (Typeable era, MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m) => H.ExecConfig -> EpochStateView - -> ShelleyBasedEra ConwayEra + -> ConwayEraOnwards era -> FilePath -> FilePath -> String @@ -325,10 +325,11 @@ voteChangeProposal :: (MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m) -> [(String, Int)] -> PaymentKeyInfo -> m () -voteChangeProposal execConfig epochStateView sbe work prefix governanceActionTxId governanceActionIndex drepVotes spoVotes wallet = do +voteChangeProposal execConfig epochStateView ceo work prefix governanceActionTxId governanceActionIndex drepVotes spoVotes wallet = do baseDir <- H.createDirectoryIfMissing $ work prefix - let era = toCardanoEra sbe + let sbe = conwayEraOnwardsToShelleyBasedEra ceo + era = toCardanoEra sbe cEra = AnyCardanoEra era drepVoteFiles <- DRep.generateVoteFiles execConfig baseDir "drep-vote-files" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedNoConfidenceDRep.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedNoConfidenceDRep.hs index 224cea33729..ebf9ea05dba 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedNoConfidenceDRep.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/PredefinedNoConfidenceDRep.hs @@ -188,7 +188,6 @@ updateConstitutionalCommittee -> m (String, Word32) updateConstitutionalCommittee execConfig epochStateView configurationFile socketPath ceo work prefix wallet previousProposalInfo votes waitTillEpoch = do - let sbe = conwayEraOnwardsToShelleyBasedEra ceo baseDir <- H.createDirectoryIfMissing $ work prefix @@ -214,7 +213,7 @@ updateConstitutionalCommittee execConfig epochStateView configurationFile socket makeUpdateConstitutionalCommitteeProposal execConfig epochStateView (File configurationFile) (File socketPath) ceo baseDir "proposal" previousProposalInfo [coldKeyHash] wallet - voteChangeProposal execConfig epochStateView sbe baseDir "vote" + voteChangeProposal execConfig epochStateView ceo baseDir "vote" governanceActionTxId governanceActionIndex propVotes (zip (repeat "yes") [1..3]) wallet (EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView @@ -304,7 +303,7 @@ makeUpdateConstitutionalCommitteeProposal execConfig epochStateView configuratio governanceActionTxId <- retrieveTransactionId execConfig signedProposalTx - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString governanceActionTxId)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString governanceActionTxId)) (unFile configurationFile) (unFile socketPath) (EpochNo 10) @@ -351,7 +350,7 @@ testNoConfidenceProposal -> m (String, Word32) testNoConfidenceProposal execConfig epochStateView configurationFile socketPath ceo work prefix wallet previousProposalInfo votes waitTillEpoch = do - let sbe = conwayEraOnwardsToShelleyBasedEra ceo + baseDir <- H.createDirectoryIfMissing $ work prefix let propVotes :: [(String, Int)] @@ -362,7 +361,7 @@ testNoConfidenceProposal execConfig epochStateView configurationFile socketPath makeNoConfidenceProposal execConfig epochStateView (File configurationFile) (File socketPath) ceo baseDir "proposal" previousProposalInfo wallet - voteChangeProposal execConfig epochStateView sbe baseDir "vote" + voteChangeProposal execConfig epochStateView ceo baseDir "vote" governanceActionTxId governanceActionIndex propVotes (zip (repeat "yes") [1..3]) wallet (EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView @@ -444,7 +443,7 @@ makeNoConfidenceProposal execConfig epochStateView configurationFile socketPath governanceActionTxId <- retrieveTransactionId execConfig signedProposalTx - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString governanceActionTxId)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString governanceActionTxId)) (unFile configurationFile) (unFile socketPath) (EpochNo 30) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ProposeNewConstitution.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ProposeNewConstitution.hs index d5d62a23806..6a40ce33fe4 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ProposeNewConstitution.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ProposeNewConstitution.hs @@ -172,7 +172,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n governanceActionTxId <- retrieveTransactionId execConfig signedProposalTx - !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex sbe (fromString governanceActionTxId)) + !propSubmittedResult <- findCondition (maybeExtractGovernanceActionIndex ceo (fromString governanceActionTxId)) configurationFile socketPath (EpochNo 10) @@ -205,7 +205,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n (File configurationFile) (File socketPath) FullValidation - (EpochNo 10) + (EpochNo 30) () (\epochState _ _ -> foldBlocksCheckConstitutionWasRatified constitutionHash constitutionScriptHash epochState)