Skip to content

Commit

Permalink
Propagate removal of base record through cardano-testnet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed May 31, 2023
1 parent 880aee1 commit b76c3f8
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cardano-testnet/src/Cardano/Testnet.hs
Expand Up @@ -38,7 +38,7 @@ module Cardano.Testnet (

import Testnet
import Testnet.Cardano
import Testnet.Conf hiding (base)
import Testnet.Conf
import Testnet.Options
import Testnet.Shelley as Shelley
import Testnet.Utils (waitUntilEpoch)
Expand Down
7 changes: 2 additions & 5 deletions cardano-testnet/src/Testnet/Run.hs
Expand Up @@ -11,18 +11,15 @@ import qualified Control.Concurrent as IO
import qualified Control.Concurrent.STM as STM
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified System.Console.ANSI as ANSI
import qualified System.Directory as IO
import qualified System.Exit as IO
import qualified System.IO as IO
import qualified Testnet.Conf as H
import qualified Testnet.Util.Base as H

testnetProperty :: Maybe Int -> (H.Conf -> H.Integration ()) -> H.Property
testnetProperty maybeTestnetMagic tn = H.integrationRetryWorkspace 2 "testnet" $ \tempAbsPath' -> do
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
conf <- H.mkConf (H.ProjectBase base) Nothing tempAbsPath' maybeTestnetMagic
testnetProperty maybeTestnetMagic tn = H.integrationRetryWorkspace 2 "testnet" $ \workspaceDir -> do
conf <- H.mkConf Nothing workspaceDir maybeTestnetMagic

-- Fork a thread to keep alive indefinitely any resources allocated by testnet.
void . H.evalM . liftResourceT . resourceForkIO . forever . liftIO $ IO.threadDelay 10000000
Expand Down
Expand Up @@ -31,9 +31,7 @@ import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Concurrent as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Process as H
import Prelude
import qualified System.Directory as IO
import System.FilePath ((</>))
import qualified System.Info as SYS
import qualified Testnet.Util.Process as H
Expand All @@ -53,9 +51,8 @@ import Testnet.Util.Runtime
hprop_leadershipSchedule :: Property
hprop_leadershipSchedule = integrationRetryWorkspace 2 "alonzo-leadership-schedule" $ \tempAbsBasePath' -> do
H.note_ SYS.os
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
conf@Conf { tempBaseAbsPath, tempAbsPath } <- H.noteShowM $
mkConf (ProjectBase base) Nothing tempAbsBasePath' Nothing
mkConf Nothing tempAbsBasePath' Nothing
let
fastTestnetOptions = CardanoOnlyTestnetOptions cardanoDefaultTestnetOptions
{ cardanoEpochLength = 500
Expand All @@ -73,7 +70,6 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "alonzo-leadership-schedu
execConfig <- H.headM (bftSprockets tr) >>= H.mkExecConfig tempBaseAbsPath

-- First we note all the relevant files
H.note_ base
work <- H.note tempAbsPath

-- We get our UTxOs from here
Expand Down
Expand Up @@ -32,8 +32,6 @@ import qualified Data.Time.Clock as DTC
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified System.Directory as IO
import qualified System.Info as SYS
import qualified Testnet.Util.Base as H

Expand All @@ -46,9 +44,8 @@ import Testnet.Util.Runtime
hprop_leadershipSchedule :: Property
hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-schedule" $ \tempAbsBasePath' -> do
H.note_ SYS.os
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
conf@Conf { tempBaseAbsPath, tempAbsPath } <- H.noteShowM $
mkConf (ProjectBase base) Nothing tempAbsBasePath' Nothing
mkConf Nothing tempAbsBasePath' Nothing

work <- H.createDirectoryIfMissing $ tempAbsPath </> "work"

Expand Down
Expand Up @@ -25,7 +25,6 @@ import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Time.Clock as DTC
import GHC.Stack (callStack)
import qualified System.Directory as IO
import System.FilePath ((</>))
import qualified System.Info as SYS

Expand All @@ -36,7 +35,6 @@ import Hedgehog (Property, (===))
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified Testnet.Util.Base as H
import qualified Testnet.Util.Process as H
import Testnet.Util.Process
Expand All @@ -45,9 +43,8 @@ import Testnet.Util.Runtime
hprop_stakeSnapshot :: Property
hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \tempAbsBasePath' -> do
H.note_ SYS.os
base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
conf@Conf { tempBaseAbsPath, tempAbsPath } <- H.noteShowM $
mkConf (ProjectBase base) Nothing tempAbsBasePath' Nothing
mkConf Nothing tempAbsBasePath' Nothing

work <- H.createDirectoryIfMissing $ tempAbsPath </> "work"

Expand Down
Expand Up @@ -27,8 +27,6 @@ import qualified Data.Text as T
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified System.Directory as IO
import qualified System.Info as SYS
import qualified Testnet.Util.Base as H
import qualified Testnet.Util.Process as H
Expand All @@ -41,11 +39,9 @@ import Testnet.Util.Runtime
hprop_kes_period_info :: Property
hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempAbsBasePath' -> do
H.note_ SYS.os
base <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase
conf@Conf { tempBaseAbsPath, tempAbsPath }
-- TODO: Move yaml filepath specification into individual node options
<- H.noteShowM $ mkConf (ProjectBase base) Nothing
tempAbsBasePath' Nothing
<- H.noteShowM $ mkConf Nothing tempAbsBasePath' Nothing

let fastTestnetOptions = CardanoOnlyTestnetOptions $ cardanoDefaultTestnetOptions
{ cardanoNodes = cardanoDefaultTestnetNodeOptions
Expand Down
6 changes: 1 addition & 5 deletions cardano-testnet/test/cardano-testnet-test/Test/FoldBlocks.hs
Expand Up @@ -37,11 +37,7 @@ prop_foldBlocks :: H.Property
prop_foldBlocks = H.integrationRetryWorkspace 2 "foldblocks" $ \tempAbsBasePath' -> do

-- Start testnet
base <- HE.noteM $ H.evalIO . IO.canonicalizePath =<< HE.getProjectBase
conf <- HE.noteShowM $
TN.mkConf (TN.ProjectBase base) Nothing
(tempAbsBasePath' <> "/")
Nothing
conf <- HE.noteShowM $ TN.mkConf Nothing (tempAbsBasePath' <> "/") Nothing

let options = CardanoOnlyTestnetOptions $ cardanoDefaultTestnetOptions
-- NB! The `activeSlotsCoeff` value is very important for
Expand Down
Expand Up @@ -17,7 +17,6 @@ import Data.Either (isRight)
import Data.Maybe
import GHC.IO.Exception (ExitCode (ExitSuccess))
import GHC.Stack (callStack)
import qualified System.Directory as IO

import Hedgehog (Property, (===))
import qualified Hedgehog as H
Expand All @@ -31,10 +30,9 @@ import Testnet.Util.Runtime (TestnetRuntime (..))
hprop_shutdownOnSlotSynced :: Property
hprop_shutdownOnSlotSynced = H.integrationRetryWorkspace 2 "shutdown-on-slot-synced" $ \tempAbsBasePath' -> do
-- Start a local test net
baseDir <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase
conf <- H.noteShowM $
-- TODO: Move yaml filepath specification into individual node options
mkConf (ProjectBase baseDir) Nothing tempAbsBasePath' Nothing
-- TODO: Move yaml filepath specification into individual node options
conf <- H.noteShowM $ mkConf Nothing tempAbsBasePath' Nothing

let maxSlot = 1500
slotLen = 0.01
let fastTestnetOptions = CardanoOnlyTestnetOptions $ cardanoDefaultTestnetOptions
Expand Down

0 comments on commit b76c3f8

Please sign in to comment.