Skip to content

Commit ff2f3c4

Browse files
committed
export API from Cardano.Testnet
1 parent 8177c2f commit ff2f3c4

20 files changed

+345
-309
lines changed

cardano-node-chairman/test/Spec/Chairman/Byron.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import qualified Hedgehog as H
1414
import qualified Hedgehog.Extras.Test.Base as H
1515
import qualified Hedgehog.Extras.Test.Process as H
1616
import qualified System.Directory as IO
17-
import qualified Testnet.Byron as H
18-
import qualified Testnet.Conf as H
19-
import qualified Util.Base as H
17+
18+
import qualified Testnet.Byron as B
19+
import qualified Cardano.Testnet as H
2020

2121
{- HLINT ignore "Reduce duplication" -}
2222
{- HLINT ignore "Redundant <&>" -}
@@ -27,6 +27,6 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp
2727
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
2828
configurationTemplate <- H.noteShow $ base </> "configuration/defaults/byron-mainnet/configuration.yaml"
2929
conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing
30-
allNodes <- H.testnet H.defaultTestnetOptions conf
30+
allNodes <- B.testnet B.defaultTestnetOptions conf
3131

3232
chairmanOver 120 52 conf allNodes

cardano-node-chairman/test/Spec/Chairman/Cardano.hs

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ import Data.Maybe
1111
import Spec.Chairman.Chairman (chairmanOver)
1212
import System.FilePath ((</>))
1313

14-
import Testnet ( TestnetOptions( CardanoOnlyTestnetOptions), testnet)
15-
1614
import qualified Hedgehog as H
1715
import qualified Hedgehog.Extras.Test.Base as H
1816
import qualified Hedgehog.Extras.Test.Process as H
1917
import qualified System.Directory as IO
20-
import qualified Testnet.Cardano as H
21-
import qualified Testnet.Conf as H
22-
import qualified Util.Base as H
23-
import qualified Util.Runtime as H
18+
19+
import qualified Cardano.Testnet as H
2420

2521
{- HLINT ignore "Reduce duplication" -}
2622
{- HLINT ignore "Redundant <&>" -}
@@ -32,6 +28,6 @@ hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \temp
3228
configurationTemplate <- H.noteShow $ base </> "configuration/defaults/byron-mainnet/configuration.yaml"
3329
conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing
3430

35-
allNodes <- fmap H.nodeName . H.allNodes <$> testnet (CardanoOnlyTestnetOptions H.defaultTestnetOptions) conf
31+
allNodes <- fmap H.nodeName . H.allNodes <$> H.testnet (H.CardanoOnlyTestnetOptions H.cardanoDefaultTestnetOptions) conf
3632

3733
chairmanOver 120 50 conf allNodes

cardano-node-chairman/test/Spec/Chairman/Chairman.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import qualified Hedgehog.Extras.Test.Process as H
3131
import qualified System.Environment as IO
3232
import qualified System.IO as IO
3333
import qualified System.Process as IO
34-
import qualified Testnet.Conf as H
35-
import qualified Util.Process as H
34+
35+
import qualified Cardano.Testnet as H
3636

3737
{- HLINT ignore "Reduce duplication" -}
3838
{- HLINT ignore "Redundant <&>" -}

cardano-node-chairman/test/Spec/Chairman/Shelley.hs

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ import qualified Hedgehog as H
1212
import qualified Hedgehog.Extras.Test.Base as H
1313
import qualified Hedgehog.Extras.Test.Process as H
1414
import qualified System.Directory as IO
15-
import qualified Testnet.Conf as H
16-
import qualified Testnet.Shelley as H
17-
import qualified Util.Base as H
18-
import qualified Util.Runtime as H
15+
16+
import qualified Cardano.Testnet as H
1917

2018
hprop_chairman :: H.Property
2119
hprop_chairman = H.integration . H.runFinallies . H.workspace "chairman" $ \tempAbsPath' -> do
2220
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
2321
configurationTemplate <- H.noteShow $ base </> "configuration/defaults/byron-mainnet/configuration.yaml"
2422
conf <- H.mkConf (H.ProjectBase base) (H.YamlFilePath configurationTemplate) tempAbsPath' Nothing
2523

26-
allNodes <- fmap H.nodeName . H.allNodes <$> H.shelleyTestnet H.defaultTestnetOptions conf
24+
allNodes <- fmap H.nodeName . H.allNodes <$> H.testnet (H.ShelleyOnlyTestnetOptions H.shelleyDefaultTestnetOptions) conf
2725

2826
chairmanOver 120 21 conf allNodes

