-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
285268c
commit c7552e8
Showing
3 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
126 changes: 126 additions & 0 deletions
126
...est/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ConstitutionalCommittee.hs
This file contains 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,126 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE NumericUnderscores #-} | ||
Check warning on line 2 in cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ConstitutionalCommittee.hs
|
||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
Check warning on line 5 in cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/ConstitutionalCommittee.hs
|
||
|
||
module Cardano.Testnet.Test.LedgerEvents.Gov.ConstitutionalCommittee | ||
( hprop_constitutional_committee | ||
) where | ||
|
||
import Cardano.Api as Api | ||
import Cardano.Api.Error (displayError) | ||
|
||
import qualified Cardano.Crypto.Hash as L | ||
import qualified Cardano.Ledger.Conway.Governance as L | ||
import qualified Cardano.Ledger.Conway.Governance as Ledger | ||
import qualified Cardano.Ledger.Hashes as L | ||
import qualified Cardano.Ledger.Shelley.LedgerState as L | ||
import Cardano.Testnet | ||
|
||
import Prelude | ||
|
||
import Control.Monad | ||
import Control.Monad.State.Strict (StateT) | ||
import Data.Maybe | ||
import Data.Maybe.Strict | ||
import Data.String | ||
import qualified Data.Text as Text | ||
import GHC.Exts (IsList (..)) | ||
import GHC.Stack (callStack) | ||
import Lens.Micro | ||
import System.FilePath ((</>)) | ||
|
||
import Testnet.Components.Configuration | ||
import Testnet.Components.DReps (createVotingTxBody, generateVoteFiles, | ||
retrieveTransactionId, signTx, submitTx) | ||
import Testnet.Components.Query | ||
import Testnet.Components.TestWatchdog | ||
import Testnet.Defaults | ||
import qualified Testnet.Process.Cli as P | ||
import qualified Testnet.Process.Run as H | ||
import qualified Testnet.Property.Utils as H | ||
import Testnet.Runtime | ||
|
||
import Hedgehog | ||
import qualified Hedgehog.Extras as H | ||
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO | ||
|
||
hprop_constitutional_committee :: Property | ||
hprop_constitutional_committee = H.integrationWorkspace "constitutional-committee" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do | ||
-- Start a local test net | ||
conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' | ||
let tempAbsPath' = unTmpAbsPath tempAbsPath | ||
tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath | ||
|
||
work <- H.createDirectoryIfMissing $ tempAbsPath' </> "work" | ||
|
||
-- Generate model for votes | ||
let allVotes :: [(String, Int)] | ||
allVotes = zip (concatMap (uncurry replicate) [(4, "yes"), (3, "no"), (2, "abstain")]) [1..] | ||
annotateShow allVotes | ||
|
||
let numVotes :: Int | ||
numVotes = length allVotes | ||
annotateShow numVotes | ||
|
||
let ceo = ConwayEraOnwardsConway | ||
sbe = conwayEraOnwardsToShelleyBasedEra ceo | ||
era = toCardanoEra sbe | ||
cEra = AnyCardanoEra era | ||
fastTestnetOptions = cardanoDefaultTestnetOptions | ||
{ cardanoEpochLength = 100 | ||
, cardanoNodeEra = cEra | ||
, cardanoNumDReps = numVotes | ||
} | ||
|
||
TestnetRuntime | ||
{ testnetMagic | ||
, poolNodes | ||
, wallets=wallet0:wallet1:_ | ||
, configurationFile | ||
} | ||
<- cardanoTestnetDefault fastTestnetOptions conf | ||
|
||
poolNode1 <- H.headM poolNodes | ||
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 | ||
execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic | ||
|
||
let socketName' = IO.sprocketName poolSprocket1 | ||
socketBase = IO.sprocketBase poolSprocket1 -- /tmp | ||
socketPath = socketBase </> socketName' | ||
|
||
epochStateView <- getEpochStateView (File configurationFile) (File socketPath) | ||
|
||
H.note_ $ "Sprocket: " <> show poolSprocket1 | ||
H.note_ $ "Abs path: " <> tempAbsBasePath' | ||
H.note_ $ "Socketpath: " <> socketPath | ||
H.note_ $ "Foldblocks config file: " <> configurationFile | ||
|
||
-- Create Conway constitution | ||
gov <- H.createDirectoryIfMissing $ work </> "governance" | ||
proposalAnchorFile <- H.note $ gov </> "sample-proposal-anchor" | ||
consitutionFile <- H.note $ gov </> "sample-constitution" | ||
constitutionActionFp <- H.note $ gov </> "constitution.action" | ||
|
||
H.writeFile proposalAnchorFile "dummy anchor data" | ||
H.writeFile consitutionFile "dummy constitution data" | ||
constitutionHash <- H.execCli' execConfig | ||
[ "conway", "governance" | ||
, "hash", "anchor-data", "--file-text", consitutionFile | ||
] | ||
|
||
proposalAnchorDataHash <- H.execCli' execConfig | ||
[ "conway", "governance" | ||
, "hash", "anchor-data", "--file-text", proposalAnchorFile | ||
] | ||
|
||
let stakeVkeyFp = gov </> "stake.vkey" | ||
stakeSKeyFp = gov </> "stake.skey" | ||
|
||
_ <- P.cliStakeAddressKeyGen tempAbsPath' | ||
$ P.KeyNames { P.verificationKeyFile = stakeVkeyFp | ||
, P.signingKeyFile = stakeSKeyFp | ||
} | ||
|
||
failure |
This file contains 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