Skip to content

Commit

Permalink
Test to demonstrate non-matching network failures
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed May 23, 2024
1 parent fe34031 commit 4cf4a01
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions hydra-cluster/test/Test/CardanoNodeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ supportedNetworks = [Preview, Preproduction, Mainnet]
quickNetworks :: [KnownNetwork]
quickNetworks = [Sanchonet, Preview]

supportedQuickNetworks :: [KnownNetwork]
supportedQuickNetworks = filter (`elem` quickNetworks) supportedNetworks

supportedCardanoNodeVersion :: String
supportedCardanoNodeVersion = "8.9.0"

Expand All @@ -37,13 +34,6 @@ forSupportedKnownNetworks msg action = forEachKnownNetwork msg $ \network -> do
"cardano-node " <> supportedCardanoNodeVersion <> " is only supported on " ++ show supportedNetworks
action network

forASupportedQuickNetwork :: String -> (KnownNetwork -> IO ()) -> Spec
forASupportedQuickNetwork msg action =
it msg $
case supportedQuickNetworks of
(network : _) -> action network
_ -> pendingWith "No supported networks capable of running this test."

spec :: Spec
spec = do
-- NOTE: We also hard-code the cardano-node version here to allow prevent
Expand All @@ -67,12 +57,12 @@ spec = do
slot2 `shouldSatisfy` (> slot1)

describe "findRunningCardanoNode" $ do
forASupportedQuickNetwork "returns Nothing on non-matching network" $ \network -> do
forSupportedKnownNetworks "returns Nothing on non-matching network" $ \network -> do
setupTracerAndTempDir $ \(tr, tmp) ->
withCardanoNodeOnKnownNetwork tr tmp network $ \_ -> do
findRunningCardanoNode tr tmp Preproduction `shouldReturn` Nothing
findRunningCardanoNode tr tmp Sanchonet `shouldReturn` Nothing

forASupportedQuickNetwork "returns Just running node on matching network" $ \network -> do
forSupportedKnownNetworks "returns Just running node on matching network" $ \network -> do
setupTracerAndTempDir $ \(tr, tmp) ->
withCardanoNodeOnKnownNetwork tr tmp network $ \runningNode -> do
findRunningCardanoNode tr tmp network `shouldReturn` Just runningNode
Expand Down

0 comments on commit 4cf4a01

Please sign in to comment.