From 4e781ff7975a2fe66e1327c2ed84a73d5ba3479b Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 20 Nov 2019 16:03:07 +0100 Subject: [PATCH 1/2] Remove obsolete test code about testing generated "jormungandr-config.yaml" --- .../test/data/jormungandr/config.yaml | 5 -- .../Cardano/Wallet/Jormungandr/Launch.hs | 71 ++----------------- 2 files changed, 4 insertions(+), 72 deletions(-) diff --git a/lib/jormungandr/test/data/jormungandr/config.yaml b/lib/jormungandr/test/data/jormungandr/config.yaml index 88e24291906..ba7f3c0e2b5 100644 --- a/lib/jormungandr/test/data/jormungandr/config.yaml +++ b/lib/jormungandr/test/data/jormungandr/config.yaml @@ -1,8 +1,3 @@ -storage: "/tmp/cardano-wallet-jormungandr/storage" - -rest: - listen: "127.0.0.1:8080" - p2p: trusted_peers: [] topics_of_interest: diff --git a/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/Launch.hs b/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/Launch.hs index 1a945b2ccf2..4082832c0b2 100644 --- a/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/Launch.hs +++ b/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/Launch.hs @@ -1,5 +1,4 @@ {-# LANGUAGE DataKinds #-} -{-# LANGUAGE QuasiQuotes #-} -- | -- Copyright: © 2018-2019 IOHK @@ -12,7 +11,6 @@ module Cardano.Wallet.Jormungandr.Launch ( withConfig , withBackendOnly , testDataDir - , spec ) where import Prelude @@ -23,32 +21,17 @@ import Cardano.Launcher ( StdStream (..) ) import Cardano.Wallet.Jormungandr.Network ( JormungandrConfig (..), JormungandrConnParams, withJormungandr ) -import Cardano.Wallet.Network.Ports - ( PortNumber, getRandomPort ) import Control.Exception ( bracket, throwIO ) -import Data.Aeson - ( Value (..), object, (.=) ) -import Data.Aeson.QQ - ( aesonQQ ) -import Data.Function - ( (&) ) import System.Directory ( doesDirectoryExist, removeDirectoryRecursive ) import System.Environment ( lookupEnv ) import System.FilePath - ( FilePath, () ) + ( () ) import System.IO ( IOMode (..), hClose, openFile ) import System.IO.Temp - ( createTempDirectory, getCanonicalTemporaryDirectory ) -import Test.Hspec - ( Spec, describe, it, shouldBe ) - -import qualified Data.Aeson as Aeson -import qualified Data.Text as T -import qualified Data.Yaml as Yaml testDataDir :: FilePath testDataDir = "test" "data" "jormungandr" @@ -69,8 +52,9 @@ setupConfig = do (Right $ testDataDir "block0.bin") Nothing (UseHandle logFile) - ["--secret", testDataDir "secret.yaml"] - genConfigYaml cfg + [ "--secret", testDataDir "secret.yaml" + , "--config" , testDataDir "config.yaml" + ] pure cfg teardownConfig :: JormungandrConfig -> IO () @@ -89,50 +73,3 @@ teardownConfig (JormungandrConfig d _ _ output _) = do withBackendOnly :: (JormungandrConnParams -> IO a) -> IO a withBackendOnly cb = withConfig $ \jmConfig -> do withJormungandr nullTracer jmConfig cb >>= either throwIO pure - -{------------------------------------------------------------------------------- - Generate YAML config file --------------------------------------------------------------------------------} - -spec :: Spec -spec = describe "genConfigFile integration tests helper" $ do - it "example configuration" $ do - let stateDir = "/state-dir" - genConfigFile stateDir 8081 `shouldBe` [aesonQQ|{ - "storage": "/state-dir/chain", - "p2p": { - "trusted_peers": [], - "topics_of_interest": { - "messages": "low", - "blocks": "normal" - }, - "public_address" : "/ip4/127.0.0.1/tcp/8081" - } - }|] - -genConfigYaml :: JormungandrConfig -> IO () -genConfigYaml (JormungandrConfig stateDir _ _ _ _) = do - p2pPort <- getRandomPort - genConfigFile stateDir p2pPort - & Yaml.encodeFile nodeConfigFile - where - nodeConfigFile = stateDir "jormungandr-config.yaml" - --- | Generate a configuration file for Jörmungandr@0.3.999 -genConfigFile - :: FilePath - -> PortNumber - -> Aeson.Value -genConfigFile stateDir addressPort = object - [ "storage" .= (stateDir "chain") - , "p2p" .= object - [ "trusted_peers" .= ([] :: [()]) - , "topics_of_interest" .= object - [ "messages" .= String "low" - , "blocks" .= String "normal" - ] - , "public_address" .= String publicAddress - ] - ] - where - publicAddress = T.pack $ mconcat ["/ip4/127.0.0.1/tcp/", show addressPort] From 80faee2ada18c292e655ac8e4b3966a082a45912 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 20 Nov 2019 16:03:15 +0100 Subject: [PATCH 2/2] fix hlint --- lib/core/test/unit/Cardano/Pool/MetricsSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/test/unit/Cardano/Pool/MetricsSpec.hs b/lib/core/test/unit/Cardano/Pool/MetricsSpec.hs index f09b3162ff2..04f2606428f 100644 --- a/lib/core/test/unit/Cardano/Pool/MetricsSpec.hs +++ b/lib/core/test/unit/Cardano/Pool/MetricsSpec.hs @@ -80,7 +80,7 @@ prop_combineDefaults prop_combineDefaults mStake = do combineMetrics mStake Map.empty Map.empty === - (Right $ Map.map (, Quantity 0, 0) mStake) + Right (Map.map (, Quantity 0, 0) mStake) -- | it fails if a block-producer or performance is not in the stake distr prop_combineIsLeftBiased