Skip to content

Commit d696dd0

Browse files
committed
Sanity check works!
1 parent 64ed665 commit d696dd0

File tree

22 files changed

+753
-224
lines changed

22 files changed

+753
-224
lines changed

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ packages:
3535
-- Needed when cross compiling
3636
extra-packages: alex
3737

38-
program-options
39-
ghc-options: -Werror
38+
-- program-options
39+
-- ghc-options: -Werror
4040

4141
test-show-details: direct
4242

cardano-node/src/Cardano/Node/Protocol/Byron.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Cardano.Tracing.OrphanInstances.Shelley ()
3636
import Ouroboros.Consensus.Cardano
3737
import qualified Ouroboros.Consensus.Cardano as Consensus
3838

39+
import Control.Exception
3940
import qualified Data.ByteString.Lazy as LB
4041
import Data.Maybe (fromMaybe)
4142
import Data.Text (Text)
@@ -167,6 +168,9 @@ data ByronProtocolInstantiationError =
167168
| SigningKeyFilepathNotSpecified
168169
deriving Show
169170

171+
instance Exception ByronProtocolInstantiationError where
172+
displayException = docToString . prettyError
173+
170174
instance Error ByronProtocolInstantiationError where
171175
prettyError (CanonicalDecodeFailure fp failure) =
172176
"Canonical decode failure in " <> pshow fp

cardano-testnet/cardano-testnet.cabal

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ library
8686
, process
8787
, resourcet
8888
, retry
89+
, rio
90+
, rio-orphans
8991
, safe-exceptions
9092
, scientific
9193
, si-timers
@@ -98,6 +100,7 @@ library
98100
, time
99101
, transformers
100102
, transformers-except
103+
, unliftio-core
101104
, vector
102105
, yaml
103106

@@ -111,17 +114,20 @@ library
111114
Testnet.EpochStateProcessing
112115
Testnet.Filepath
113116
Testnet.Handlers
117+
Testnet.Orphans
114118
Testnet.Ping
115119
Testnet.Process.Cli.DRep
116120
Testnet.Process.Cli.Keys
117121
Testnet.Process.Cli.SPO
118122
Testnet.Process.Cli.Transaction
123+
Testnet.Process.NewRun
119124
Testnet.Process.Run
120125
Testnet.Property.Assert
121126
Testnet.Property.Run
122127
Testnet.Property.Util
123128
Testnet.Runtime
124129
Testnet.Start.Byron
130+
Testnet.Start.Cardano
125131
Testnet.Start.Types
126132
Testnet.SubmitApi
127133
Testnet.TestQueryCmds
@@ -130,7 +136,6 @@ library
130136
other-modules: Parsers.Cardano
131137
Parsers.Help
132138
Parsers.Version
133-
Testnet.Start.Cardano
134139
Testnet.TestEnumGenerator
135140
Paths_cardano_testnet
136141

@@ -266,6 +271,7 @@ test-suite cardano-testnet-test
266271
, mtl
267272
, process
268273
, regex-compat
274+
, resourcet
269275
, rio
270276
, tasty ^>= 1.5
271277
, text

cardano-testnet/src/Parsers/Run.hs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE GADTs #-}
22
{-# LANGUAGE LambdaCase #-}
3-
{-# LANGUAGE NamedFieldPuns #-}
43
{-# LANGUAGE ScopedTypeVariables #-}
54

65
module Parsers.Run
@@ -11,12 +10,16 @@ module Parsers.Run
1110
) where
1211

1312
import Cardano.CLI.Environment
13+
import Control.Monad
14+
import Control.Monad.Trans.Class (lift)
15+
import Control.Monad.Trans.Resource (getInternalState)
1416

1517
import Data.Default.Class (def)
1618
import Data.Foldable
1719
import Options.Applicative
1820
import qualified Options.Applicative as Opt
19-
21+
import RIO (runRIO)
22+
import RIO.Orphans
2023
import Testnet.Property.Run
2124
import Testnet.Start.Cardano
2225
import 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

7176
runCardanoOptions :: CardanoTestnetCliOptions -> IO ()
7277
runCardanoOptions 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

Comments
 (0)