Skip to content

Commit

Permalink
Move the local-cluster exe code into the exe source dir
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Apr 23, 2024
1 parent ec4dc46 commit 0ed39a9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 51 deletions.
6 changes: 3 additions & 3 deletions lib/benchmarks/exe/latency-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ import Cardano.Wallet.Launch.Cluster
, withCluster
, withFaucet
)
import Cardano.Wallet.Launch.Cluster.CommandLine
( clusterConfigsDirParser
)
import Cardano.Wallet.Launch.Cluster.FileOf
( DirOf (..)
, mkRelDirOf
, newAbsolutizer
, toFilePath
)
import Cardano.Wallet.LocalCluster
( clusterConfigsDirParser
)
import Cardano.Wallet.Network.Implementation.Ouroboros
( tunedForMainnetPipeliningStrategy
)
Expand Down
6 changes: 0 additions & 6 deletions lib/local-cluster/exe/Cluster.hs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Wallet.LocalCluster where

import Prelude

import Cardano.Address.Style.Shelley
Expand All @@ -32,20 +30,18 @@ import Cardano.Wallet.Launch.Cluster
, FaucetFunds (..)
, withFaucet
)
import Cardano.Wallet.Launch.Cluster.CommandLine
( CommandLineOptions (..)
, parseCommandLineOptions
)
import Cardano.Wallet.Launch.Cluster.FileOf
( Absolutizer (..)
, DirOf (..)
( DirOf (..)
, FileOf (..)
, mkRelDirOf
, newAbsolutizer
, toFilePath
)
import Cardano.Wallet.Primitive.Types.Coin
( Coin (..)
)
import Control.Applicative
( (<**>)
)
import Control.Lens
( over
)
Expand All @@ -59,9 +55,6 @@ import Control.Monad.Trans.Resource
import Main.Utf8
( withUtf8
)
import System.Directory
( createDirectoryIfMissing
)
import System.Environment.Extended
( isEnvSet
)
Expand All @@ -71,12 +64,14 @@ import System.IO.Temp.Extra
)
import System.Path
( absDir
, absRel
, parse
, relDir
, relFile
, (</>)
)
import System.Path.Directory
( createDirectoryIfMissing
)
import UnliftIO.Concurrent
( threadDelay
)
Expand All @@ -85,7 +80,6 @@ import qualified Cardano.Node.Cli.Launcher as NC
import qualified Cardano.Wallet.Cli.Launcher as WC
import qualified Cardano.Wallet.Faucet as Faucet
import qualified Cardano.Wallet.Launch.Cluster as Cluster
import qualified Options.Applicative as O

-- |
-- # OVERVIEW
Expand Down Expand Up @@ -249,7 +243,7 @@ main = withUtf8 $ do
$ \node -> do
let clusterDir = absDir clusterPath
let walletDir = clusterDir </> relDir "wallet"
createDirectoryIfMissing True $ toFilePath walletDir
createDirectoryIfMissing True walletDir
nodeSocket <-
case parse . nodeSocketFile
$ Cluster.runningNodeSocketPath node of
Expand All @@ -273,32 +267,10 @@ main = withUtf8 $ do
Nothing
, WC.walletByronGenesisForTestnet =
Just
$ FileOf $ clusterDir </>
relFile "byron-genesis.json"
$ FileOf
$ clusterDir
</> relFile "byron-genesis.json"
}
)
(WC.stop . fst)
threadDelay maxBound -- wait for Ctrl+C

newtype CommandLineOptions = CommandLineOptions
{clusterConfigsDir :: DirOf "cluster-configs"}
deriving stock (Show)

parseCommandLineOptions :: IO CommandLineOptions
parseCommandLineOptions = do
absolutizer <- newAbsolutizer
O.execParser
$ O.info
( fmap CommandLineOptions (clusterConfigsDirParser absolutizer)
<**> O.helper
)
(O.progDesc "Local Cluster for testing")

clusterConfigsDirParser :: Absolutizer -> O.Parser (DirOf "cluster-configs")
clusterConfigsDirParser (Absolutizer absOf) =
DirOf . absOf . absRel
<$> O.strOption
( O.long "cluster-configs"
<> O.metavar "LOCAL_CLUSTER_CONFIGS"
<> O.help "Path to the local cluster configuration directory"
)
47 changes: 47 additions & 0 deletions lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/CommandLine.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}

module Cardano.Wallet.Launch.Cluster.CommandLine
( CommandLineOptions (..)
, parseCommandLineOptions
, clusterConfigsDirParser
) where

import Prelude

import Cardano.Wallet.Launch.Cluster.FileOf
( Absolutizer (..)
, DirOf (..)
, newAbsolutizer
)
import Options.Applicative
( (<**>)
)
import System.Path
( absRel
)

import qualified Options.Applicative as O

newtype CommandLineOptions = CommandLineOptions
{clusterConfigsDir :: DirOf "cluster-configs"}
deriving stock (Show)

parseCommandLineOptions :: IO CommandLineOptions
parseCommandLineOptions = do
absolutizer <- newAbsolutizer
O.execParser
$ O.info
( fmap CommandLineOptions (clusterConfigsDirParser absolutizer)
<**> O.helper
)
(O.progDesc "Local Cluster for testing")

clusterConfigsDirParser :: Absolutizer -> O.Parser (DirOf "cluster-configs")
clusterConfigsDirParser (Absolutizer absOf) =
DirOf . absOf . absRel
<$> O.strOption
( O.long "cluster-configs"
<> O.metavar "LOCAL_CLUSTER_CONFIGS"
<> O.help "Path to the local cluster configuration directory"
)
16 changes: 14 additions & 2 deletions lib/local-cluster/local-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ library
Cardano.Wallet.Launch.Cluster.Cluster
Cardano.Wallet.Launch.Cluster.ClusterEra
Cardano.Wallet.Launch.Cluster.ClusterM
Cardano.Wallet.Launch.Cluster.CommandLine
Cardano.Wallet.Launch.Cluster.Config
Cardano.Wallet.Launch.Cluster.ConfiguredPool
Cardano.Wallet.Launch.Cluster.Env
Expand All @@ -73,7 +74,6 @@ library
Cardano.Wallet.Launch.Cluster.StakeCertificates
Cardano.Wallet.Launch.Cluster.Tx
Cardano.Wallet.Launch.Cluster.UnsafeInterval
Cardano.Wallet.LocalCluster

if flag(release)
ghc-options: -O2 -Werror
Expand Down Expand Up @@ -135,12 +135,24 @@ library

executable local-cluster
import: language, opts-exe
main-is: Cluster.hs
main-is: ./local-cluster.hs
hs-source-dirs: exe

build-depends:
, base
, cardano-addresses
, cardano-wallet-application-extras
, cardano-wallet-launcher
, cardano-wallet-primitive
, iohk-monitoring-extra
, lens
, local-cluster
, optparse-applicative
, pathtype
, resourcet
, temporary-extra
, unliftio
, with-utf8

test-suite local-cluster-test
import: language, opts-exe
Expand Down

0 comments on commit 0ed39a9

Please sign in to comment.