From 928e7066b17ed1587ec6e4a27efe0b31b8b288e8 Mon Sep 17 00:00:00 2001 From: Franco Testagrossa Date: Fri, 12 Jan 2024 10:05:09 +0100 Subject: [PATCH] Enhance e2e spec over api --- hydra-cluster/test/Test/HydraExplorerSpec.hs | 7 +++---- hydra-explorer/src/Hydra/Explorer.hs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hydra-cluster/test/Test/HydraExplorerSpec.hs b/hydra-cluster/test/Test/HydraExplorerSpec.hs index ca62f18b7d7..7ab1f8467f6 100644 --- a/hydra-cluster/test/Test/HydraExplorerSpec.hs +++ b/hydra-cluster/test/Test/HydraExplorerSpec.hs @@ -10,7 +10,7 @@ import Hydra.Prelude hiding (get) import Test.Hydra.Prelude import CardanoClient (NodeLog, RunningNode (..), submitTx) -import CardanoNode (withCardanoNodeDevnet) +import CardanoNode (unsafeDecodeJson, withCardanoNodeDevnet) import Control.Concurrent.Class.MonadSTM (modifyTVar', newTVarIO, readTVarIO) import Control.Exception (IOException) import Control.Lens ((^?)) @@ -22,7 +22,6 @@ import Hydra.Cardano.Api (NetworkId (..), NetworkMagic (..), unFile) import Hydra.Cluster.Faucet (FaucetLog, publishHydraScriptsAs, seedFromFaucet_) import Hydra.Cluster.Fixture (Actor (..), aliceSk, bobSk, cperiod) import Hydra.Cluster.Util (chainConfigFor, keysFor) -import Hydra.HeadId (HeadId (..)) import Hydra.Logging (showLogsOnFailure) import HydraNode (HydraNodeLog, input, output, requestCommitTx, send, waitFor, waitMatch, withHydraNode) import Network.HTTP.Client qualified as HTTPClient @@ -132,8 +131,8 @@ spec = do response <- HTTPClient.httpLbs request manager HTTPClient.responseStatus response `shouldBe` status200 print (HTTPClient.responseBody response) - let maybeOpenHeads = decode $ HTTPClient.responseBody response :: Maybe [HeadId] - maybeOpenHeads `shouldBe` Just [UnsafeHeadId $ encodeUtf8 headId] + allHeads <- unsafeDecodeJson . toStrict $ HTTPClient.responseBody response + allHeads `shouldBe` [headId] headExplorerSees :: HasCallStack => HydraExplorerHandle -> Value -> Text -> IO () headExplorerSees explorer txType headId = diff --git a/hydra-explorer/src/Hydra/Explorer.hs b/hydra-explorer/src/Hydra/Explorer.hs index 81d3742f25b..f46dafd2575 100644 --- a/hydra-explorer/src/Hydra/Explorer.hs +++ b/hydra-explorer/src/Hydra/Explorer.hs @@ -71,7 +71,7 @@ httpApp tracer explorerState req send = do case (requestMethod req, pathInfo req) of ("HEAD", _) -> send $ responseLBS status200 corsHeaders "" ("GET", []) -> send $ handleFile "index.html" - ("GET", ["heads"]) -> send $ responseLBS status200 corsHeaders "OK" + ("GET", ["heads"]) -> send $ responseLBS status200 corsHeaders "[]" -- FIXME: do proper file serving, this is dangerous ("GET", path) -> send $ handleFile $ toString $ mconcat $ List.intersperse "/" ("." : path) (_, _) -> send handleNotFound