diff --git a/cardano-node-chairman/test/Spec/Chairman/Byron.hs b/cardano-node-chairman/test/Spec/Chairman/Byron.hs index d3f53eb51b4..8674f05dc2b 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Byron.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Byron.hs @@ -14,9 +14,9 @@ import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.Process as H import qualified System.Directory as IO -import qualified Testnet.Byron as H -import qualified Testnet.Conf as H -import qualified Util.Base as H + +import qualified Testnet.Byron as B +import qualified Cardano.Testnet as H {- HLINT ignore "Reduce duplication" -} {- HLINT ignore "Redundant <&>" -} @@ -27,6 +27,6 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing - allNodes <- H.testnet H.defaultTestnetOptions conf + allNodes <- B.testnet B.defaultTestnetOptions conf chairmanOver 120 52 conf allNodes diff --git a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs index f7f743b162c..6902c933d3d 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs @@ -11,16 +11,12 @@ import Data.Maybe import Spec.Chairman.Chairman (chairmanOver) import System.FilePath (()) -import Testnet ( TestnetOptions( CardanoOnlyTestnetOptions), testnet) - import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.Process as H import qualified System.Directory as IO -import qualified Testnet.Cardano as H -import qualified Testnet.Conf as H -import qualified Util.Base as H -import qualified Util.Runtime as H + +import qualified Cardano.Testnet as H {- HLINT ignore "Reduce duplication" -} {- HLINT ignore "Redundant <&>" -} @@ -32,6 +28,6 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing - allNodes <- fmap H.nodeName . H.allNodes <$> testnet (CardanoOnlyTestnetOptions H.defaultTestnetOptions) conf + allNodes <- fmap H.nodeName . H.allNodes <$> H.testnet (H.CardanoOnlyTestnetOptions H.cardanoDefaultTestnetOptions) conf chairmanOver 120 50 conf allNodes diff --git a/cardano-node-chairman/test/Spec/Chairman/Chairman.hs b/cardano-node-chairman/test/Spec/Chairman/Chairman.hs index 8a3942b5ac2..e2a84e9390a 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Chairman.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Chairman.hs @@ -31,8 +31,8 @@ import qualified Hedgehog.Extras.Test.Process as H import qualified System.Environment as IO import qualified System.IO as IO import qualified System.Process as IO -import qualified Testnet.Conf as H -import qualified Util.Process as H + +import qualified Cardano.Testnet as H {- HLINT ignore "Reduce duplication" -} {- HLINT ignore "Redundant <&>" -} diff --git a/cardano-node-chairman/test/Spec/Chairman/Shelley.hs b/cardano-node-chairman/test/Spec/Chairman/Shelley.hs index 7b7cc23ed2e..34fa5ae3f43 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Shelley.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Shelley.hs @@ -12,10 +12,8 @@ import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.Process as H import qualified System.Directory as IO -import qualified Testnet.Conf as H -import qualified Testnet.Shelley as H -import qualified Util.Base as H -import qualified Util.Runtime as H + +import qualified Cardano.Testnet as H hprop_chairman :: H.Property hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \tempAbsPath' -> do @@ -23,6 +21,6 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing - allNodes <- fmap H.nodeName . H.allNodes <$> H.shelleyTestnet H.defaultTestnetOptions conf + allNodes <- fmap H.nodeName . H.allNodes <$> H.testnet (H.ShelleyOnlyTestnetOptions H.shelleyDefaultTestnetOptions) conf chairmanOver 120 21 conf allNodes diff --git a/cardano-testnet/app/cardano-testnet.hs b/cardano-testnet/app/cardano-testnet.hs index 5ef8ebdae16..6391a41675e 100644 --- a/cardano-testnet/app/cardano-testnet.hs +++ b/cardano-testnet/app/cardano-testnet.hs @@ -5,7 +5,7 @@ import Data.Function import Data.Semigroup import Options.Applicative import System.IO (IO) -import Parsers +import Cardano.Testnet (commands) main :: IO () main = join $ customExecParser diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index cf4f6c5a2f6..26cd511f9f8 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -57,7 +57,10 @@ library , unordered-containers hs-source-dirs: src - exposed-modules: Parsers + exposed-modules: Cardano.Testnet + Testnet.Byron + + other-modules: Parsers Parsers.Babbage Parsers.Byron Parsers.Cardano @@ -70,14 +73,12 @@ library Util.Runtime Testnet Testnet.Babbage - Testnet.Byron Testnet.Cardano Testnet.Conf Testnet.Run Testnet.Shelley Testnet.Utils - - other-modules: Paths_cardano_testnet + Paths_cardano_testnet autogen-modules: Paths_cardano_testnet diff --git a/cardano-testnet/src/Cardano/Testnet.hs b/cardano-testnet/src/Cardano/Testnet.hs new file mode 100644 index 00000000000..699fd508b23 --- /dev/null +++ b/cardano-testnet/src/Cardano/Testnet.hs @@ -0,0 +1,65 @@ +module Cardano.Testnet + ( Babbage.BabbageTestnetOptions(..) + , Cardano.CardanoTestnetOptions(..) + , Shelley.ShelleyTestnetOptions(..) + , TestnetOptions(..) + , TestnetNodeOptions(..) + , babbageDefaultTestnetOptions + , cardanoDefaultTestnetOptions + , cardanoDefaultTestnetNodeOptions + , shelleyDefaultTestnetOptions + , testnet + + , Conf(..) + , ProjectBase(..) + , YamlFilePath(..) + , mkConf + + , execCli + , execCli' + , execCli_ + , procNode + , procChairman + + , getRelevantLeaderSlots + + , assertByDeadlineMCustom + , integration + , isLinux + , waitUntilEpoch + + , disabled + , ignoreOnWindows + , ignoreOnMacAndWindows + + , LeadershipSlot(..) + , NodeLoggingFormat(..) + , PaymentKeyPair(..) + , StakingKeyPair(..) + , TestnetRuntime(..) + , NodeRuntime(..) + , PoolNode(..) + , PoolNodeKeys(..) + , Delegator(..) + , allNodes + , bftSprockets + , poolSprockets + , poolNodeStdout + , readNodeLoggingFormat + , startNode + + , commands + ) where + +import Testnet +import Testnet.Babbage as Babbage +import Testnet.Cardano as Cardano +import Testnet.Shelley as Shelley +import Testnet.Utils (waitUntilEpoch) +import Testnet.Conf hiding (base) +import Parsers (commands) +import Util.Assert +import Util.Base (integration, isLinux) +import Util.Ignore (disabled, ignoreOnWindows, ignoreOnMacAndWindows) +import Util.Process (assertByDeadlineMCustom, execCli, execCli', execCli_, procChairman, procNode) +import Util.Runtime diff --git a/cardano-testnet/src/Parsers/Babbage.hs b/cardano-testnet/src/Parsers/Babbage.hs index f6c3a0c3ab7..f633eda8d76 100644 --- a/cardano-testnet/src/Parsers/Babbage.hs +++ b/cardano-testnet/src/Parsers/Babbage.hs @@ -25,35 +25,35 @@ optsTestnet = BabbageTestnetOptions <> OA.help "Number of SPO nodes" <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (numSpoNodes defaultTestnetOptions) + <> OA.value (babbageNumSpoNodes defaultTestnetOptions) ) <*> OA.option auto ( OA.long "slot-duration" <> OA.help "Slot duration" <> OA.metavar "MILLISECONDS" <> OA.showDefault - <> OA.value (slotDuration defaultTestnetOptions) + <> OA.value (babbageSlotDuration defaultTestnetOptions) ) <*> OA.option auto ( OA.long "security-param" <> OA.help "Security parameter" <> OA.metavar "INT" <> OA.showDefault - <> OA.value (securityParam defaultTestnetOptions) + <> OA.value (babbageSecurityParam defaultTestnetOptions) ) <*> OA.option auto ( OA.long "total-balance" <> OA.help "Total balance" <> OA.metavar "INT" <> OA.showDefault - <> OA.value (totalBalance defaultTestnetOptions) + <> OA.value (babbageTotalBalance defaultTestnetOptions) ) <*> OA.option (OA.eitherReader readNodeLoggingFormat) ( OA.long "nodeLoggingFormat" <> OA.help "Node logging format (json|text)" <> OA.metavar "LOGGING_FORMAT" <> OA.showDefault - <> OA.value (nodeLoggingFormat defaultTestnetOptions) + <> OA.value (babbageNodeLoggingFormat defaultTestnetOptions) ) optsBabbage :: Parser BabbageOptions diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index 104834028db..f4cc9a570c8 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -26,61 +26,61 @@ data CardanoOptions = CardanoOptions optsTestnet :: Parser CardanoTestnetOptions optsTestnet = CardanoTestnetOptions <$> OA.option - ((`L.replicate` defaultTestnetNodeOptions) <$> auto) + ((`L.replicate` cardanoDefaultTestnetNodeOptions) <$> auto) ( OA.long "num-bft-nodes" <> OA.help "Number of BFT nodes" <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (bftNodeOptions defaultTestnetOptions) + <> OA.value (cardanoBftNodeOptions defaultTestnetOptions) ) <*> OA.option auto ( OA.long "num-pool-nodes" <> OA.help "Number of pool nodes" <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (numPoolNodes defaultTestnetOptions) + <> OA.value (cardanoNumPoolNodes defaultTestnetOptions) ) <*> OA.option (OA.eitherReader readEither) ( OA.long "era" <> OA.help ("Era to upgrade to. " <> show @[Era] [minBound .. maxBound]) <> OA.metavar "ERA" <> OA.showDefault - <> OA.value (era defaultTestnetOptions) + <> OA.value (cardanoEra defaultTestnetOptions) ) <*> OA.option auto ( OA.long "epoch-length" <> OA.help "Epoch length" <> OA.metavar "MILLISECONDS" <> OA.showDefault - <> OA.value (epochLength defaultTestnetOptions) + <> OA.value (cardanoEpochLength defaultTestnetOptions) ) <*> OA.option auto ( OA.long "slot-length" <> OA.help "Slot length" <> OA.metavar "SECONDS" <> OA.showDefault - <> OA.value (slotLength defaultTestnetOptions) + <> OA.value (cardanoSlotLength defaultTestnetOptions) ) <*> OA.option auto ( OA.long "active-slots-coeff" <> OA.help "Active slots co-efficient" <> OA.metavar "DOUBLE" <> OA.showDefault - <> OA.value (activeSlotsCoeff defaultTestnetOptions) + <> OA.value (cardanoActiveSlotsCoeff defaultTestnetOptions) ) <*> OA.option auto ( OA.long "enable-p2p" <> OA.help "Enable P2P" <> OA.metavar "BOOL" <> OA.showDefault - <> OA.value (enableP2P defaultTestnetOptions) + <> OA.value (cardanoEnableP2P defaultTestnetOptions) ) <*> OA.option (OA.eitherReader readNodeLoggingFormat) ( OA.long "nodeLoggingFormat" <> OA.help "Node logging format (json|text)" <> OA.metavar "LOGGING_FORMAT" <> OA.showDefault - <> OA.value (nodeLoggingFormat defaultTestnetOptions) + <> OA.value (cardanoNodeLoggingFormat defaultTestnetOptions) ) optsCardano :: Parser CardanoOptions diff --git a/cardano-testnet/src/Parsers/Shelley.hs b/cardano-testnet/src/Parsers/Shelley.hs index 4c7461d76c8..5963f9dcd3d 100644 --- a/cardano-testnet/src/Parsers/Shelley.hs +++ b/cardano-testnet/src/Parsers/Shelley.hs @@ -31,56 +31,56 @@ optsTestnet = ShelleyTestnetOptions <> OA.help "Number of PRAOS nodes" <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (numPraosNodes defaultTestnetOptions) + <> OA.value (shelleyNumPraosNodes defaultTestnetOptions) ) <*> OA.option auto ( OA.long "num-pool-nodes" <> OA.help "Number of pool nodes" <> OA.metavar "COUNT" <> OA.showDefault - <> OA.value (numPoolNodes defaultTestnetOptions) + <> OA.value (shelleyNumPoolNodes defaultTestnetOptions) ) <*> OA.option auto ( OA.long "active-slots-coeff" <> OA.help "Active slots co-efficient" <> OA.metavar "DOUBLE" <> OA.showDefault - <> OA.value (activeSlotsCoeff defaultTestnetOptions) + <> OA.value (shelleyActiveSlotsCoeff defaultTestnetOptions) ) <*> OA.option auto ( OA.long "security-param" <> OA.help "Security param" <> OA.metavar "INT" <> OA.showDefault - <> OA.value (securityParam defaultTestnetOptions) + <> OA.value (shelleySecurityParam defaultTestnetOptions) ) <*> OA.option auto ( OA.long "epoch-length" <> OA.help "Epoch length" <> OA.metavar "MILLISECONDS" <> OA.showDefault - <> OA.value (epochLength defaultTestnetOptions) + <> OA.value (shelleyEpochLength defaultTestnetOptions) ) <*> OA.option auto ( OA.long "slot-length" <> OA.help "Slot length" <> OA.metavar "MILLISECONDS" <> OA.showDefault - <> OA.value (slotLength defaultTestnetOptions) + <> OA.value (shelleySlotLength defaultTestnetOptions) ) <*> OA.option auto ( OA.long "max-lovelace-supply" <> OA.help "Max lovelace supply" <> OA.metavar "INTEGER" <> OA.showDefault - <> OA.value (maxLovelaceSupply defaultTestnetOptions) + <> OA.value (shelleyMaxLovelaceSupply defaultTestnetOptions) ) <*> OA.option auto ( OA.long "enable-p2p" <> OA.help "Enable P2P" <> OA.metavar "BOOL" <> OA.showDefault - <> OA.value (enableP2P defaultTestnetOptions) + <> OA.value (shelleyEnableP2P defaultTestnetOptions) ) optsShelley :: Parser ShelleyOptions diff --git a/cardano-testnet/src/Testnet.hs b/cardano-testnet/src/Testnet.hs index 8b8394aed0c..9273958502d 100644 --- a/cardano-testnet/src/Testnet.hs +++ b/cardano-testnet/src/Testnet.hs @@ -1,5 +1,8 @@ module Testnet ( TestnetOptions(..) + , babbageDefaultTestnetOptions + , cardanoDefaultTestnetOptions + , shelleyDefaultTestnetOptions , Testnet.testnet ) where @@ -8,10 +11,10 @@ import Text.Show (Show) import qualified Hedgehog.Extras.Test.Base as H -import Testnet.Babbage -import Testnet.Cardano +import Testnet.Babbage as Babbage +import Testnet.Cardano as Cardano import Testnet.Conf -import Testnet.Shelley +import Testnet.Shelley as Shelley data TestnetOptions = ShelleyOnlyTestnetOptions ShelleyTestnetOptions @@ -25,3 +28,11 @@ testnet options = case options of BabbageOnlyTestnetOptions o -> babbageTestnet o CardanoOnlyTestnetOptions o -> cardanoTestnet o +babbageDefaultTestnetOptions :: BabbageTestnetOptions +babbageDefaultTestnetOptions = Babbage.defaultTestnetOptions + +cardanoDefaultTestnetOptions :: CardanoTestnetOptions +cardanoDefaultTestnetOptions = Cardano.defaultTestnetOptions + +shelleyDefaultTestnetOptions :: ShelleyTestnetOptions +shelleyDefaultTestnetOptions = Shelley.defaultTestnetOptions diff --git a/cardano-testnet/src/Testnet/Babbage.hs b/cardano-testnet/src/Testnet/Babbage.hs index 50cc4160f60..979512498d2 100644 --- a/cardano-testnet/src/Testnet/Babbage.hs +++ b/cardano-testnet/src/Testnet/Babbage.hs @@ -10,9 +10,6 @@ module Testnet.Babbage ( BabbageTestnetOptions(..) , defaultTestnetOptions - , TestnetNodeOptions(..) - , defaultTestnetNodeOptions - , TestnetRuntime (..) , PaymentKeyPair(..) @@ -46,27 +43,22 @@ import qualified Testnet.Conf as H {- HLINT ignore "Redundant flip" -} data BabbageTestnetOptions = BabbageTestnetOptions - { numSpoNodes :: Int - , slotDuration :: Int - , securityParam :: Int - , totalBalance :: Int - , nodeLoggingFormat :: NodeLoggingFormat + { babbageNumSpoNodes :: Int + , babbageSlotDuration :: Int + , babbageSecurityParam :: Int + , babbageTotalBalance :: Int + , babbageNodeLoggingFormat :: NodeLoggingFormat } deriving (Eq, Show) defaultTestnetOptions :: BabbageTestnetOptions defaultTestnetOptions = BabbageTestnetOptions - { numSpoNodes = 3 - , slotDuration = 1000 - , securityParam = 10 - , totalBalance = 10020000000 - , nodeLoggingFormat = NodeLoggingFormatAsJson + { babbageNumSpoNodes = 3 + , babbageSlotDuration = 1000 + , babbageSecurityParam = 10 + , babbageTotalBalance = 10020000000 + , babbageNodeLoggingFormat = NodeLoggingFormatAsJson } -data TestnetNodeOptions = TestnetNodeOptions deriving (Eq, Show) - -defaultTestnetNodeOptions :: TestnetNodeOptions -defaultTestnetNodeOptions = TestnetNodeOptions - -- | For an unknown reason, CLI commands are a lot slower on Windows than on Linux and -- MacOS. We need to allow a lot more time to set up a testnet. startTimeOffsetSeconds :: DTC.NominalDiffTime @@ -84,7 +76,7 @@ babbageTestnet testnetOptions H.Conf {..} = do , "maxProposalSize" .= ("700" :: String) , "mpcThd" .= ("20000000000000" :: String) , "scriptVersion" .= (0 :: Int) - , "slotDuration" .= show @Int (slotDuration testnetOptions) + , "slotDuration" .= show @Int (babbageSlotDuration testnetOptions) , "unlockStakeEpoch" .= ("18446744073709551615" :: String) , "updateImplicit" .= ("10000" :: String) , "updateProposalThd" .= ("100000000000000" :: String) @@ -108,10 +100,10 @@ babbageTestnet testnetOptions H.Conf {..} = do [ "byron", "genesis", "genesis" , "--protocol-magic", show @Int testnetMagic , "--start-time", showUTCTimeSeconds startTime - , "--k", show @Int (securityParam testnetOptions) + , "--k", show @Int (babbageSecurityParam testnetOptions) , "--n-poor-addresses", "0" - , "--n-delegate-addresses", show @Int (numSpoNodes testnetOptions) - , "--total-balance", show @Int (totalBalance testnetOptions) + , "--n-delegate-addresses", show @Int (babbageNumSpoNodes testnetOptions) + , "--total-balance", show @Int (babbageTotalBalance testnetOptions) , "--delegate-share", "1" , "--avvm-entry-count", "0" , "--avvm-entry-balance", "0" @@ -154,7 +146,7 @@ babbageTestnet testnetOptions H.Conf {..} = do . J.rewriteArrayElements . J.rewriteObject . HM.insert "scFormat" - $ case nodeLoggingFormat testnetOptions of + $ case babbageNodeLoggingFormat testnetOptions of NodeLoggingFormatAsJson -> "ScJson" NodeLoggingFormatAsText -> "ScText") @@ -199,7 +191,7 @@ babbageTestnet testnetOptions H.Conf {..} = do } } - let spoNodes :: [String] = ("node-spo" <>) . show <$> [1 .. numSpoNodes testnetOptions] + let spoNodes :: [String] = ("node-spo" <>) . show <$> [1 .. babbageNumSpoNodes testnetOptions] -- Create the node directories @@ -229,7 +221,7 @@ babbageTestnet testnetOptions H.Conf {..} = do H.rewriteJsonFile (tempAbsPath "genesis/shelley/genesis.json") $ J.rewriteObject ( HM.insert "slotLength" (toJSON @Double 0.1) . HM.insert "activeSlotsCoeff" (toJSON @Double 0.1) - . HM.insert "securityParam" (toJSON @Int 10) + . HM.insert "securityParam" (toJSON @Int 10) -- TODO: USE config parameter . HM.insert "epochLength" (toJSON @Int 500) . HM.insert "maxLovelaceSupply" (toJSON @Int 1000000000000) . HM.insert "minFeeA" (toJSON @Int 44) @@ -339,7 +331,7 @@ babbageTestnet testnetOptions H.Conf {..} = do forM_ spoNodes $ \node -> do nodeStdoutFile <- H.noteTempFile logDir $ node <> ".stdout.log" - H.assertChainExtended deadline (nodeLoggingFormat testnetOptions) nodeStdoutFile + H.assertChainExtended deadline (babbageNodeLoggingFormat testnetOptions) nodeStdoutFile H.noteShowIO_ DTC.getCurrentTime diff --git a/cardano-testnet/src/Testnet/Cardano.hs b/cardano-testnet/src/Testnet/Cardano.hs index f6d8f1d34b0..198ae0f5d35 100644 --- a/cardano-testnet/src/Testnet/Cardano.hs +++ b/cardano-testnet/src/Testnet/Cardano.hs @@ -8,7 +8,7 @@ module Testnet.Cardano , CardanoTestnetOptions(..) , defaultTestnetOptions , TestnetNodeOptions(..) - , defaultTestnetNodeOptions + , cardanoDefaultTestnetNodeOptions , Era(..) , TestnetRuntime (..) @@ -71,26 +71,26 @@ data Era = Byron | Shelley | Allegra | Mary | Alonzo deriving (Eq, Enum, Bounded data CardanoTestnetOptions = CardanoTestnetOptions { -- | List of node options. Each option will result in a single node being -- created. - bftNodeOptions :: [TestnetNodeOptions] - , numPoolNodes :: Int - , era :: Era - , epochLength :: Int - , slotLength :: Double - , activeSlotsCoeff :: Double - , enableP2P :: Bool - , nodeLoggingFormat :: NodeLoggingFormat + cardanoBftNodeOptions :: [TestnetNodeOptions] + , cardanoNumPoolNodes :: Int + , cardanoEra :: Era + , cardanoEpochLength :: Int + , cardanoSlotLength :: Double + , cardanoActiveSlotsCoeff :: Double + , cardanoEnableP2P :: Bool + , cardanoNodeLoggingFormat :: NodeLoggingFormat } deriving (Eq, Show) defaultTestnetOptions :: CardanoTestnetOptions defaultTestnetOptions = CardanoTestnetOptions - { bftNodeOptions = L.replicate 2 defaultTestnetNodeOptions - , numPoolNodes = 1 - , era = Alonzo - , epochLength = 1500 - , slotLength = 0.2 - , activeSlotsCoeff = 0.2 - , enableP2P = False - , nodeLoggingFormat = NodeLoggingFormatAsText + { cardanoBftNodeOptions = L.replicate 2 cardanoDefaultTestnetNodeOptions + , cardanoNumPoolNodes = 1 + , cardanoEra = Alonzo + , cardanoEpochLength = 1500 + , cardanoSlotLength = 0.2 + , cardanoActiveSlotsCoeff = 0.2 + , cardanoEnableP2P = False + , cardanoNodeLoggingFormat = NodeLoggingFormatAsText } newtype TestnetNodeOptions = TestnetNodeOptions @@ -99,8 +99,8 @@ newtype TestnetNodeOptions = TestnetNodeOptions extraNodeCliArgs :: [String] } deriving (Eq, Show) -defaultTestnetNodeOptions :: TestnetNodeOptions -defaultTestnetNodeOptions = TestnetNodeOptions +cardanoDefaultTestnetNodeOptions :: TestnetNodeOptions +cardanoDefaultTestnetNodeOptions = TestnetNodeOptions { extraNodeCliArgs = [] } @@ -155,9 +155,9 @@ cardanoTestnet testnetOptions H.Conf {..} = do currentTime <- H.noteShowIO DTC.getCurrentTime startTime <- H.noteShow $ DTC.addUTCTime startTimeOffsetSeconds currentTime configurationFile <- H.noteShow $ tempAbsPath "configuration.yaml" - let numBftNodes = L.length (bftNodeOptions testnetOptions) + let numBftNodes = L.length (cardanoBftNodeOptions testnetOptions) bftNodesN = [1 .. numBftNodes] - poolNodesN = [1 .. numPoolNodes testnetOptions] + poolNodesN = [1 .. cardanoNumPoolNodes testnetOptions] bftNodeNames = ("node-bft" <>) . show @Int <$> bftNodesN poolNodeNames = ("node-pool" <>) . show @Int <$> poolNodesN allNodeNames = bftNodeNames <> poolNodeNames @@ -179,7 +179,7 @@ cardanoTestnet testnetOptions H.Conf {..} = do forkOptions <- pure $ id . HM.insert "EnableLogMetrics" (J.toJSON False) . HM.insert "EnableLogging" (J.toJSON True) - . case era testnetOptions of + . case cardanoEra testnetOptions of Byron -> id . HM.insert "LastKnownBlockVersion-Major" (J.toJSON @Int 1) @@ -221,13 +221,13 @@ cardanoTestnet testnetOptions H.Conf {..} = do . HM.insert "TraceBlockchainTime" (J.toJSON True) . HM.delete "GenesisFile" . HM.insert "TestEnableDevelopmentHardForkEras" (J.toJSON @Bool True) - . HM.insert "EnableP2P" (J.toJSON @Bool (enableP2P testnetOptions)) + . HM.insert "EnableP2P" (J.toJSON @Bool (cardanoEnableP2P testnetOptions)) . flip HM.alter "setupScribes" ( fmap . J.rewriteArrayElements . J.rewriteObject . HM.insert "scFormat" - $ case nodeLoggingFormat testnetOptions of + $ case cardanoNodeLoggingFormat testnetOptions of NodeLoggingFormatAsJson -> "ScJson" NodeLoggingFormatAsText -> "ScText") . forkOptions @@ -241,7 +241,8 @@ cardanoTestnet testnetOptions H.Conf {..} = do forM_ allNodeNames $ \node -> do let port = fromJust $ M.lookup node nodeToPort H.lbsWriteFile (tempAbsPath node "topology.json") $ - mkTopologyConfig (numBftNodes + numPoolNodes testnetOptions) allPorts port (enableP2P testnetOptions) + mkTopologyConfig (numBftNodes + cardanoNumPoolNodes testnetOptions) + allPorts port (cardanoEnableP2P testnetOptions) H.writeFile (tempAbsPath node "port") (show port) @@ -406,10 +407,10 @@ cardanoTestnet testnetOptions H.Conf {..} = do -- and K=10, but we'll keep long KES periods so we don't have to bother -- cycling KES keys H.rewriteJsonFile (tempAbsPath "shelley/genesis.spec.json") . J.rewriteObject - $ HM.insert "activeSlotsCoeff" (J.toJSON @Double (activeSlotsCoeff testnetOptions)) + $ HM.insert "activeSlotsCoeff" (J.toJSON @Double (cardanoActiveSlotsCoeff testnetOptions)) . HM.insert "securityParam" (J.toJSON @Int 10) - . HM.insert "epochLength" (J.toJSON @Int (epochLength testnetOptions)) - . HM.insert "slotLength" (J.toJSON @Double (slotLength testnetOptions)) + . HM.insert "epochLength" (J.toJSON @Int (cardanoEpochLength testnetOptions)) + . HM.insert "slotLength" (J.toJSON @Double (cardanoSlotLength testnetOptions)) . HM.insert "maxLovelaceSupply" (J.toJSON @Int maxShelleySupply) . flip HM.adjust "protocolParams" ( J.rewriteObject ( HM.insert "decentralisationParam" (J.toJSON @Double 0.7) @@ -425,7 +426,7 @@ cardanoTestnet testnetOptions H.Conf {..} = do , "--genesis-dir", tempAbsPath "shelley" , "--gen-genesis-keys", show @Int numBftNodes , "--start-time", formatIso8601 startTime - , "--gen-utxo-keys", show @Int (numPoolNodes testnetOptions) + , "--gen-utxo-keys", show @Int (cardanoNumPoolNodes testnetOptions) ] -- Generated genesis keys and genesis files @@ -709,7 +710,7 @@ cardanoTestnet testnetOptions H.Conf {..} = do -------------------------------- -- Launch cluster of three nodes - let bftNodeNameAndOpts = L.zip bftNodeNames (bftNodeOptions testnetOptions) + let bftNodeNameAndOpts = L.zip bftNodeNames (cardanoBftNodeOptions testnetOptions) bftNodes <- forM bftNodeNameAndOpts $ \(node, nodeOpts) -> do startNode tempBaseAbsPath tempAbsPath logDir socketDir node ([ "run" @@ -748,7 +749,7 @@ cardanoTestnet testnetOptions H.Conf {..} = do forM_ allNodeNames $ \node -> do nodeStdoutFile <- H.noteTempFile logDir $ node <> ".stdout.log" - H.assertChainExtended deadline (nodeLoggingFormat testnetOptions) nodeStdoutFile + H.assertChainExtended deadline (cardanoNodeLoggingFormat testnetOptions) nodeStdoutFile H.noteShowIO_ DTC.getCurrentTime diff --git a/cardano-testnet/src/Testnet/Shelley.hs b/cardano-testnet/src/Testnet/Shelley.hs index a5a4a31ae90..cd43b35431e 100644 --- a/cardano-testnet/src/Testnet/Shelley.hs +++ b/cardano-testnet/src/Testnet/Shelley.hs @@ -61,26 +61,26 @@ import Util.Runtime hiding (allNodes) {- HLINT ignore "Redundant flip" -} data ShelleyTestnetOptions = ShelleyTestnetOptions - { numPraosNodes :: Int - , numPoolNodes :: Int - , activeSlotsCoeff :: Double - , securityParam :: Int - , epochLength :: Int - , slotLength :: Double - , maxLovelaceSupply :: Integer - , enableP2P :: Bool + { shelleyNumPraosNodes :: Int + , shelleyNumPoolNodes :: Int + , shelleyActiveSlotsCoeff :: Double + , shelleySecurityParam :: Int + , shelleyEpochLength :: Int + , shelleySlotLength :: Double + , shelleyMaxLovelaceSupply :: Integer + , shelleyEnableP2P :: Bool } deriving (Eq, Show) defaultTestnetOptions :: ShelleyTestnetOptions defaultTestnetOptions = ShelleyTestnetOptions - { numPraosNodes = 2 - , numPoolNodes = 1 - , activeSlotsCoeff = 0.1 - , securityParam = 10 - , epochLength = 1000 - , slotLength = 0.2 - , maxLovelaceSupply = 1000000000 - , enableP2P = False + { shelleyNumPraosNodes = 2 + , shelleyNumPoolNodes = 1 + , shelleyActiveSlotsCoeff = 0.1 + , shelleySecurityParam = 10 + , shelleyEpochLength = 1000 + , shelleySlotLength = 0.2 + , shelleyMaxLovelaceSupply = 1000000000 + , shelleyEnableP2P = False } -- TODO: We need to refactor this to directly check the parsed configuration @@ -97,11 +97,11 @@ ifaceAddress = "127.0.0.1" rewriteGenesisSpec :: ShelleyTestnetOptions -> UTCTime -> Value -> Value rewriteGenesisSpec testnetOptions startTime = rewriteObject - $ HM.insert "activeSlotsCoeff" (J.toJSON @Double (activeSlotsCoeff testnetOptions)) - . HM.insert "securityParam" (J.toJSON @Int (securityParam testnetOptions)) - . HM.insert "epochLength" (J.toJSON @Int (epochLength testnetOptions)) - . HM.insert "slotLength" (J.toJSON @Double (slotLength testnetOptions)) - . HM.insert "maxLovelaceSupply" (J.toJSON @Integer (maxLovelaceSupply testnetOptions)) + $ HM.insert "activeSlotsCoeff" (J.toJSON @Double (shelleyActiveSlotsCoeff testnetOptions)) + . HM.insert "securityParam" (J.toJSON @Int (shelleySecurityParam testnetOptions)) + . HM.insert "epochLength" (J.toJSON @Int (shelleyEpochLength testnetOptions)) + . HM.insert "slotLength" (J.toJSON @Double (shelleySlotLength testnetOptions)) + . HM.insert "maxLovelaceSupply" (J.toJSON @Integer (shelleyMaxLovelaceSupply testnetOptions)) . HM.insert "systemStart" (J.toJSON @String (DTC.formatIso8601 startTime)) . flip HM.adjust "protocolParams" ( rewriteObject (HM.insert "decentralisationParam" (toJSON @Double 0.7)) @@ -155,9 +155,9 @@ shelleyTestnet :: ShelleyTestnetOptions -> H.Conf -> H.Integration TestnetRuntim shelleyTestnet testnetOptions H.Conf {..} = do void $ H.note OS.os - let praosNodesN = show @Int <$> [1 .. numPraosNodes testnetOptions] + let praosNodesN = show @Int <$> [1 .. shelleyNumPraosNodes testnetOptions] let praosNodes = ("node-praos" <>) <$> praosNodesN - let poolNodesN = show @Int <$> [1 .. numPoolNodes testnetOptions] + let poolNodesN = show @Int <$> [1 .. shelleyNumPoolNodes testnetOptions] let poolNodes = ("node-pool" <>) <$> poolNodesN let allNodes = praosNodes <> poolNodes :: [String] let numPraosNodes = L.length allNodes :: Int @@ -202,7 +202,7 @@ shelleyTestnet testnetOptions H.Conf {..} = do , "--testnet-magic", show @Int testnetMagic , "--genesis-dir", tempAbsPath , "--gen-genesis-keys", show numPraosNodes - , "--gen-utxo-keys", show @Int (numPoolNodes testnetOptions) + , "--gen-utxo-keys", show @Int (shelleyNumPoolNodes testnetOptions) , "--start-time", DTC.formatIso8601 startTime ] @@ -252,7 +252,7 @@ shelleyTestnet testnetOptions H.Conf {..} = do forM_ allNodes $ \node -> do let port = fromJust $ M.lookup node nodeToPort H.lbsWriteFile (tempAbsPath node "topology.json") $ - mkTopologyConfig numPraosNodes allPorts port (enableP2P testnetOptions) + mkTopologyConfig numPraosNodes allPorts port (shelleyEnableP2P testnetOptions) H.writeFile (tempAbsPath node "port") (show port) @@ -362,7 +362,7 @@ shelleyTestnet testnetOptions H.Conf {..} = do , "--invalid-hereafter", "1000" , "--fee", "0" , "--tx-in", genesisTxinResult - , "--tx-out", userNAddr <> "+" <> show @Integer (maxLovelaceSupply testnetOptions) + , "--tx-out", userNAddr <> "+" <> show @Integer (shelleyMaxLovelaceSupply testnetOptions) , "--certificate-file", tempAbsPath "addresses/pool-owner" <> n <> "-stake.reg.cert" , "--certificate-file", tempAbsPath "node-pool" <> n <> "/registration.cert" , "--certificate-file", tempAbsPath "addresses/user" <> n <> "-stake.reg.cert" @@ -396,7 +396,7 @@ shelleyTestnet testnetOptions H.Conf {..} = do H.createDirectoryIfMissing logDir H.readFile (base "configuration/chairman/shelley-only/configuration.yaml") - <&> L.unlines . fmap (rewriteConfiguration (enableP2P testnetOptions)) . L.lines + <&> L.unlines . fmap (rewriteConfiguration (shelleyEnableP2P testnetOptions)) . L.lines >>= H.writeFile (tempAbsPath "configuration.yaml") allNodeRuntimes <- forM allNodes diff --git a/cardano-testnet/test/Main.hs b/cardano-testnet/test/Main.hs index 40e2d94fe38..3925b14b6bd 100644 --- a/cardano-testnet/test/Main.hs +++ b/cardano-testnet/test/Main.hs @@ -16,7 +16,8 @@ import qualified Test.Cli.Babbage.LeadershipSchedule import qualified Test.Cli.KesPeriodInfo import qualified Test.Node.Shutdown import qualified Test.ShutdownOnSlotSynced -import qualified Util.Ignore as H + +import qualified Cardano.Testnet as H tests :: IO TestTree tests = pure $ T.testGroup "test/Spec.hs" diff --git a/cardano-testnet/test/Test/Cli/Alonzo/LeadershipSchedule.hs b/cardano-testnet/test/Test/Cli/Alonzo/LeadershipSchedule.hs index cc6a928aa8b..a7357ecdc64 100644 --- a/cardano-testnet/test/Test/Cli/Alonzo/LeadershipSchedule.hs +++ b/cardano-testnet/test/Test/Cli/Alonzo/LeadershipSchedule.hs @@ -14,11 +14,6 @@ module Test.Cli.Alonzo.LeadershipSchedule ( hprop_leadershipSchedule ) where -import Cardano.Api (AlonzoEra, SerialiseAddress (serialiseAddress), UTxO (UTxO)) -import qualified Cardano.Api as Api -import Cardano.Api.Shelley (PoolId) -import Cardano.CLI.Shelley.Output (QueryTipLocalStateOutput (mEpoch)) -import Cardano.CLI.Shelley.Run.Query (DelegationsAndRewards, mergeDelegsAndRewards) import Control.Monad (void) import qualified Data.Aeson.Types as J import Data.List ((\\)) @@ -30,6 +25,7 @@ import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Time.Clock as DTC import GHC.Stack (callStack) + import Hedgehog (Property, (===)) import qualified Hedgehog as H import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO @@ -41,32 +37,32 @@ import Prelude import qualified System.Directory as IO import System.Environment (getEnvironment) import System.FilePath (()) + +import Cardano.Api (AlonzoEra, SerialiseAddress (serialiseAddress), UTxO (UTxO)) +import qualified Cardano.Api as Api +import Cardano.Api.Shelley (PoolId) +import Cardano.CLI.Shelley.Output (QueryTipLocalStateOutput (mEpoch)) +import Cardano.CLI.Shelley.Run.Query (DelegationsAndRewards, mergeDelegsAndRewards) + +import Cardano.Testnet + import qualified System.Info as SYS -import Testnet ( TestnetOptions (CardanoOnlyTestnetOptions), testnet) -import Testnet.Cardano as TC (CardanoTestnetOptions (..), defaultTestnetOptions) -import qualified Testnet.Conf as H -import Testnet.Utils (waitUntilEpoch) -import qualified Util.Assert as H -import qualified Util.Base as H -import qualified Util.Process as H -import Util.Runtime (LeadershipSlot (..)) -import qualified Util.Runtime as TR hprop_leadershipSchedule :: Property -hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" $ \tempAbsBasePath' -> do +hprop_leadershipSchedule = integration . H.runFinallies . H.workspace "alonzo" $ \tempAbsBasePath' -> do H.note_ SYS.os base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" - conf@H.Conf { H.tempBaseAbsPath, H.tempAbsPath } <- H.noteShowM $ - H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsBasePath' Nothing + conf@Conf { tempBaseAbsPath, tempAbsPath } <- H.noteShowM $ + mkConf (ProjectBase base) (YamlFilePath configurationTemplate) tempAbsBasePath' Nothing let - fastTestnetOptions = CardanoOnlyTestnetOptions defaultTestnetOptions - { epochLength = 500 - , slotLength = 0.01 - , activeSlotsCoeff = 0.1 - , nodeLoggingFormat = TR.NodeLoggingFormatAsJson + fastTestnetOptions = CardanoOnlyTestnetOptions cardanoDefaultTestnetOptions + { cardanoEpochLength = 500 + , cardanoSlotLength = 0.01 + , cardanoActiveSlotsCoeff = 0.1 + , cardanoNodeLoggingFormat = NodeLoggingFormatAsJson } - tr@TR.TestnetRuntime + tr@TestnetRuntime { testnetMagic , poolNodes } <- testnet fastTestnetOptions conf @@ -77,7 +73,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" execConfig <- H.noteShow H.ExecConfig { H.execConfigEnv = Last $ Just $ - [ ("CARDANO_NODE_SOCKET_PATH", IO.sprocketArgumentName $ head $ TR.bftSprockets tr) + [ ("CARDANO_NODE_SOCKET_PATH", IO.sprocketArgumentName $ head $ bftSprockets tr) ] -- The environment must be passed onto child process on Windows in order to -- successfully start that process. @@ -95,13 +91,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" utxoVKeyFile2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2.vkey" utxoSKeyFile2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2.skey" - utxoAddr <- H.execCli + utxoAddr <- execCli [ "address", "build" , "--testnet-magic", show @Int testnetMagic , "--payment-verification-key-file", utxoVKeyFile ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -119,14 +115,14 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" utxoStakingVkey2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2-stake.vkey" utxoStakingSkey2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2-stake.skey" - utxoaddrwithstaking <- H.execCli + utxoaddrwithstaking <- execCli [ "address", "build" , "--payment-verification-key-file", utxoVKeyFile2 , "--stake-verification-key-file", utxoStakingVkey2 , "--testnet-magic", show @Int testnetMagic ] - utxostakingaddr <- filter (/= '\n') <$> H.execCli + utxostakingaddr <- filter (/= '\n') <$> execCli [ "stake-address", "build" , "--stake-verification-key-file", utxoStakingVkey2 , "--testnet-magic", show @Int testnetMagic @@ -136,13 +132,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.createDirectoryIfMissing $ tempAbsPath "addresses" poolownerstakekey <- H.note $ tempAbsPath "addresses/pool-owner1-stake.vkey" poolownerverkey <- H.note $ tempAbsPath "addresses/pool-owner1.vkey" - poolownerstakeaddr <- filter (/= '\n') <$> H.execCli + poolownerstakeaddr <- filter (/= '\n') <$> execCli [ "stake-address", "build" , "--stake-verification-key-file", poolownerstakekey , "--testnet-magic", show @Int testnetMagic ] - poolowneraddresswstakecred <- H.execCli + poolowneraddresswstakecred <- execCli [ "address", "build" , "--payment-verification-key-file", poolownerverkey , "--stake-verification-key-file", poolownerstakekey @@ -152,7 +148,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" poolcoldVkey <- H.note $ tempAbsPath "node-pool1/shelley/operator.vkey" poolcoldSkey <- H.note $ tempAbsPath "node-pool1/shelley/operator.skey" - stakePoolId <- filter ( /= '\n') <$> H.execCli + stakePoolId <- filter ( /= '\n') <$> execCli [ "stake-pool", "id" , "--cold-verification-key-file", poolcoldVkey ] @@ -160,13 +156,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" -- REGISTER PLEDGER POOL -- Create pledger registration certificate - void $ H.execCli + void $ execCli [ "stake-address", "registration-certificate" , "--stake-verification-key-file", poolownerstakekey , "--out-file", work "pledger.regcert" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -179,7 +175,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" , "--out-file", work "pledge-registration-cert.txbody" ] - void $ H.execCli + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "pledge-registration-cert.txbody" , "--testnet-magic", show @Int testnetMagic @@ -189,20 +185,20 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Submitting pool owner/pledge stake registration cert and funding stake pool owner address..." - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "pledge-registration-cert.tx" , "--testnet-magic", show @Int testnetMagic ] -- Things take long on non-linux machines - if H.isLinux - then H.threadDelay 5000000 - else H.threadDelay 10000000 + if isLinux + then H.threadDelay 5000000 + else H.threadDelay 10000000 -- Check to see if pledge's stake address was registered - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", poolownerstakeaddr , "--testnet-magic", show @Int testnetMagic @@ -222,7 +218,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ $ "Register staking key: " <> show utxoStakingVkey2 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoaddrwithstaking , "--cardano-mode" @@ -236,13 +232,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" UTxO utxoWithStaking1 <- H.noteShowM $ H.jsonErrorFail $ J.fromJSON @(UTxO AlonzoEra) utxoWithStaking1Json txinForStakeReg <- H.noteShow $ head $ Map.keys utxoWithStaking1 - void $ H.execCli + void $ execCli [ "stake-address", "registration-certificate" , "--stake-verification-key-file", utxoStakingVkey2 , "--out-file", work "stakekey.regcert" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -254,7 +250,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" , "--out-file", work "key-registration-cert.txbody" ] - void $ H.execCli + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "key-registration-cert.txbody" , "--testnet-magic", show @Int testnetMagic @@ -263,7 +259,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" , "--out-file", work "key-registration-cert.tx" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "key-registration-cert.tx" , "--testnet-magic", show @Int testnetMagic @@ -272,7 +268,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ $ "Check to see if " <> utxoStakingVkey2 <> " was registered..." H.threadDelay 10000000 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", utxostakingaddr , "--testnet-magic", show @Int testnetMagic @@ -291,7 +287,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -307,7 +303,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Create delegation certificate of pledger" - void $ H.execCli + void $ execCli [ "stake-address", "delegation-certificate" , "--stake-verification-key-file", poolownerstakekey , "--cold-verification-key-file", poolcoldVkey @@ -316,7 +312,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Register stake pool and delegate pledger to stake pool in a single tx" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -329,7 +325,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" , "--out-file", work "register-stake-pool.txbody" ] - void $ H.execCli + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "register-stake-pool.txbody" , "--testnet-magic", show @Int testnetMagic @@ -339,17 +335,17 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" , "--out-file", work "register-stake-pool.tx" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "register-stake-pool.tx" , "--testnet-magic", show @Int testnetMagic ] - if H.isLinux - then H.threadDelay 5000000 - else H.threadDelay 20000000 + if isLinux + then H.threadDelay 5000000 + else H.threadDelay 20000000 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-pools" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-registered.pools.json" @@ -363,7 +359,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" T.unpack (Api.serialiseToBech32 poolId) === stakePoolId H.note_ "Check pledge was successfully delegated" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", poolownerstakeaddr , "--testnet-magic", show @Int testnetMagic @@ -384,7 +380,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -396,7 +392,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -411,7 +407,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Wait for rewards to be paid out. This will be current epoch + 4" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip.json" @@ -436,7 +432,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Check we have reached 4 epochs ahead" waitedEpoch === rewardsEpoch - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip-2.json" @@ -454,9 +450,9 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" now <- H.noteShowIO DTC.getCurrentTime deadline <- H.noteShow $ DTC.addUTCTime 90 now - H.assertByDeadlineMCustom "stdout does not contain \"until genesis start time\"" deadline $ do + assertByDeadlineMCustom "stdout does not contain \"until genesis start time\"" deadline $ do H.threadDelay 1000000 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip-3.json" @@ -472,7 +468,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ $ "Current Epoch: " <> show currEpoch3 return (currEpoch3 > currEpoch2 + 1) - ledgerStateJson <- H.execCli' execConfig + ledgerStateJson <- execCli' execConfig [ "query", "ledger-state" , "--cardano-mode" , "--testnet-magic", show @Int testnetMagic @@ -482,13 +478,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ "Done" - let poolVrfSkey = TR.poolNodeKeysVrfSkey $ TR.poolKeys poolNode1 + let poolVrfSkey = poolNodeKeysVrfSkey $ poolKeys poolNode1 scheduleFile <- H.noteTempFile tempAbsPath "schedule.log" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "leadership-schedule" , "--testnet-magic", show @Int testnetMagic - , "--genesis", TR.shelleyGenesisFile tr + , "--genesis", shelleyGenesisFile tr , "--stake-pool-id", stakePoolId , "--vrf-signing-key-file", poolVrfSkey , "--out-file", scheduleFile @@ -503,13 +499,13 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime - H.assertByDeadlineMCustom "Leader schedule is correct" leadershipDeadline $ do - leaderSlots <- H.getRelevantLeaderSlots (TR.nodeStdout $ TR.poolRuntime poolNode1) (minimum expectedLeadershipSlotNumbers) + assertByDeadlineMCustom "Leader schedule is correct" leadershipDeadline $ do + leaderSlots <- getRelevantLeaderSlots (nodeStdout $ poolRuntime poolNode1) (minimum expectedLeadershipSlotNumbers) maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers maxActualSlot <- H.noteShow $ maximum leaderSlots return $ maxActualSlot >= maxSlotExpected - leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) + leaderSlots <- getRelevantLeaderSlots (poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) -- It's possible for some slots to not be assigned in TPraos when BFT nodes are running. -- TODO Remove BFT nodes from testnet and assert the schedule is equal to actual slots diff --git a/cardano-testnet/test/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/Test/Cli/Babbage/LeadershipSchedule.hs index 53789c66326..69068522b40 100644 --- a/cardano-testnet/test/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/Test/Cli/Babbage/LeadershipSchedule.hs @@ -38,32 +38,25 @@ import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.Process as H import qualified System.Directory as IO import qualified System.Info as SYS -import Testnet ( TestnetOptions (BabbageOnlyTestnetOptions), testnet) -import Testnet.Babbage (BabbageTestnetOptions (..)) -import qualified Testnet.Babbage as TC -import qualified Testnet.Conf as H -import qualified Util.Assert as H -import qualified Util.Base as H -import qualified Util.Process as H -import qualified Util.Runtime as TR -import Util.Runtime (LeadershipSlot (..)) + +import Cardano.Testnet hprop_leadershipSchedule :: Property -hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" $ \tempAbsBasePath' -> do +hprop_leadershipSchedule = integration . H.runFinallies . H.workspace "alonzo" $ \tempAbsBasePath' -> do H.note_ SYS.os base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" - conf@H.Conf { H.tempBaseAbsPath, H.tempAbsPath } <- H.noteShowM $ - H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsBasePath' Nothing + conf@Conf { tempBaseAbsPath, tempAbsPath } <- H.noteShowM $ + mkConf (ProjectBase base) (YamlFilePath configurationTemplate) tempAbsBasePath' Nothing work <- H.note $ tempAbsPath "work" H.createDirectoryIfMissing work let - testnetOptions = BabbageOnlyTestnetOptions $ TC.defaultTestnetOptions - { nodeLoggingFormat = TR.NodeLoggingFormatAsJson + testnetOptions = BabbageOnlyTestnetOptions $ babbageDefaultTestnetOptions + { babbageNodeLoggingFormat = NodeLoggingFormatAsJson } - tr@TR.TestnetRuntime + tr@TestnetRuntime { testnetMagic , poolNodes -- , wallets @@ -74,7 +67,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" env <- H.evalIO getEnvironment - poolSprocket1 <- H.noteShow $ TR.nodeSprocket $ TR.poolRuntime poolNode1 + poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 execConfig <- H.noteShow H.ExecConfig { H.execConfigEnv = Last $ Just $ @@ -88,9 +81,9 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" tipDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime - H.assertByDeadlineMCustom "stdout does not contain \"until genesis start time\"" tipDeadline $ do + assertByDeadlineMCustom "stdout does not contain \"until genesis start time\"" tipDeadline $ do H.threadDelay 5000000 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip.json" @@ -106,12 +99,12 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" H.note_ $ "Current Epoch: " <> show currEpoch return (currEpoch > 2) - stakePoolId <- filter ( /= '\n') <$> H.execCli + stakePoolId <- filter ( /= '\n') <$> execCli [ "stake-pool", "id" - , "--cold-verification-key-file", TR.poolNodeKeysColdVkey $ TR.poolKeys poolNode1 + , "--cold-verification-key-file", poolNodeKeysColdVkey $ poolKeys poolNode1 ] - let poolVrfSkey = TR.poolNodeKeysVrfSkey $ TR.poolKeys poolNode1 + let poolVrfSkey = poolNodeKeysVrfSkey $ poolKeys poolNode1 id do scheduleFile <- H.noteTempFile tempAbsPath "schedule.log" @@ -119,10 +112,10 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipScheduleDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime H.byDeadlineM 5 leadershipScheduleDeadline $ do - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "leadership-schedule" , "--testnet-magic", show @Int testnetMagic - , "--genesis", TC.shelleyGenesisFile tr + , "--genesis", shelleyGenesisFile tr , "--stake-pool-id", stakePoolId , "--vrf-signing-key-file", poolVrfSkey , "--out-file", scheduleFile @@ -137,8 +130,8 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime - H.assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do - leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) + assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do + leaderSlots <- getRelevantLeaderSlots (poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers if L.null leaderSlots then return False @@ -146,7 +139,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" maxActualSlot <- H.noteShow $ maximum leaderSlots return $ maxActualSlot >= maxSlotExpected - leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) + leaderSlots <- getRelevantLeaderSlots (poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) H.noteShow_ expectedLeadershipSlotNumbers H.noteShow_ leaderSlots @@ -160,10 +153,10 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipScheduleDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime H.byDeadlineM 5 leadershipScheduleDeadline $ do - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "leadership-schedule" , "--testnet-magic", show @Int testnetMagic - , "--genesis", TC.shelleyGenesisFile tr + , "--genesis", shelleyGenesisFile tr , "--stake-pool-id", stakePoolId , "--vrf-signing-key-file", poolVrfSkey , "--out-file", scheduleFile @@ -178,8 +171,8 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime - H.assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do - leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) + assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do + leaderSlots <- getRelevantLeaderSlots (poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers if L.null leaderSlots then return False @@ -187,7 +180,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" maxActualSlot <- H.noteShow $ maximum leaderSlots return $ maxActualSlot >= maxSlotExpected - leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) + leaderSlots <- getRelevantLeaderSlots (poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers) H.noteShow_ expectedLeadershipSlotNumbers H.noteShow_ leaderSlots diff --git a/cardano-testnet/test/Test/Cli/KesPeriodInfo.hs b/cardano-testnet/test/Test/Cli/KesPeriodInfo.hs index 572baf08d0b..6d49604187f 100644 --- a/cardano-testnet/test/Test/Cli/KesPeriodInfo.hs +++ b/cardano-testnet/test/Test/Cli/KesPeriodInfo.hs @@ -35,37 +35,27 @@ import qualified System.Directory as IO import qualified System.Info as SYS import Test.Misc -import Testnet.Cardano (CardanoTestnetOptions (..), TestnetRuntime (..), - defaultTestnetNodeOptions, defaultTestnetOptions) -import Testnet (TestnetOptions (CardanoOnlyTestnetOptions), testnet) -import qualified Testnet.Cardano as TC -import qualified Testnet.Conf as H -import Testnet.Conf (ProjectBase (..), YamlFilePath (..)) -import Testnet.Utils (waitUntilEpoch) -import qualified Util.Base as H -import qualified Util.Process as H -import qualified Util.Runtime as TR - +import Cardano.Testnet hprop_kes_period_info :: Property -hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do +hprop_kes_period_info = integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do H.note_ SYS.os base <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" - conf@H.Conf { H.tempBaseAbsPath, H.tempAbsPath } - <- H.noteShowM $ H.mkConf (ProjectBase base) (YamlFilePath configurationTemplate) + conf@Conf { tempBaseAbsPath, tempAbsPath } + <- H.noteShowM $ mkConf (ProjectBase base) (YamlFilePath configurationTemplate) tempAbsBasePath' Nothing - let fastTestnetOptions = CardanoOnlyTestnetOptions $ defaultTestnetOptions - { bftNodeOptions = replicate 1 defaultTestnetNodeOptions - , epochLength = 500 - , slotLength = 0.02 - , activeSlotsCoeff = 0.1 + let fastTestnetOptions = CardanoOnlyTestnetOptions $ cardanoDefaultTestnetOptions + { cardanoBftNodeOptions = replicate 1 cardanoDefaultTestnetNodeOptions + , cardanoEpochLength = 500 + , cardanoSlotLength = 0.02 + , cardanoActiveSlotsCoeff = 0.1 } - runTime@TC.TestnetRuntime { testnetMagic } <- testnet fastTestnetOptions conf - let sprockets = TR.bftSprockets runTime + runTime@TestnetRuntime { testnetMagic } <- testnet fastTestnetOptions conf + let sprockets = bftSprockets runTime env <- H.evalIO getEnvironment execConfig <- H.noteShow H.ExecConfig @@ -87,13 +77,13 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" utxoVKeyFile2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2.vkey" utxoSKeyFile2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2.skey" - utxoAddr <- H.execCli + utxoAddr <- execCli [ "address", "build" , "--testnet-magic", show @Int testnetMagic , "--payment-verification-key-file", utxoVKeyFile ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -111,14 +101,14 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" utxoStakingVkey2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2-stake.vkey" utxoStakingSkey2 <- H.note $ tempAbsPath "shelley/utxo-keys/utxo2-stake.skey" - utxoaddrwithstaking <- H.execCli [ "address", "build" + utxoaddrwithstaking <- execCli [ "address", "build" , "--payment-verification-key-file", utxoVKeyFile2 , "--stake-verification-key-file", utxoStakingVkey2 , "--testnet-magic", show @Int testnetMagic ] utxostakingaddr <- filter (/= '\n') - <$> H.execCli + <$> execCli [ "stake-address", "build" , "--stake-verification-key-file", utxoStakingVkey2 , "--testnet-magic", show @Int testnetMagic @@ -129,13 +119,13 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" poolownerstakekey <- H.note $ tempAbsPath "addresses/pool-owner1-stake.vkey" poolownerverkey <- H.note $ tempAbsPath "addresses/pool-owner1.vkey" poolownerstakeaddr <- filter (/= '\n') - <$> H.execCli + <$> execCli [ "stake-address", "build" , "--stake-verification-key-file", poolownerstakekey , "--testnet-magic", show @Int testnetMagic ] - poolowneraddresswstakecred <- H.execCli [ "address", "build" + poolowneraddresswstakecred <- execCli [ "address", "build" , "--payment-verification-key-file", poolownerverkey , "--stake-verification-key-file", poolownerstakekey , "--testnet-magic", show @Int testnetMagic @@ -144,20 +134,20 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" poolcoldSkey <- H.note $ tempAbsPath "node-pool1/shelley/operator.skey" stakePoolId <- filter ( /= '\n') <$> - H.execCli [ "stake-pool", "id" + execCli [ "stake-pool", "id" , "--cold-verification-key-file", poolcoldVkey ] -- REGISTER PLEDGER POOL -- Create pledger registration certificate - void $ H.execCli + void $ execCli [ "stake-address", "registration-certificate" , "--stake-verification-key-file", poolownerstakekey , "--out-file", work "pledger.regcert" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -170,7 +160,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" , "--out-file", work "pledge-registration-cert.txbody" ] - void $ H.execCli + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "pledge-registration-cert.txbody" , "--testnet-magic", show @Int testnetMagic @@ -180,7 +170,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Submitting pool owner/pledge stake registration cert and funding stake pool owner address..." - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "pledge-registration-cert.tx" , "--testnet-magic", show @Int testnetMagic @@ -189,7 +179,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" delegsAndRewards <- H.byDurationM 3 12 $ do -- Check to see if pledge's stake address was registered - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", poolownerstakeaddr , "--testnet-magic", show @Int testnetMagic @@ -210,7 +200,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ $ "Register staking key: " <> show utxoStakingVkey2 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoaddrwithstaking , "--cardano-mode" @@ -224,12 +214,12 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" UTxO utxoWithStaking1 <- H.noteShowM $ H.jsonErrorFail $ J.fromJSON @(UTxO AlonzoEra) utxoWithStaking1Json txinForStakeReg <- H.noteShow =<< H.headM (Map.keys utxoWithStaking1) - void $ H.execCli [ "stake-address", "registration-certificate" + void $ execCli [ "stake-address", "registration-certificate" , "--stake-verification-key-file", utxoStakingVkey2 , "--out-file", work "stakekey.regcert" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -241,7 +231,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" , "--out-file", work "key-registration-cert.txbody" ] - void $ H.execCli [ "transaction", "sign" + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "key-registration-cert.txbody" , "--testnet-magic", show @Int testnetMagic , "--signing-key-file", utxoStakingSkey2 @@ -250,7 +240,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "key-registration-cert.tx" , "--testnet-magic", show @Int testnetMagic @@ -259,7 +249,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ $ "Check to see if " <> utxoStakingVkey2 <> " was registered..." userSAddr <- H.byDurationM 3 12 $ do - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", utxostakingaddr , "--testnet-magic", show @Int testnetMagic @@ -278,7 +268,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -294,7 +284,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Create delegation certificate of pledger" - void $ H.execCli + void $ execCli [ "stake-address", "delegation-certificate" , "--stake-verification-key-file", poolownerstakekey , "--cold-verification-key-file", poolcoldVkey @@ -303,7 +293,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Register stake pool and delegate pledger to stake pool in a single tx" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "build" , "--alonzo-era" , "--testnet-magic", show @Int testnetMagic @@ -316,7 +306,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" , "--out-file", work "register-stake-pool.txbody" ] - void $ H.execCli + void $ execCli [ "transaction", "sign" , "--tx-body-file", work "register-stake-pool.txbody" , "--testnet-magic", show @Int testnetMagic @@ -326,14 +316,14 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" , "--out-file", work "register-stake-pool.tx" ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "transaction", "submit" , "--tx-file", work "register-stake-pool.tx" , "--testnet-magic", show @Int testnetMagic ] H.byDurationM 3 12 $ do - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-pools" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-registered.pools.json" @@ -347,7 +337,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" T.unpack (serialiseToBech32 poolId) === stakePoolId H.note_ "Check pledge was successfully delegated" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "stake-address-info" , "--address", poolownerstakeaddr , "--testnet-magic", show @Int testnetMagic @@ -372,7 +362,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" -- TODO: Linking directly to the node certificate is fragile nodeOperationalCertFp <- H.note $ tempAbsPath "node-pool1/shelley/node.cert" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "kes-period-info" , "--testnet-magic", show @Int testnetMagic , "--op-cert-file", nodeOperationalCertFp @@ -390,7 +380,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -408,7 +398,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" H.note_ "Wait for the node to mint blocks. This will be in the following epoch so lets wait\ \ until the END of the following epoch." - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip.json" @@ -437,7 +427,7 @@ hprop_kes_period_info = H.integration . H.runFinallies . H.workspace "chairman" " Current epoch: " <> show currentEpoch - void $ H.execCli' execConfig + void $ execCli' execConfig [ "query", "tip" , "--testnet-magic", show @Int testnetMagic , "--out-file", work "current-tip-2.json" diff --git a/cardano-testnet/test/Test/Node/Shutdown.hs b/cardano-testnet/test/Test/Node/Shutdown.hs index 225b8ef1404..3675564306b 100644 --- a/cardano-testnet/test/Test/Node/Shutdown.hs +++ b/cardano-testnet/test/Test/Node/Shutdown.hs @@ -27,18 +27,17 @@ import qualified System.Directory as IO import qualified System.Exit as IO import qualified System.IO as IO import qualified System.Process as IO -import qualified Testnet.Conf as H -import qualified Util.Base as H -import qualified Util.Process as H + +import Cardano.Testnet {- HLINT ignore "Redundant <&>" -} hprop_shutdown :: Property -hprop_shutdown = H.integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do +hprop_shutdown = integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" - H.Conf { H.tempBaseAbsPath, H.tempAbsPath, H.logDir, H.socketDir } <- H.noteShowM $ - H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsBasePath' Nothing + Conf { tempBaseAbsPath, tempAbsPath, logDir, socketDir } <- H.noteShowM $ + mkConf (ProjectBase base) (YamlFilePath configurationTemplate) tempAbsBasePath' Nothing [port] <- H.noteShowIO $ IO.allocateRandomPorts 1 @@ -58,7 +57,7 @@ hprop_shutdown = H.integration . H.runFinallies . H.workspace "chairman" $ \temp -- Run cardano-node with pipe as stdin. Use 0 file descriptor as shutdown-ipc (mStdin, _mStdout, _mStderr, pHandle, _releaseKey) <- H.createProcess =<< - ( H.procNode + ( procNode [ "run" , "--config", base "configuration/cardano/mainnet-config.json" , "--topology", base "configuration/cardano/mainnet-topology.json" diff --git a/cardano-testnet/test/Test/ShutdownOnSlotSynced.hs b/cardano-testnet/test/Test/ShutdownOnSlotSynced.hs index 4a9b92fe268..dccb97e52bf 100644 --- a/cardano-testnet/test/Test/ShutdownOnSlotSynced.hs +++ b/cardano-testnet/test/Test/ShutdownOnSlotSynced.hs @@ -22,36 +22,29 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.Process as H -import Testnet (TestnetOptions( CardanoOnlyTestnetOptions), testnet) -import Testnet.Cardano (TestnetNodeOptions (TestnetNodeOptions), - CardanoTestnetOptions (..), TestnetRuntime (..), defaultTestnetNodeOptions, - defaultTestnetOptions) -import qualified Testnet.Cardano as TC -import qualified Testnet.Conf as H -import qualified Util.Base as H -import Util.Runtime (NodeRuntime (..)) +import Cardano.Testnet hprop_shutdownOnSlotSynced :: Property -hprop_shutdownOnSlotSynced = H.integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do +hprop_shutdownOnSlotSynced = integration . H.runFinallies . H.workspace "chairman" $ \tempAbsBasePath' -> do -- Start a local test net - base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase - configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" + baseDir <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase + configTemplate <- H.noteShow $ baseDir "configuration/defaults/byron-mainnet/configuration.yaml" conf <- H.noteShowM $ - H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsBasePath' Nothing + mkConf (ProjectBase baseDir) (YamlFilePath configTemplate) tempAbsBasePath' Nothing let maxSlot = 1500 slotLen = 0.01 - let fastTestnetOptions = CardanoOnlyTestnetOptions $ defaultTestnetOptions - { epochLength = 300 - , slotLength = slotLen - , bftNodeOptions = + let fastTestnetOptions = CardanoOnlyTestnetOptions $ cardanoDefaultTestnetOptions + { cardanoEpochLength = 300 + , cardanoSlotLength = slotLen + , cardanoBftNodeOptions = [ TestnetNodeOptions - { TC.extraNodeCliArgs = ["--shutdown-on-slot-synced", show maxSlot] + { extraNodeCliArgs = ["--shutdown-on-slot-synced", show maxSlot] } - , defaultTestnetNodeOptions - , defaultTestnetNodeOptions + , cardanoDefaultTestnetNodeOptions + , cardanoDefaultTestnetNodeOptions ] } - TC.TestnetRuntime { bftNodes = node:_ } <- testnet fastTestnetOptions conf + TestnetRuntime { bftNodes = node:_ } <- testnet fastTestnetOptions conf -- Wait for the node to exit let timeout :: Int