cardano-testnet/app/cardano-testnet.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Data.Function
55
import Data.Semigroup
66
import Options.Applicative
77
import System.IO (IO)
8-
import Parsers
8+
import Cardano.Testnet (commands)
99

1010
main :: IO ()
1111
main = join $ customExecParser

cardano-testnet/cardano-testnet.cabal

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ library
5757
, unordered-containers
5858

5959
hs-source-dirs: src
60-
exposed-modules: Parsers
60+
exposed-modules: Cardano.Testnet
61+
Testnet.Byron
62+
63+
other-modules: Parsers
6164
Parsers.Babbage
6265
Parsers.Byron
6366
Parsers.Cardano
@@ -70,14 +73,12 @@ library
7073
Util.Runtime
7174
Testnet
7275
Testnet.Babbage
73-
Testnet.Byron
7476
Testnet.Cardano
7577
Testnet.Conf
7678
Testnet.Run
7779
Testnet.Shelley
7880
Testnet.Utils
79-
80-
other-modules: Paths_cardano_testnet
81+
Paths_cardano_testnet
8182

8283
autogen-modules: Paths_cardano_testnet
8384

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module Cardano.Testnet
2+
( Babbage.BabbageTestnetOptions(..)
3+
, Cardano.CardanoTestnetOptions(..)
4+
, Shelley.ShelleyTestnetOptions(..)
5+
, TestnetOptions(..)
6+
, TestnetNodeOptions(..)
7+
, babbageDefaultTestnetOptions
8+
, cardanoDefaultTestnetOptions
9+
, cardanoDefaultTestnetNodeOptions
10+
, shelleyDefaultTestnetOptions
11+
, testnet
12+
13+
, Conf(..)
14+
, ProjectBase(..)
15+
, YamlFilePath(..)
16+
, mkConf
17+
18+
, execCli
19+
, execCli'
20+
, execCli_
21+
, procNode
22+
, procChairman
23+
24+
, getRelevantLeaderSlots
25+
26+
, assertByDeadlineMCustom
27+
, integration
28+
, isLinux
29+
, waitUntilEpoch
30+
31+
, disabled
32+
, ignoreOnWindows
33+
, ignoreOnMacAndWindows
34+
35+
, LeadershipSlot(..)
36+
, NodeLoggingFormat(..)
37+
, PaymentKeyPair(..)
38+
, StakingKeyPair(..)
39+
, TestnetRuntime(..)
40+
, NodeRuntime(..)
41+
, PoolNode(..)
42+
, PoolNodeKeys(..)
43+
, Delegator(..)
44+
, allNodes
45+
, bftSprockets
46+
, poolSprockets
47+
, poolNodeStdout
48+
, readNodeLoggingFormat
49+
, startNode
50+
51+
, commands
52+
) where
53+
54+
import Testnet
55+
import Testnet.Babbage as Babbage
56+
import Testnet.Cardano as Cardano
57+
import Testnet.Shelley as Shelley
58+
import Testnet.Utils (waitUntilEpoch)
59+
import Testnet.Conf hiding (base)
60+
import Parsers (commands)
61+
import Util.Assert
62+
import Util.Base (integration, isLinux)
63+
import Util.Ignore (disabled, ignoreOnWindows, ignoreOnMacAndWindows)
64+
import Util.Process (assertByDeadlineMCustom, execCli, execCli', execCli_, procChairman, procNode)
65+
import Util.Runtime

cardano-testnet/src/Parsers/Babbage.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,35 @@ optsTestnet = BabbageTestnetOptions
2525
<> OA.help "Number of SPO nodes"
2626
<> OA.metavar "COUNT"
2727
<> OA.showDefault
28-
<> OA.value (numSpoNodes defaultTestnetOptions)
28+
<> OA.value (babbageNumSpoNodes defaultTestnetOptions)
2929
)
3030
<*> OA.option auto
3131
( OA.long "slot-duration"
3232
<> OA.help "Slot duration"
3333
<> OA.metavar "MILLISECONDS"
3434
<> OA.showDefault
35-
<> OA.value (slotDuration defaultTestnetOptions)
35+
<> OA.value (babbageSlotDuration defaultTestnetOptions)
3636
)
3737
<*> OA.option auto
3838
( OA.long "security-param"
3939
<> OA.help "Security parameter"
4040
<> OA.metavar "INT"
4141
<> OA.showDefault
42-
<> OA.value (securityParam defaultTestnetOptions)
42+
<> OA.value (babbageSecurityParam defaultTestnetOptions)
4343
)
4444
<*> OA.option auto
4545
( OA.long "total-balance"
4646
<> OA.help "Total balance"
4747
<> OA.metavar "INT"
4848
<> OA.showDefault
49-
<> OA.value (totalBalance defaultTestnetOptions)
49+
<> OA.value (babbageTotalBalance defaultTestnetOptions)
5050
)
5151
<*> OA.option (OA.eitherReader readNodeLoggingFormat)
5252
( OA.long "nodeLoggingFormat"
5353
<> OA.help "Node logging format (json|text)"
5454
<> OA.metavar "LOGGING_FORMAT"
5555
<> OA.showDefault
56-
<> OA.value (nodeLoggingFormat defaultTestnetOptions)
56+
<> OA.value (babbageNodeLoggingFormat defaultTestnetOptions)
5757
)
5858

