diff --git a/cardano-testnet/src/Testnet/Components/Query.hs b/cardano-testnet/src/Testnet/Components/Query.hs index 1a054a70544..020e6770ba8 100644 --- a/cardano-testnet/src/Testnet/Components/Query.hs +++ b/cardano-testnet/src/Testnet/Components/Query.hs @@ -35,6 +35,7 @@ module Testnet.Components.Query , checkDRepsNumber , checkDRepState , assertNewEpochState + , getGovActionLifetime ) where import Cardano.Api as Api @@ -42,9 +43,11 @@ import Cardano.Api.Ledger (Credential, DRepState, EpochInterval (..), StandardCrypto) import Cardano.Api.Shelley (ShelleyLedgerEra, fromShelleyTxIn, fromShelleyTxOut) +import Cardano.Ledger.Api (ConwayGovState) import qualified Cardano.Ledger.Api as L import qualified Cardano.Ledger.Coin as L import qualified Cardano.Ledger.Conway.Governance as L +import Cardano.Ledger.Conway.PParams (ConwayEraPParams) import qualified Cardano.Ledger.Conway.PParams as L import qualified Cardano.Ledger.Shelley.LedgerState as L import qualified Cardano.Ledger.UTxO as L @@ -550,3 +553,16 @@ assertNewEpochState epochStateView sbe maxWait lens expected = withFrozenCallSta Refl <- H.leftFail $ assertErasEqual sbe actualEra pure $ newEpochState ^. lens + +-- | Obtains the @govActionLifetime@ from the protocol parameters. +-- The @govActionLifetime@ or governance action maximum lifetime in epochs is +-- the number of epochs such that a governance action submitted during an epoch @e@ +-- expires if it is still not ratified as of the end of epoch: @e + govActionLifetime + 1@. +getGovActionLifetime :: (ConwayEraPParams (ShelleyLedgerEra era), H.MonadAssertion m, MonadTest m, MonadIO m) + => EpochStateView + -> ConwayEraOnwards era + -> m EpochInterval +getGovActionLifetime epochStateView ceo = do + govState :: ConwayGovState era <- getGovState epochStateView ceo + return $ govState ^. L.cgsCurPParamsL + . L.ppGovActionLifetimeL diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs index 846b4117212..934062d5549 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs @@ -9,18 +9,14 @@ module Cardano.Testnet.Test.Gov.GovActionTimeout ) where import Cardano.Api as Api -import Cardano.Api.Eon.ShelleyBasedEra (ShelleyLedgerEra) import Cardano.Api.Ledger (EpochInterval (EpochInterval, unEpochInterval)) -import Cardano.Ledger.Conway.Core (ConwayEraPParams, ppGovActionLifetimeL) -import Cardano.Ledger.Conway.Governance (ConwayGovState, cgsCurPParamsL) import Cardano.Testnet import Prelude import Control.Monad (void) import Data.String (fromString) -import Lens.Micro ((^.)) import System.FilePath (()) import Testnet.Components.Query @@ -29,7 +25,7 @@ import Testnet.Process.Run (mkExecConfig) import Testnet.Property.Util (integrationWorkspace) import Testnet.Types -import Hedgehog (MonadTest, Property) +import Hedgehog (Property) import qualified Hedgehog as H import qualified Hedgehog.Extras as H @@ -99,15 +95,3 @@ hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \te mGovernanceActionTxIx H.=== Nothing --- | Obtains the @govActionLifetime@ from the protocol parameters. --- The @govActionLifetime@ or governance action maximum lifetime in epochs is --- the number of epochs such that a governance action submitted during an epoch @e@ --- expires if it is still not ratified as of the end of epoch: @e + govActionLifetime + 1@. -getGovActionLifetime :: (ConwayEraPParams (ShelleyLedgerEra era), H.MonadAssertion m, MonadTest m, MonadIO m) - => EpochStateView - -> ConwayEraOnwards era - -> m EpochInterval -getGovActionLifetime epochStateView ceo = do - govState :: ConwayGovState era <- getGovState epochStateView ceo - return $ govState ^. cgsCurPParamsL - . ppGovActionLifetimeL