-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test succeeds but not sure if testnet actually starts
- Loading branch information
Showing
3 changed files
with
167 additions
and
0 deletions.
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
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
138 changes: 138 additions & 0 deletions
138
cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/UpdateCommittee.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,138 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE NumericUnderscores #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module Cardano.Testnet.Test.EpochState.Gov.UpdateCommittee | ||
( hprop_epoch_state_update_committee | ||
) where | ||
|
||
import Cardano.Api as Api | ||
import Cardano.Api.Error (displayError) | ||
import Cardano.Api.Shelley | ||
|
||
import qualified Cardano.Crypto.Hash as L | ||
import qualified Cardano.Ledger.Conway.Genesis as L | ||
import qualified Cardano.Ledger.Conway.Governance as L | ||
import qualified Cardano.Ledger.Conway.Governance as Ledger | ||
import qualified Cardano.Ledger.Credential as L | ||
import qualified Cardano.Ledger.Hashes as L | ||
import qualified Cardano.Ledger.Shelley.LedgerState as L | ||
import Cardano.Testnet | ||
|
||
import Prelude | ||
|
||
import Control.Monad | ||
import Data.Bifunctor | ||
import qualified Data.ByteString.Char8 as BSC | ||
import qualified Data.Map.Strict as Map | ||
import System.FilePath ((</>)) | ||
|
||
import Testnet.Components.Configuration | ||
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 as H | ||
import qualified Hedgehog.Extras as H | ||
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO | ||
|
||
-- | Execute me with: | ||
-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/UpdateCommittee/"'@ | ||
-- Generate a testnet with a committee defined in the Conway genesis. Add and remove members from the committee | ||
-- in a single governance proposal. | ||
hprop_epoch_state_update_committee :: Property | ||
hprop_epoch_state_update_committee = H.integrationWorkspace "update-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" | ||
|
||
|
||
let ceo = ConwayEraOnwardsConway | ||
sbe = conwayEraOnwardsToShelleyBasedEra ceo | ||
era = toCardanoEra sbe | ||
cEra = AnyCardanoEra era | ||
fastTestnetOptions = cardanoDefaultTestnetOptions | ||
{ cardanoEpochLength = 100 | ||
, cardanoNodeEra = cEra | ||
} | ||
execConfigOffline <- H.mkExecConfigOffline tempBaseAbsPath | ||
|
||
-- Step 1. Define generate and define a committee in the genesis file | ||
|
||
-- Create committee cold keys | ||
H.createDirectoryIfMissing_ $ tempAbsPath' </> work </> "committee-keys" | ||
H.forConcurrently_ [1..2] $ \n -> do | ||
H.execCli' execConfigOffline | ||
[ anyEraToString cEra, "governance", "committee" | ||
, "key-gen-cold" | ||
, "--cold-verification-key-file", work </> defaultCommitteeVkeyFp n | ||
, "--cold-signing-key-file", work </> defaultCommitteeSkeyFp n | ||
] | ||
|
||
committeeVkey1Fp <- H.noteShow $ work </> defaultCommitteeVkeyFp 1 | ||
_committeeSkey1Fp <- H.noteShow $ work </> defaultCommitteeSkeyFp 1 | ||
committeeVkey2Fp <- H.noteShow $ work </> defaultCommitteeVkeyFp 2 | ||
_committeeSkey2Fp <- H.noteShow $ work </> defaultCommitteeSkeyFp 2 | ||
|
||
-- Read committee cold keys from disk to put into conway genesis | ||
|
||
comKeyHash1Str <- filter (/= '\n') <$> H.execCli' execConfigOffline | ||
[ anyEraToString cEra, "governance", "committee" | ||
, "key-hash" | ||
, "--verification-key-file", committeeVkey1Fp | ||
] | ||
|
||
_comKeyHash2Str <- H.execCli' execConfigOffline | ||
[ anyEraToString cEra, "governance", "committee" | ||
, "key-hash" | ||
, "--verification-key-file", committeeVkey2Fp | ||
] | ||
|
||
CommitteeColdKeyHash comKeyHash1 <- | ||
H.evalEither | ||
$ deserialiseFromRawBytesHex (AsHash AsCommitteeColdKey) | ||
$ BSC.pack comKeyHash1Str | ||
|
||
let comKeyCred1 = L.KeyHashObj comKeyHash1 | ||
committeeThreshold = unsafeBoundedRational 0.5 | ||
committee = L.Committee (Map.fromList [(comKeyCred1, EpochNo 100)]) committeeThreshold | ||
|
||
alonzoGenesis <- evalEither $ first prettyError defaultAlonzoGenesis | ||
(startTime, shelleyGenesis') <- getDefaultShelleyGenesis fastTestnetOptions | ||
let conwayGenesisWithCommittee = | ||
defaultConwayGenesis { L.cgCommittee = committee } | ||
TestnetRuntime | ||
{ testnetMagic | ||
, poolNodes | ||
, wallets=_wallet0:_wallet1:_ | ||
, configurationFile | ||
} <- cardanoTestnet | ||
fastTestnetOptions | ||
conf startTime shelleyGenesis' | ||
alonzoGenesis conwayGenesisWithCommittee | ||
|
||
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 | ||
return () | ||
|