+
-- | Like 'withTempDir', busing a common prefix to keep hydra-cluster logs more
+
-- NOTE: The ci.yaml workflow depends on this.
+
withClusterTempDir :: MonadIO m => String -> (FilePath -> m a) -> m a
+
withClusterTempDir name =
+
withTempDir ("hydra-cluster-e2e-" <> name)
spec = around showLogsOnFailure $ do
describe "End-to-end on Cardano devnet" $ do
describe "single party hydra head" $ do
it "full head life-cycle" $ \tracer -> do
-
withTempDir "hydra-cluster-end-to-end" $ \tmpDir -> do
+
withClusterTempDir "single-full-life-cycle" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node ->
publishHydraScriptsAs node Faucet
>>= singlePartyHeadFullLifeCycle tracer tmpDir node
it "can close with long deadline" $ \tracer -> do
-
withTempDir "hydra-cluster-end-to-end" $ \tmpDir -> do
+
withClusterTempDir "close-long-deadline" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node ->
publishHydraScriptsAs node Faucet
>>= canCloseWithLongContestationPeriod tracer tmpDir node
describe "three hydra nodes scenario" $ do
it "inits a Head, processes a single Cardano transaction and closes it again" $ \tracer ->
-
withTempDir "end-to-end-cardano-node" $ \tmpDir -> do
+
withClusterTempDir "three-full-life-cycle" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
initAndClose tracer 1 hydraScriptsTxId node
it "inits a Head and closes it immediately " $ \tracer ->
-
withTempDir "end-to-end-cardano-node" $ \tmpDir -> do
+
withClusterTempDir "three-init-close-immediately" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \[email protected]{nodeSocket} -> do
aliceKeys@(aliceCardanoVk, _) <- generate genKeyPair
describe "restarting nodes" $ do
it "can abort head after restart" $ \tracer -> do
-
withTempDir "hydra-cluster-end-to-end" $ \tmpDir -> do
+
withClusterTempDir "abort-after-restart" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node ->
publishHydraScriptsAs node Faucet
>>= restartedNodeCanAbort tracer tmpDir node
it "can observe a commit tx after a restart, even when a tx happened while down" $ \tracer -> do
-
withTempDir "hydra-cluster-end-to-end" $ \tmpDir -> do
+
withClusterTempDir "commit-after-restart" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node ->
publishHydraScriptsAs node Faucet
>>= restartedNodeCanObserveCommitTx tracer tmpDir node
it "can start chain from the past and replay on-chain events" $ \tracer ->
-
withTempDir "end-to-end-chain-observer" $ \tmp ->
+
withClusterTempDir "replay-chain-events" $ \tmp ->
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmp $ \[email protected]{nodeSocket, networkId} -> do
(aliceCardanoVk, _aliceCardanoSk) <- keysFor Alice
let contestationPeriod = UnsafeContestationPeriod 10
headId' `shouldBe` aliceHeadId
it "close of an initial snapshot from re-initialized node is contested" $ \tracer ->
-
withTempDir "end-to-end-chain-observer" $ \tmp ->
+
withClusterTempDir "contest-after-restart" $ \tmp ->
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmp $ \[email protected]{nodeSocket, networkId} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
describe "two hydra heads scenario" $ do
it "two heads on the same network do not conflict" $ \tracer ->
-
withTempDir "end-to-end-cardano-node" $ \tmpDir -> do
+
withClusterTempDir "two-heads-no-conflict" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
it "bob cannot abort alice's head" $ \tracer -> do
-
withTempDir "end-to-end-two-heads" $ \tmpDir -> do
+
withClusterTempDir "two-heads-cant-abort" $ \tmpDir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \[email protected]{nodeSocket} -> do
(aliceCardanoVk, _aliceCardanoSk) <- keysFor Alice
(bobCardanoVk, _bobCardanoSk) <- keysFor Bob
describe "Monitoring" $ do
it "Node exposes Prometheus metrics on port 6001" $ \tracer -> do
-
withTempDir "end-to-end-prometheus-metrics" $ \tmpDir -> do
+
withClusterTempDir "prometheus-metrics" $ \tmpDir -> do
(aliceCardanoVk, _) <- keysFor Alice
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \[email protected]{nodeSocket} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
version `shouldSatisfy` (=~ ("[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9]+)?" :: String))
it "logs its command line arguments" $ \tracer -> do
-
withTempDir "temp-dir-to-check-hydra-logs" $ \dir -> do
+
withClusterTempDir "logs-options" $ \dir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) dir $ \RunningNode{nodeSocket} -> do
let hydraSK = dir </> "hydra.sk"
let cardanoSK = dir </> "cardano.sk"
hydraSKey :: SigningKey HydraKey <- generate arbitrary
(_, cardanoSKey) <- generateCardanoKey
void $ writeFileTextEnvelope hydraSK Nothing hydraSKey
void $ writeFileTextEnvelope cardanoSK Nothing cardanoSKey
-
withCreateProcess (proc "hydra-node" ["-n", "hydra-node-1", "--testnet-magic", "42", "--hydra-signing-key", hydraSK,"--cardano-signing-key", cardanoSK, "--node-socket", nodeSocket]){std_out = CreatePipe} $
+
withCreateProcess (proc "hydra-node" ["-n", "hydra-node-1", "--testnet-magic", "42", "--hydra-signing-key", hydraSK, "--cardano-signing-key", cardanoSK, "--node-socket", nodeSocket]){std_out = CreatePipe} $
\_ (Just nodeStdout) _ _ ->
waitForLog 10 nodeStdout "JSON object with key NodeOptions" $ \line ->
line ^? key "message" . key "tag" == Just (Aeson.String "NodeOptions")
it "detects misconfiguration" $ \tracer -> do
-
withTempDir "temp-dir-to-check-hydra-misconfiguration" $ \dir -> do
+
withClusterTempDir "detect-misconfiguration" $ \dir -> do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) dir $ \[email protected]{nodeSocket} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
let persistenceDir = dir </> "persistence"
initAndClose :: Tracer IO EndToEndLog -> Int -> TxId -> RunningNode -> IO ()
initAndClose tracer clusterIx hydraScriptsTxId [email protected]{nodeSocket, networkId} = do
-
withTempDir "end-to-end-init-and-close" $ \tmpDir -> do
+
withClusterTempDir "init-and-close" $ \tmpDir -> do
aliceKeys@(aliceCardanoVk, aliceCardanoSk) <- generate genKeyPair
bobKeys@(bobCardanoVk, _) <- generate genKeyPair
carolKeys@(carolCardanoVk, _) <- generate genKeyPair