@@ -19,8 +19,8 @@ module Testnet.Start.Cardano
1919
2020 , cardanoTestnet
2121 , cardanoTestnetDefault
22- , getDefaultAlonzoGenesis
23- , getDefaultShelleyGenesis
22+ , getDefaultAlonzoGenesis -- TODO, stop exporting me when Shutdown.hs is refactored to use cardanoTestnet
23+ , getDefaultGenesisBatch
2424 , retryOnAddressInUseError
2525 ) where
2626
@@ -29,7 +29,6 @@ import Cardano.Api
2929import Cardano.Api.Ledger (StandardCrypto )
3030
3131import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis )
32- import Cardano.Ledger.Conway.Genesis (ConwayGenesis )
3332import Cardano.Node.Configuration.Topology
3433
3534import Prelude hiding (lines )
@@ -88,6 +87,7 @@ startTimeOffsetSeconds = if OS.isWin32 then 90 else 15
8887-- | Like 'cardanoTestnet', but using 'GenesisOptions' to obtain
8988-- the genesis files, instead of passing them directly.
9089-- See 'cardanoTestnet' for additional documentation.
90+ -- TODO delete me? @cardano-testnet@ plus @getDefaultGenesisBatch@ suffice now.
9191cardanoTestnetDefault
9292 :: ()
9393 => HasCallStack
@@ -96,12 +96,8 @@ cardanoTestnetDefault
9696 -> Conf
9797 -> H. Integration TestnetRuntime
9898cardanoTestnetDefault testnetOptions shelleyOptions conf = do
99- AnyShelleyBasedEra sbe <- pure cardanoNodeEra
100- alonzoGenesis <- getDefaultAlonzoGenesis sbe
101- shelleyGenesis <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply shelleyOptions
102- cardanoTestnet testnetOptions conf UserNodeConfigNotSubmitted shelleyGenesis alonzoGenesis Defaults. defaultConwayGenesis
103- where
104- CardanoTestnetOptions {cardanoNodeEra, cardanoMaxSupply} = testnetOptions
99+ batch <- getDefaultGenesisBatch testnetOptions shelleyOptions
100+ cardanoTestnet testnetOptions conf UserNodeConfigNotSubmitted batch
105101
106102-- | An 'AlonzoGenesis' value that is fit to pass to 'cardanoTestnet'
107103getDefaultAlonzoGenesis :: ()
@@ -125,6 +121,23 @@ getDefaultShelleyGenesis asbe maxSupply opts = do
125121 startTime <- H. noteShow $ DTC. addUTCTime startTimeOffsetSeconds currentTime
126122 return $ Defaults. defaultShelleyGenesis asbe startTime maxSupply opts
127123
124+ -- | Get a 'GenesisBatch' that is fit to pass to 'cardanoTestnet'
125+ getDefaultGenesisBatch
126+ :: ()
127+ => HasCallStack
128+ => MonadIO m
129+ => MonadTest m
130+ => CardanoTestnetOptions
131+ -> GenesisOptions
132+ -> m GenesisBatch
133+ getDefaultGenesisBatch testnetOptions shelleyOptions = do
134+ AnyShelleyBasedEra sbe <- pure cardanoNodeEra
135+ alonzoGenesis <- getDefaultAlonzoGenesis sbe
136+ shelleyGenesis <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply shelleyOptions
137+ return (GenesisBatch (shelleyGenesis, alonzoGenesis, Defaults. defaultConwayGenesis, DefaultedOrigin ))
138+ where
139+ CardanoTestnetOptions {cardanoNodeEra, cardanoMaxSupply} = testnetOptions
140+
128141-- | Setup a number of credentials and nodes (SPOs and relays), like this:
129142--
130143-- > ├── byron-gen-command
@@ -194,14 +207,15 @@ cardanoTestnet :: ()
194207 => CardanoTestnetOptions -- ^ The options to use
195208 -> Conf
196209 -> UserNodeConfig -- ^ The node configuration file to use. If omitted it's generated.
197- -> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use, for example 'getDefaultShelleyGenesis' from this module.
198- -- Some fields are overridden by the accompanying 'CardanoTestnetOptions'.
199- -> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module.
200- -> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'.
210+ -> GenesisBatch
211+ -- ^ The shelley genesis to use, for example 'getDefaultShelleyGenesis' from this module,
212+ -- and whether they ar provided by the user or defaulted by 'cardano-testnet'.
213+ -- Some fields are overridden by the accompanying 'CardanoTestnetOptions' (TODO: don't override
214+ -- anything when the user provided the files)
201215 -> H. Integration TestnetRuntime
202216cardanoTestnet
203217 testnetOptions Conf {tempAbsPath= TmpAbsolutePath tmpAbsPath} mNodeConfigFile
204- shelleyGenesis alonzoGenesis conwayGenesis = do
218+ genesisBatch @ ( GenesisBatch ( shelleyGenesis, alonzoGenesis, conwayGenesis, _)) = do
205219 let CardanoTestnetOptions
206220 { cardanoNodeEra= asbe
207221 , cardanoMaxSupply= maxSupply
@@ -225,7 +239,7 @@ cardanoTestnet
225239 writeGenesisSpecFile " alonzo" alonzoGenesis
226240 writeGenesisSpecFile " conway" conwayGenesis
227241
228- _ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
242+ _ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe genesisBatch (TmpAbsolutePath tmpAbsPath)
229243
230244 -- TODO: This should come from the configuration!
231245 let makePathsAbsolute :: (Element a ~ FilePath , MonoFunctor a ) => a -> a
0 commit comments