Skip to content

Commit 53e05d9

Browse files
committed
cardano-testnet: modify API to accept user-provided configuration file
But we do not use this feature yet
1 parent ca38b9d commit 53e05d9

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

cardano-testnet/src/Testnet/Start/Cardano.hs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ cardanoTestnetDefault testnetOptions shelleyOptions conf = do
100100
AnyShelleyBasedEra sbe <- pure cardanoNodeEra
101101
alonzoGenesis <- getDefaultAlonzoGenesis sbe
102102
shelleyGenesis <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply shelleyOptions
103-
cardanoTestnet testnetOptions conf shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis
103+
cardanoTestnet testnetOptions conf Nothing shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis
104104
where
105105
CardanoTestnetOptions{cardanoNodeEra, cardanoMaxSupply} = testnetOptions
106106

@@ -194,13 +194,14 @@ cardanoTestnet :: ()
194194
=> HasCallStack
195195
=> CardanoTestnetOptions -- ^ The options to use
196196
-> Conf
197+
-> Maybe FilePath -- ^ The node configuration file to use. If omitted it's generated.
197198
-> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use, for example 'getDefaultShelleyGenesis' from this module.
198199
-- Some fields are overridden by the accompanying 'CardanoTestnetOptions'.
199200
-> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module.
200201
-> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'.
201202
-> H.Integration TestnetRuntime
202203
cardanoTestnet
203-
testnetOptions Conf{tempAbsPath=TmpAbsolutePath tmpAbsPath}
204+
testnetOptions Conf{tempAbsPath=TmpAbsolutePath tmpAbsPath} mNodeConfigFile
204205
shelleyGenesis alonzoGenesis conwayGenesis = do
205206
let CardanoTestnetOptions
206207
{ cardanoNodeEra=asbe
@@ -232,8 +233,6 @@ cardanoTestnet
232233
writeGenesisSpecFile "alonzo" alonzoGenesis
233234
writeGenesisSpecFile "conway" conwayGenesis
234235

235-
configurationFile <- H.noteShow . File $ tmpAbsPath </> "configuration.yaml"
236-
237236
_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
238237

239238
-- TODO: This should come from the configuration!
@@ -272,12 +271,18 @@ cardanoTestnet
272271
}
273272
}
274273

275-
-- Add Byron, Shelley and Alonzo genesis hashes to node configuration
276-
config <- createConfigJson (TmpAbsolutePath tmpAbsPath) sbe
277-
H.evalIO $ LBS.writeFile (unFile configurationFile) config
274+
nodeConfigFile <- case mNodeConfigFile of
275+
Nothing -> do
276+
configurationFile <- H.noteShow $ tmpAbsPath </> "configuration.yaml"
277+
-- Add Byron, Shelley and Alonzo genesis hashes to node configuration
278+
config <- createConfigJson (TmpAbsolutePath tmpAbsPath) sbe
279+
H.evalIO $ LBS.writeFile configurationFile config
280+
return configurationFile
281+
Just userSubmittedNodeConfigFile -> pure userSubmittedNodeConfigFile
282+
278283
execCli_
279284
[ "debug", "check-node-configuration"
280-
, "--node-configuration-file", unFile configurationFile
285+
, "--node-configuration-file", nodeConfigFile
281286
]
282287

283288
portNumbersWithNodeOptions <- forM cardanoNodes $ \nodeOption -> (nodeOption,) <$> H.randomPort testnetDefaultIpv4Address
@@ -324,7 +329,7 @@ cardanoTestnet
324329
eRuntime <- runExceptT . retryOnAddressInUseError $
325330
startNode (TmpAbsolutePath tmpAbsPath) nodeName testnetDefaultIpv4Address port testnetMagic $
326331
[ "run"
327-
, "--config", unFile configurationFile
332+
, "--config", nodeConfigFile
328333
, "--topology", nodeDataDir </> "topology.json"
329334
, "--database-path", nodeDataDir </> "db"
330335
]
@@ -352,7 +357,7 @@ cardanoTestnet
352357
H.cat . verificationKeyFp $ paymentKeyInfoPair wallet
353358

354359
let runtime = TestnetRuntime
355-
{ configurationFile
360+
{ configurationFile = File nodeConfigFile
356361
, shelleyGenesisFile = tmpAbsPath </> Defaults.defaultGenesisFilepath ShelleyEra
357362
, testnetMagic
358363
, testnetNodes=testnetNodes'

0 commit comments

Comments
 (0)