Skip to content

Commit

Permalink
Move getGovActionLifetime to Query.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Jun 6, 2024
1 parent 6b55d51 commit 49370c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 16 additions & 0 deletions cardano-testnet/src/Testnet/Components/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ module Testnet.Components.Query
, checkDRepsNumber
, checkDRepState
, assertNewEpochState
, getGovActionLifetime
) where

import Cardano.Api as Api
import Cardano.Api.Ledger (Credential, DRepState, EpochInterval (..), KeyRole (DRepRole),
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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 49370c0

Please sign in to comment.