Skip to content

Commit

Permalink
cardano-testnet: rename ShelleyTestnetOptionsinto GenesisOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Sep 16, 2024
1 parent e6a9c24 commit 3b168a0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions cardano-testnet/src/Parsers/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Testnet.Types (readNodeLoggingFormat)
optsTestnet :: EnvCli -> Parser CardanoTestnetCliOptions
optsTestnet envCli = CardanoTestnetCliOptions
<$> pCardanoTestnetCliOptions envCli
<*> pShelleyTestnetOptions
<*> pGenesisOptions

pCardanoTestnetCliOptions :: EnvCli -> Parser CardanoTestnetOptions
pCardanoTestnetCliOptions envCli = CardanoTestnetOptions
Expand Down Expand Up @@ -96,9 +96,9 @@ parseNodeConfigFile = NodeConfigurationYaml <$>
, "Or use num-pool-nodes to use cardano-testnet's default configuration."
]

pShelleyTestnetOptions :: Parser ShelleyTestnetOptions
pShelleyTestnetOptions =
ShelleyTestnetOptions
pGenesisOptions :: Parser GenesisOptions
pGenesisOptions =
GenesisOptions
<$> pNetworkId
<*> pEpochLength
<*> pSlotLength
Expand Down
4 changes: 2 additions & 2 deletions cardano-testnet/src/Testnet/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@ defaultShelleyGenesis
:: AnyShelleyBasedEra
-> UTCTime
-> Word64
-> ShelleyTestnetOptions
-> GenesisOptions
-> Api.ShelleyGenesis StandardCrypto
defaultShelleyGenesis asbe startTime maxSupply options = do
let ShelleyTestnetOptions
let GenesisOptions
{ shelleyTestnetMagic = magic
, shelleySlotLength = slotLength
, shelleyEpochLength = epochLength
Expand Down
6 changes: 3 additions & 3 deletions cardano-testnet/src/Testnet/Start/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ data ForkPoint
startTimeOffsetSeconds :: DTC.NominalDiffTime
startTimeOffsetSeconds = if OS.isWin32 then 90 else 15

-- | Like 'cardanoTestnet', but using 'ShelleyTestnetOptions' to obtain
-- | Like 'cardanoTestnet', but using 'GenesisOptions' to obtain
-- the genesis files, instead of passing them directly.
-- See 'cardanoTestnet' for additional documentation.
cardanoTestnetDefault
:: ()
=> HasCallStack
=> CardanoTestnetOptions
-> ShelleyTestnetOptions
-> GenesisOptions
-> Conf
-> H.Integration TestnetRuntime
cardanoTestnetDefault testnetOptions shelleyOptions conf = do
Expand All @@ -121,7 +121,7 @@ getDefaultShelleyGenesis :: ()
=> MonadTest m
=> AnyShelleyBasedEra
-> Word64 -- ^ The max supply
-> ShelleyTestnetOptions
-> GenesisOptions
-> m (ShelleyGenesis StandardCrypto)
getDefaultShelleyGenesis asbe maxSupply opts = do
currentTime <- H.noteShowIO DTC.getCurrentTime
Expand Down
18 changes: 9 additions & 9 deletions cardano-testnet/src/Testnet/Start/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Testnet.Start.Types
, TestnetNodeOptions(..)
, extraSpoNodeCliArgs
, cardanoDefaultTestnetNodeOptions
, ShelleyTestnetOptions(..)
, GenesisOptions(..)

, NodeLoggingFormat(..)
, Conf(..)
Expand All @@ -38,27 +38,27 @@ import qualified Hedgehog.Extras as H

-- | Command line options for the @cardano-testnet@ executable. They are used
-- in the parser, and then get split into 'CardanoTestnetOptions' and
-- 'ShelleyTestnetOptions'
-- 'GenesisOptions'
data CardanoTestnetCliOptions = CardanoTestnetCliOptions
{ cliTestnetOptions :: CardanoTestnetOptions
, cliShelleyOptions :: ShelleyTestnetOptions
, cliGenesisOptions :: GenesisOptions
} deriving (Eq, Show)

instance Default CardanoTestnetCliOptions where
def = CardanoTestnetCliOptions
{ cliTestnetOptions = def
, cliShelleyOptions = def
, cliGenesisOptions = def
}

-- | Options which, contrary to 'ShelleyTestnetOptions' are not implemented
-- | Options which, contrary to 'GenesisOptions' are not implemented
-- by tuning the genesis files.
data CardanoTestnetOptions = CardanoTestnetOptions
{ -- | List of node options. Each option will result in a single node being
-- created.
cardanoNodes :: [TestnetNodeOptions]
, cardanoNodeEra :: AnyShelleyBasedEra -- ^ The era to start at
, cardanoMaxSupply :: Word64 -- ^ The amount of Lovelace you are starting your testnet with (forwarded to shelley genesis)
-- TODO move me to ShelleyTestnetOptions when https://github.com/IntersectMBO/cardano-cli/pull/874 makes it to cardano-node
-- TODO move me to GenesisOptions when https://github.com/IntersectMBO/cardano-cli/pull/874 makes it to cardano-node
, cardanoEnableP2P :: Bool
, cardanoNodeLoggingFormat :: NodeLoggingFormat
, cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation
Expand All @@ -77,15 +77,15 @@ instance Default CardanoTestnetOptions where
}

-- | Options that are implemented by writing fields in the Shelley genesis file.
data ShelleyTestnetOptions = ShelleyTestnetOptions
data GenesisOptions = GenesisOptions
{ shelleyTestnetMagic :: Int -- TODO Use the NetworkMagic type from API
, shelleyEpochLength :: Int -- ^ An epoch's duration, in number of slots
, shelleySlotLength :: Double -- ^ Slot length, in seconds
, shelleyActiveSlotsCoeff :: Double
} deriving (Eq, Show)

instance Default ShelleyTestnetOptions where
def = ShelleyTestnetOptions
instance Default GenesisOptions where
def = GenesisOptions
{ shelleyTestnetMagic = 42
, shelleyEpochLength = 500
, shelleySlotLength = 0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import Testnet.Process.Cli.Transaction (TxOutAddress (ReferenceScriptA
import Testnet.Process.Run (execCli', execCliStdoutToJson, mkExecConfig)
import Testnet.Property.Assert (assertErasEqual)
import Testnet.Property.Util (integrationWorkspace)
import Testnet.Start.Types (ShelleyTestnetOptions(..))
import Testnet.Start.Types (GenesisOptions(..))
import Testnet.TestQueryCmds (TestQueryCmds (..), forallQueryCommands)
import Testnet.Types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import Testnet.Process.Cli.Transaction
import Testnet.Process.Run (execCli', mkExecConfig)
import Testnet.Property.Util (integrationWorkspace)
import Testnet.Types
import Testnet.Start.Types (ShelleyTestnetOptions(..))
import Testnet.Start.Types (GenesisOptions(..))

import Hedgehog
import qualified Hedgehog.Extras as H
Expand Down

0 comments on commit 3b168a0

Please sign in to comment.