Skip to content
Permalink
Browse files

Add missing DaedalusIPC tests for the 'serve' command

  • Loading branch information...
KtorZ committed Jul 11, 2019
1 parent 5ed2151 commit 9b923f65e8341aae97b534c04966a10e0b4d478b
@@ -11,14 +11,23 @@ import Prelude

import Control.Concurrent
( threadDelay )
import Control.Monad
( forM_ )
import System.Exit
( ExitCode (..) )
import System.IO.Temp
( withSystemTempDirectory )
import System.Process
( terminateProcess, withCreateProcess )
( createProcess
, proc
, terminateProcess
, waitForProcess
, withCreateProcess
)
import Test.Hspec
( Spec, SpecWith, describe, it )
import Test.Hspec.Expectations.Lifted
( shouldBe )
( shouldBe, shouldReturn )
import Test.Integration.Framework.DSL
( Context (..)
, KnownCommand (..)
@@ -44,6 +53,20 @@ spec = do
terminateProcess ph
threadDelay oneSecond

describe "DaedalusIPC" $ do
let defaultArgs =
[ commandName @t , "serve" ]
let tests =
[ defaultArgs ++ ["--random-port"]
, defaultArgs ++ ["--port", "8082"]
]
forM_ tests $ \args -> do
let title = "should reply with the port when asked " <> show args
it title $ \_ -> do
let filepath = "test/integration/js/mock-daedalus.js"
(_, _, _, ph) <- createProcess (proc filepath args)
waitForProcess ph `shouldReturn` ExitSuccess

describe "LOGGING - cardano-wallet serve logging" $ do
it "LOGGING - Launch can log --verbose" $ \_ -> do
let args = ["serve", "--random-port", "--verbose"]
@@ -11,14 +11,23 @@ import Prelude

import Control.Concurrent
( threadDelay )
import Control.Monad
( forM_ )
import System.Exit
( ExitCode (..) )
import System.IO.Temp
( withSystemTempDirectory )
import System.Process
( terminateProcess, withCreateProcess )
( createProcess
, proc
, terminateProcess
, waitForProcess
, withCreateProcess
)
import Test.Hspec
( Spec, SpecWith, describe, it )
import Test.Hspec.Expectations.Lifted
( shouldBe )
( shouldBe, shouldReturn )
import Test.Integration.Framework.DSL
( Context (..)
, KnownCommand (..)
@@ -33,30 +42,42 @@ import Test.Integration.Framework.TestData

spec :: forall t. KnownCommand t => SpecWith (Context t)
spec = do
let block0H =
"dba597bee5f0987efbf56f6bd7f44c38158a7770d0cb28a26b5eca40613a7ebd"
describe "SERVER - cardano-wallet serve" $ do
it "SERVER - Can start cardano-wallet serve --database" $ \_ -> do
withTempDir $ \d -> do
let db = d ++ "/db-file"
let args =
[ "serve", "--database", db, "--genesis-hash"
, "dba597bee5f0987efbf56f6bd7f44c38\
\158a7770d0cb28a26b5eca40613a7ebd"
]
[ "serve", "--database", db, "--genesis-hash", block0H ]
let process = proc' (commandName @t) args
withCreateProcess process $ \_ _ _ ph -> do
expectPathEventuallyExist db
terminateProcess ph
threadDelay oneSecond

describe "DaedalusIPC" $ do
let defaultArgs =
[ commandName @t , "serve" , "--genesis-hash", block0H ]
let tests =
[ defaultArgs ++ ["--random-port"]
, defaultArgs ++ ["--port", "8082"]
]
forM_ tests $ \args -> do
let title = "should reply with the port when asked " <> show args
it title $ \_ -> do
let filepath = "test/integration/js/mock-daedalus.js"
(_, _, _, ph) <- createProcess (proc filepath args)
waitForProcess ph `shouldReturn` ExitSuccess

describe "LOGGING - cardano-wallet serve logging" $ do
it "LOGGING - Launch can log --verbose" $ \_ -> do
let args =
["serve"
, "--random-port"
, "--verbose"
, "--genesis-hash"
, "dba597bee5f0987efbf56f6bd7f44c38\
\158a7770d0cb28a26b5eca40613a7ebd"
, block0H
]
let process = proc' (commandName @t) args
(out, _) <- collectStreams (20, 0) process
@@ -71,8 +92,7 @@ spec = do
, "--random-port"
, "--quiet"
, "--genesis-hash"
, "dba597bee5f0987efbf56f6bd7f44c38\
\158a7770d0cb28a26b5eca40613a7ebd"
, block0H
]
let process = proc' (commandName @t) args
(out, err) <- collectStreams (10, 10) process
@@ -84,8 +104,7 @@ spec = do
["serve"
, "--random-port"
, "--genesis-hash"
, "dba597bee5f0987efbf56f6bd7f44c38\
\158a7770d0cb28a26b5eca40613a7ebd"
, block0H
]
let process = proc' (commandName @t) args
(out, _) <- collectStreams (5, 0) process

0 comments on commit 9b923f6

Please sign in to comment.
You can’t perform that action at this time.