Skip to content

Commit

Permalink
Update E2E to provide the socket path to the cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 9, 2024
1 parent f68bf91 commit 65c1da1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions lib/wallet-e2e/cardano-wallet-e2e.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ library
, cardano-wallet-primitive
, effectful-core ^>=2.2.2.0
, effectful-th ^>=1.0.0.1
, extra
, faucet
, http-client ^>=0.7.13.1
, http-types ^>=0.12.3
Expand Down
38 changes: 23 additions & 15 deletions lib/wallet-e2e/src/Cardano/Wallet/Spec/Network/Local.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import Control.Monad.Trans.Resource
import System.IO
( openFile
)
import System.IO.Extra
( newTempFile
)
import System.Path
( relFile
, (</>)
Expand Down Expand Up @@ -48,23 +51,28 @@ configuredNetwork (DirOf stateDir) (DirOf clusterConfigsDir) = do
pure ConfiguredNetwork{configuredNetworkWallet = walletApi, ..}
where
startCluster :: ResourceT IO WalletApi = do
(_clusterReleaseKey, _clusterProcess) <-
allocate startLocalClusterProcess stopProcess
pure WalletApi
{ walletInstanceApiUrl = "http://localhost:8090/v2"
, walletInstanceApiHost = "localhost"
, walletInstanceApiPort = 8090
}
(_, (socketFile, _)) <- allocate newTempFile snd
(_clusterReleaseKey, _clusterProcess) <-
allocate (startLocalClusterProcess socketFile) stopProcess
pure
WalletApi
{ walletInstanceApiUrl = "http://localhost:8090/v2"
, walletInstanceApiHost = "localhost"
, walletInstanceApiPort = 8090
}

startLocalClusterProcess :: IO (Process () () ())
startLocalClusterProcess = do
startLocalClusterProcess :: FilePath -> IO (Process () () ())
startLocalClusterProcess socketPath = do
let clusterLog = stateDir </> relFile "cluster.log"
handle <- openFile (toFilePath clusterLog) AppendMode
putStrLn $ "Writing cluster logs to " <> toFilePath clusterLog
startProcess
$ setStderr (useHandleClose handle)
$ setStdout (useHandleClose handle)
$ proc "local-cluster"
[ "--cluster-configs"
, toFilePath clusterConfigsDir
]
$ setStderr (useHandleClose handle)
$ setStdout (useHandleClose handle)
$ proc
"local-cluster"
[ "--cluster-configs"
, toFilePath clusterConfigsDir
, "--socket-path"
, socketPath
]

0 comments on commit 65c1da1

Please sign in to comment.