Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Move starting the testnet into a helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeinsky committed Sep 27, 2022
1 parent 2bfbdbc commit 0a3719b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions marconi/test/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,7 @@ testIndex :: Property
testIndex = H.integration . HE.runFinallies . HE.workspace "chairman" $ \tempAbsBasePath' -> do

base <- HE.noteM $ liftIO . IO.canonicalizePath =<< HE.getProjectBase

-- Start testnet
configurationTemplate <- H.noteShow $ base </> "configuration/defaults/byron-mainnet/configuration.yaml"
conf@TC.Conf { TC.tempBaseAbsPath, TC.tempAbsPath } <- HE.noteShowM $
TC.mkConf (TC.ProjectBase base) (TC.YamlFilePath configurationTemplate)
(tempAbsBasePath' <> "/")
Nothing
assert $ tempAbsPath == (tempAbsBasePath' <> "/")
&& tempAbsPath == (tempBaseAbsPath <> "/")
TN.TestnetRuntime { TN.bftSprockets, TN.testnetMagic } <- TN.testnet TN.defaultTestnetOptions conf
let networkId = C.Testnet $ C.NetworkMagic $ fromIntegral testnetMagic
socketPath <- IO.sprocketArgumentName <$> headM bftSprockets
socketPathAbs <- H.note =<< (liftIO $ IO.canonicalizePath $ tempAbsPath </> socketPath)
(socketPathAbs, networkId, tempAbsPath) <- startTestnet base tempAbsBasePath'

-- Create a channel that is passed into the indexer, such that it
-- can write index updates to it and we can await for them (also
Expand Down Expand Up @@ -319,6 +307,21 @@ testIndex = H.integration . HE.runFinallies . HE.workspace "chairman" $ \tempAbs

-- * Helpers

startTestnet :: FilePath -> FilePath -> H.Integration (String, C.NetworkId, FilePath)
startTestnet base tempAbsBasePath' = do
configurationTemplate <- H.noteShow $ base </> "configuration/defaults/byron-mainnet/configuration.yaml"
conf@TC.Conf { TC.tempBaseAbsPath, TC.tempAbsPath } <- HE.noteShowM $
TC.mkConf (TC.ProjectBase base) (TC.YamlFilePath configurationTemplate)
(tempAbsBasePath' <> "/")
Nothing
assert $ tempAbsPath == (tempAbsBasePath' <> "/")
&& tempAbsPath == (tempBaseAbsPath <> "/")
TN.TestnetRuntime { TN.bftSprockets, TN.testnetMagic } <- TN.testnet TN.defaultTestnetOptions conf
let networkId = C.Testnet $ C.NetworkMagic $ fromIntegral testnetMagic
socketPath <- IO.sprocketArgumentName <$> headM bftSprockets
socketPathAbs <- H.note =<< (liftIO $ IO.canonicalizePath $ tempAbsPath </> socketPath)
pure (socketPathAbs, networkId, tempAbsPath)

deriving instance Real C.Lovelace
deriving instance Integral C.Lovelace

Expand Down

0 comments on commit 0a3719b

Please sign in to comment.