-
Notifications
You must be signed in to change notification settings - Fork 732
Add test for timeout of gov actions #5873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/GovActionTimeout.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Cardano.Testnet.Test.Gov.GovActionTimeout | ||
( hprop_check_gov_action_timeout | ||
) where | ||
|
||
import Cardano.Api as Api | ||
import Cardano.Api.Ledger (EpochInterval (EpochInterval, unEpochInterval)) | ||
|
||
import Cardano.Testnet | ||
|
||
import Prelude | ||
|
||
import Control.Monad (void) | ||
import Data.String (fromString) | ||
import System.FilePath ((</>)) | ||
|
||
import Testnet.Components.Query | ||
import Testnet.Process.Cli.DRep (makeActivityChangeProposal) | ||
import Testnet.Process.Run (mkExecConfig) | ||
import Testnet.Property.Util (integrationWorkspace) | ||
import Testnet.Types | ||
|
||
import Hedgehog (Property) | ||
import qualified Hedgehog as H | ||
import qualified Hedgehog.Extras as H | ||
|
||
-- | Test that SPOs cannot vote on a Protocol Parameter change | ||
-- | Execute me with: | ||
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Gov Action Timeout/"'@ | ||
hprop_check_gov_action_timeout :: Property | ||
hprop_check_gov_action_timeout = integrationWorkspace "gov-action-timeout" $ \tempAbsBasePath' -> | ||
H.runWithDefaultWatchdog_ $ do | ||
-- Start a local test net | ||
conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' | ||
let tempAbsPath' = unTmpAbsPath tempAbsPath | ||
tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath | ||
|
||
work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work" | ||
|
||
-- Create default testnet | ||
let ceo = ConwayEraOnwardsConway | ||
sbe = conwayEraOnwardsToShelleyBasedEra ceo | ||
era = toCardanoEra sbe | ||
cEra = AnyCardanoEra era | ||
fastTestnetOptions = cardanoDefaultTestnetOptions | ||
{ cardanoEpochLength = 200 | ||
, cardanoNodeEra = cEra | ||
} | ||
|
||
TestnetRuntime | ||
{ testnetMagic | ||
, poolNodes | ||
, wallets=wallet0:_ | ||
, configurationFile | ||
} | ||
<- cardanoTestnetDefault fastTestnetOptions conf | ||
|
||
PoolNode{poolRuntime} <- H.headM poolNodes | ||
poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime | ||
execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic | ||
let socketPath = nodeSocketPath poolRuntime | ||
|
||
epochStateView <- getEpochStateView configurationFile socketPath | ||
|
||
H.note_ $ "Sprocket: " <> show poolSprocket1 | ||
H.note_ $ "Abs path: " <> tempAbsBasePath' | ||
H.note_ $ "Socketpath: " <> unFile socketPath | ||
H.note_ $ "Foldblocks config file: " <> unFile configurationFile | ||
|
||
gov <- H.createDirectoryIfMissing $ work </> "governance" | ||
|
||
baseDir <- H.createDirectoryIfMissing $ gov </> "output" | ||
|
||
-- Figure out expiration time for proposals | ||
|
||
govActionLifetime <- getGovActionLifetime epochStateView ceo | ||
H.note_ $ "govActionLifetime: " <> show govActionLifetime | ||
|
||
-- Create a proposal | ||
(governanceActionTxId, _governanceActionIndex) <- | ||
makeActivityChangeProposal execConfig epochStateView ceo baseDir "proposal" | ||
Nothing (EpochInterval 3) wallet0 (EpochInterval 2) | ||
|
||
-- Wait for proposal to expire | ||
void $ waitForEpochs epochStateView (EpochInterval $ unEpochInterval govActionLifetime + 1) | ||
|
||
-- Check proposal expired | ||
mGovernanceActionTxIx <- watchEpochStateUpdate epochStateView (EpochInterval 2) $ \(anyNewEpochState, _, _) -> | ||
return $ maybeExtractGovernanceActionIndex (fromString governanceActionTxId) anyNewEpochState | ||
|
||
mGovernanceActionTxIx H.=== Nothing | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.