11{-# LANGUAGE GADTs #-}
22{-# LANGUAGE LambdaCase #-}
3- {-# LANGUAGE NamedFieldPuns #-}
43{-# LANGUAGE ScopedTypeVariables #-}
54
65module Parsers.Run
@@ -11,12 +10,16 @@ module Parsers.Run
1110 ) where
1211
1312import Cardano.CLI.Environment
13+ import Control.Monad
14+ import Control.Monad.Trans.Class (lift )
15+ import Control.Monad.Trans.Resource (getInternalState )
1416
1517import Data.Default.Class (def )
1618import Data.Foldable
1719import Options.Applicative
1820import qualified Options.Applicative as Opt
19-
21+ import RIO (runRIO )
22+ import RIO.Orphans
2023import Testnet.Property.Run
2124import Testnet.Start.Cardano
2225import Testnet.Start.Types
@@ -61,34 +64,36 @@ createEnvOptions CardanoTestnetCreateEnvOptions
6164 , createEnvOutputDir= outputDir
6265 , createEnvCreateEnvOptions= ceOptions
6366 } =
64- testnetRoutine (UserProvidedEnv outputDir) $ \ conf -> do
65- createTestnetEnv
66- testnetOptions genesisOptions ceOptions
67- -- Do not add hashes to the main config file, so that genesis files
68- -- can be modified without having to recompute hashes every time.
69- conf{genesisHashesPolicy = WithoutHashes }
67+ testnetRoutine (UserProvidedEnv outputDir) $ \ conf -> do
68+ r <- lift $ lift getInternalState
69+ liftToIntegration r $
70+ createTestnetEnv
71+ testnetOptions genesisOptions ceOptions
72+ -- Do not add hashes to the main config file, so that genesis files
73+ -- can be modified without having to recompute hashes every time.
74+ conf{genesisHashesPolicy = WithoutHashes }
7075
7176runCardanoOptions :: CardanoTestnetCliOptions -> IO ()
7277runCardanoOptions CardanoTestnetCliOptions
73- { cliTestnetOptions= testnetOptions@ CardanoTestnetOptions {cardanoOutputDir}
78+ { cliTestnetOptions= testnetOptions
7479 , cliGenesisOptions= genesisOptions
7580 , cliNodeEnvironment= env
76- , cliUpdateTimestamps= updateTimestamps
81+ , cliUpdateTimestamps= updateTimestamps'
7782 } =
7883 case env of
79- NoUserProvidedEnv ->
84+ NoUserProvidedEnv -> do
8085 -- Create the sandbox, then run cardano-testnet.
8186 -- It is not necessary to honor `cliUpdateTimestamps` here, because
8287 -- the genesis files will be created with up-to-date stamps already.
83- runTestnet cardanoOutputDir $ \ conf -> do
84- createTestnetEnv
85- testnetOptions genesisOptions def
86- conf
87- cardanoTestnet testnetOptions conf
88- UserProvidedEnv nodeEnvPath ->
88+ conf <- mkConfigAbs " testnet "
89+ runRIO () $ createTestnetEnv
90+ testnetOptions genesisOptions def
91+ conf
92+ withResourceMap ( \ rm -> void . runRIO rm $ cardanoTestnet testnetOptions conf)
93+ UserProvidedEnv nodeEnvPath -> do
8994 -- Run cardano-testnet in the sandbox provided by the user
9095 -- In that case, 'cardanoOutputDir' is not used
91- runTestnet ( UserProvidedEnv nodeEnvPath) $ \ conf ->
92- cardanoTestnet
96+ conf <- mkConfigAbs nodeEnvPath
97+ withResourceMap ( \ rm -> void . runRIO rm $ cardanoTestnet
9398 testnetOptions
94- conf{updateTimestamps= updateTimestamps}
99+ conf{updateTimestamps= updateTimestamps'})
0 commit comments