diff --git a/hydra-cluster/hydra-cluster.cabal b/hydra-cluster/hydra-cluster.cabal index 86dd597c8f0..087b6f84763 100644 --- a/hydra-cluster/hydra-cluster.cabal +++ b/hydra-cluster/hydra-cluster.cabal @@ -160,7 +160,7 @@ test-suite tests build-depends: , aeson , async - , base >=4.7 && <5 + , base >=4.7 && <5 , bytestring , containers , directory @@ -168,7 +168,7 @@ test-suite tests , hspec , hydra-cardano-api , hydra-cluster - , hydra-node + , hydra-node:{hydra-node, testlib} , hydra-prelude , hydra-test-utils , io-classes diff --git a/hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs b/hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs index 61bdbb17f35..d74ff6e76d9 100644 --- a/hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs +++ b/hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs @@ -11,6 +11,7 @@ import Data.Aeson.Lens (key, _String) import Data.Aeson.Types (parseEither) import Hydra.API.HTTPServer (DraftCommitTxResponse (DraftCommitTxResponse)) import Hydra.Cardano.Api (Tx) +import Hydra.JSONSchema (validateJSON, withJsonSpecifications) import Hydra.Ledger.Cardano.Configuration (pparamsFromJson) import Hydra.Logging (showLogsOnFailure) import System.Exit (ExitCode (..)) @@ -46,8 +47,14 @@ spec = Left e -> failure $ "Failed to decode JSON: " <> e <> "\n" <> show protocolParameters Right _ -> pure () - it "query protocol-parameters matches our schema" $ \_tracer -> - pendingWith "TODO" + it "query protocol-parameters matches our schema" $ \tracer -> + withJsonSpecifications $ \tmpDir -> + withCardanoNodeDevnet tracer tmpDir $ \RunningNode{nodeSocket, networkId} -> do + pparamsValue <- cliQueryProtocolParameters nodeSocket (networkId) + validateJSON + (tmpDir "api.json") + (key "components" . key "schemas" . key "ProtocolParameters") + pparamsValue where cardanoCliSign txFile = proc diff --git a/hydra-node/hydra-node.cabal b/hydra-node/hydra-node.cabal index e5cb1f12148..6e852db9a6d 100644 --- a/hydra-node/hydra-node.cabal +++ b/hydra-node/hydra-node.cabal @@ -176,6 +176,28 @@ library ghc-options: -haddock +library testlib + import: project-config + visibility: public + hs-source-dirs: testlib + exposed-modules: Hydra.JSONSchema + other-modules: Paths_hydra_node + build-depends: + , aeson + , base + , containers + , directory + , filepath + , hydra-prelude + , hydra-test-utils + , lens + , lens-aeson + , process + , QuickCheck + , text + , versions + , yaml + executable hydra-node import: project-config hs-source-dirs: exe/hydra-node @@ -274,7 +296,6 @@ test-suite tests Hydra.FireForgetSpec Hydra.HeadLogicSnapshotSpec Hydra.HeadLogicSpec - Hydra.JSONSchema Hydra.JSONSchemaSpec Hydra.Ledger.Cardano.TimeSpec Hydra.Ledger.CardanoSpec @@ -331,7 +352,7 @@ test-suite tests , hspec-wai , HUnit , hydra-cardano-api - , hydra-node + , hydra-node:{hydra-node, testlib} , hydra-plutus , hydra-plutus-extras , hydra-prelude @@ -342,7 +363,6 @@ test-suite tests , lens-aeson , plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} >=1.1.1.0 , plutus-tx - , process , QuickCheck , quickcheck-dynamic >=3.3.1 && <3.4 , quickcheck-instances @@ -354,10 +374,7 @@ test-suite tests , time , typed-protocols-examples >=0.1.0.0 , vector - , versions - , wai-extra , websockets - , yaml build-tool-depends: hspec-discover:hspec-discover ghc-options: -threaded -rtsopts diff --git a/hydra-node/test/Hydra/JSONSchema.hs b/hydra-node/testlib/Hydra/JSONSchema.hs similarity index 99% rename from hydra-node/test/Hydra/JSONSchema.hs rename to hydra-node/testlib/Hydra/JSONSchema.hs index c6ffe6d3f23..bde2904cf3b 100644 --- a/hydra-node/test/Hydra/JSONSchema.hs +++ b/hydra-node/testlib/Hydra/JSONSchema.hs @@ -77,8 +77,7 @@ validateJSON schemaFilePath selector value = do when (exitCode /= ExitSuccess) $ failure . toString $ unlines - [ "check-jsonschema failed on " <> toText jsonInput <> " with schema " <> toText jsonSchema <> " on input:" - , decodeUtf8 $ encodePretty value + [ "check-jsonschema failed on " <> toText jsonInput <> " with schema " <> toText jsonSchema , toText err <> toText out ] where