Skip to content

Commit

Permalink
Merge pull request #1448 from input-output-hk/lc/denote-supported-net…
Browse files Browse the repository at this point in the history
…works

Denote supportedNetworks in hydra-cluster tests
  • Loading branch information
locallycompact committed May 24, 2024
2 parents 13e596f + 7306e69 commit affa123
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with open("hydra-cluster/test/Test/CardanoNodeSpec.hs", "r") as cardanoNodeSpecFile:
body = cardanoNodeSpecFile.read()
expectedCardanoNodeVersion = re.findall(r"getCardanoNodeVersion.*([0-9]+\.[0-9]+\.[0-9]+)", body)[0]
expectedCardanoNodeVersion = re.findall(r"supportedCardanoNodeVersion.*([0-9]+\.[0-9]+\.[0-9]+)", body)[0]
print("Checking used cardano-node version")
if all(v == expectedCardanoNodeVersion for v in usedCardanoNodeVersions):
Expand Down
23 changes: 19 additions & 4 deletions hydra-cluster/test/Test/CardanoNodeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,26 @@ import Hydra.Logging (Tracer, showLogsOnFailure)
import System.Directory (doesFileExist)
import Test.Hydra.Cluster.Utils (forEachKnownNetwork)

supportedNetworks :: [KnownNetwork]
supportedNetworks = [Preview, Preproduction, Mainnet]

supportedCardanoNodeVersion :: String
supportedCardanoNodeVersion = "8.9.0"

forSupportedKnownNetworks :: String -> (KnownNetwork -> IO ()) -> Spec
forSupportedKnownNetworks msg action = forEachKnownNetwork msg $ \network -> do
unless (network `elem` supportedNetworks) $
pendingWith $
"cardano-node " <> supportedCardanoNodeVersion <> " is only supported on " ++ show supportedNetworks
action network

spec :: Spec
spec = do
-- NOTE: We also hard-code the cardano-node version here to allow prevent
-- false positives test errors in case someone uses an "untested" /
-- different than in shell.nix version of cardano-node and cardano-cli.
it "has expected cardano-node version available" $
getCardanoNodeVersion >>= (`shouldContain` "8.9.0")
getCardanoNodeVersion >>= (`shouldContain` supportedCardanoNodeVersion)

around (failAfter 5 . setupTracerAndTempDir) $ do
it "withCardanoNodeDevnet does start a block-producing devnet within 5 seconds" $ \(tr, tmp) ->
Expand All @@ -41,16 +54,18 @@ spec = do

describe "findRunningCardanoNode" $ do
it "returns Nothing on non-matching network" $ \(tr, tmp) -> do
unless (Preview `elem` supportedNetworks) $
pendingWith "Preview is not supported so skipping this test."
withCardanoNodeOnKnownNetwork tr tmp Preview $ \_ -> do
findRunningCardanoNode tr tmp Preproduction `shouldReturn` Nothing

it "returns Just running node on matching network" $ \(tr, tmp) -> do
unless (Preview `elem` supportedNetworks) $
pendingWith "Preview is not supported so skipping this test."
withCardanoNodeOnKnownNetwork tr tmp Preview $ \runningNode -> do
findRunningCardanoNode tr tmp Preview `shouldReturn` Just runningNode

forEachKnownNetwork "withCardanoNodeOnKnownNetwork starts synchronizing within 10 seconds" $ \network -> do
when (network == Sanchonet) $
pendingWith "cardano-node 8.9 not anymore supported on sanchonet"
forSupportedKnownNetworks "withCardanoNodeOnKnownNetwork starts synchronizing within 10 seconds" $ \network -> do
-- NOTE: This implies that withCardanoNodeOnKnownNetwork does not
-- synchronize the whole chain before continuing.
setupTracerAndTempDir $ \(tr, tmp) ->
Expand Down

0 comments on commit affa123

Please sign in to comment.