5959
optsBabbage :: Parser BabbageOptions

cardano-testnet/src/Parsers/Cardano.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,61 +26,61 @@ data CardanoOptions = CardanoOptions
2626
optsTestnet :: Parser CardanoTestnetOptions
2727
optsTestnet = CardanoTestnetOptions
2828
<$> OA.option
29-
((`L.replicate` defaultTestnetNodeOptions) <$> auto)
29+
((`L.replicate` cardanoDefaultTestnetNodeOptions) <$> auto)
3030
( OA.long "num-bft-nodes"
3131
<> OA.help "Number of BFT nodes"
3232
<> OA.metavar "COUNT"
3333
<> OA.showDefault
34-
<> OA.value (bftNodeOptions defaultTestnetOptions)
34+
<> OA.value (cardanoBftNodeOptions defaultTestnetOptions)
3535
)
3636
<*> OA.option auto
3737
( OA.long "num-pool-nodes"
3838
<> OA.help "Number of pool nodes"
3939
<> OA.metavar "COUNT"
4040
<> OA.showDefault
41-
<> OA.value (numPoolNodes defaultTestnetOptions)
41+
<> OA.value (cardanoNumPoolNodes defaultTestnetOptions)
4242
)
4343
<*> OA.option (OA.eitherReader readEither)
4444
( OA.long "era"
4545
<> OA.help ("Era to upgrade to. " <> show @[Era] [minBound .. maxBound])
4646
<> OA.metavar "ERA"
4747
<> OA.showDefault
48-
<> OA.value (era defaultTestnetOptions)
48+
<> OA.value (cardanoEra defaultTestnetOptions)
4949
)
5050
<*> OA.option auto
5151
( OA.long "epoch-length"
5252
<> OA.help "Epoch length"
5353
<> OA.metavar "MILLISECONDS"
5454
<> OA.showDefault
55-
<> OA.value (epochLength defaultTestnetOptions)
55+
<> OA.value (cardanoEpochLength defaultTestnetOptions)
5656
)
5757
<*> OA.option auto
5858
( OA.long "slot-length"
5959
<> OA.help "Slot length"
6060
<> OA.metavar "SECONDS"
6161
<> OA.showDefault
62-
<> OA.value (slotLength defaultTestnetOptions)
62+
<> OA.value (cardanoSlotLength defaultTestnetOptions)
6363
)
6464
<*> OA.option auto
6565
( OA.long "active-slots-coeff"
6666
<> OA.help "Active slots co-efficient"
6767
<> OA.metavar "DOUBLE"
6868
<> OA.showDefault
69-
<> OA.value (activeSlotsCoeff defaultTestnetOptions)
69+
<> OA.value (cardanoActiveSlotsCoeff defaultTestnetOptions)
7070
)
7171
<*> OA.option auto
7272
( OA.long "enable-p2p"
7373
<> OA.help "Enable P2P"
7474
<> OA.metavar "BOOL"
7575
<> OA.showDefault
76-
<> OA.value (enableP2P defaultTestnetOptions)
76+
<> OA.value (cardanoEnableP2P defaultTestnetOptions)
7777
)
7878
<*> OA.option (OA.eitherReader readNodeLoggingFormat)
7979
( OA.long "nodeLoggingFormat"
8080
<> OA.help "Node logging format (json|text)"
8181
<> OA.metavar "LOGGING_FORMAT"
8282
<> OA.showDefault
83-
<> OA.value (nodeLoggingFormat defaultTestnetOptions)
83+
<> OA.value (cardanoNodeLoggingFormat defaultTestnetOptions)
8484
)
8585

8686
optsCardano :: Parser CardanoOptions

cardano-testnet/src/Parsers/Shelley.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,56 +31,56 @@ optsTestnet = ShelleyTestnetOptions
3131
<> OA.help "Number of PRAOS nodes"
3232
<> OA.metavar "COUNT"
3333
<> OA.showDefault
34-
<> OA.value (numPraosNodes defaultTestnetOptions)
34+
<> OA.value (shelleyNumPraosNodes defaultTestnetOptions)
3535
)
3636
<*> OA.option auto
3737
( OA.long "num-pool-nodes"
3838
<> OA.help "Number of pool nodes"
3939
<> OA.metavar "COUNT"
4040
<> OA.showDefault
41-
<> OA.value (numPoolNodes defaultTestnetOptions)
41+
<> OA.value (shelleyNumPoolNodes defaultTestnetOptions)
4242
)
4343
<*> OA.option auto
4444
( OA.long "active-slots-coeff"
4545
<> OA.help "Active slots co-efficient"
4646
<> OA.metavar "DOUBLE"
4747
<> OA.showDefault
48-
<> OA.value (activeSlotsCoeff defaultTestnetOptions)
48+
<> OA.value (shelleyActiveSlotsCoeff defaultTestnetOptions)
4949
)
5050
<*> OA.option auto
5151
( OA.long "security-param"
5252
<> OA.help "Security param"
5353
<> OA.metavar "INT"
5454
<> OA.showDefault
55-
<> OA.value (securityParam defaultTestnetOptions)
55+
<> OA.value (shelleySecurityParam defaultTestnetOptions)
5656
)
5757
<*> OA.option auto
5858
( OA.long "epoch-length"
5959
<> OA.help "Epoch length"
6060
<> OA.metavar "MILLISECONDS"
6161
<> OA.showDefault
62-
<> OA.value (epochLength defaultTestnetOptions)
62+
<> OA.value (shelleyEpochLength defaultTestnetOptions)
6363
)
6464
<*> OA.option auto
6565
( OA.long "slot-length"
6666
<> OA.help "Slot length"
6767
<> OA.metavar "MILLISECONDS"
6868
<> OA.showDefault
69-
<> OA.value (slotLength defaultTestnetOptions)
69+
<> OA.value (shelleySlotLength defaultTestnetOptions)
7070
)
7171
<*> OA.option auto
7272
( OA.long "max-lovelace-supply"
7373
<> OA.help "Max lovelace supply"
7474
<> OA.metavar "INTEGER"
7575
<> OA.showDefault
76-
<> OA.value (maxLovelaceSupply defaultTestnetOptions)
76+
<> OA.value (shelleyMaxLovelaceSupply defaultTestnetOptions)
7777
)
7878
<*> OA.option auto
7979
( OA.long "enable-p2p"
8080
<> OA.help "Enable P2P"
8181
<> OA.metavar "BOOL"
8282
<> OA.showDefault
83-
<> OA.value (enableP2P defaultTestnetOptions)
83+
<> OA.value (shelleyEnableP2P defaultTestnetOptions)
8484
)
8585

8686
optsShelley :: Parser ShelleyOptions

cardano-testnet/src/Testnet.hs

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module Testnet
22
( TestnetOptions(..)
3+
, babbageDefaultTestnetOptions
4+
, cardanoDefaultTestnetOptions
5+
, shelleyDefaultTestnetOptions
36
, Testnet.testnet
47
) where
58

@@ -8,10 +11,10 @@ import Text.Show (Show)
811

912
import qualified Hedgehog.Extras.Test.Base as H
1013

11-
import Testnet.Babbage
12-
import Testnet.Cardano
14+
import Testnet.Babbage as Babbage
15+
import Testnet.Cardano as Cardano
1316
import Testnet.Conf
14-
import Testnet.Shelley
17+
import Testnet.Shelley as Shelley
1518

1619
data TestnetOptions
1720
= ShelleyOnlyTestnetOptions ShelleyTestnetOptions
@@ -25,3 +28,11 @@ testnet options = case options of
2528
BabbageOnlyTestnetOptions o -> babbageTestnet o
2629
CardanoOnlyTestnetOptions o -> cardanoTestnet o
2730

31+
babbageDefaultTestnetOptions :: BabbageTestnetOptions
32+
babbageDefaultTestnetOptions = Babbage.defaultTestnetOptions
33+
34+
cardanoDefaultTestnetOptions :: CardanoTestnetOptions
35+
cardanoDefaultTestnetOptions = Cardano.defaultTestnetOptions
36+
37+
shelleyDefaultTestnetOptions :: ShelleyTestnetOptions
38+
shelleyDefaultTestnetOptions = Shelley.defaultTestnetOptions

0 commit comments

Comments
 (0)