Skip to content

Commit

Permalink
add DaedalusIPC test (removed by previous rebase)
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Jun 17, 2019
1 parent 759eb6e commit ca24707
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions lib/http-bridge/test/integration/Cardano/LauncherSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import Prelude
import Cardano.Launcher
( Command (..), StdStream (..) )
import System.Directory
( doesDirectoryExist, doesFileExist, removePathForcibly )
( createDirectory, doesDirectoryExist, doesFileExist, removePathForcibly )
import System.Exit
( ExitCode (..) )
import System.Process
( createProcess, proc, waitForProcess )
import Test.Hspec
( Spec, after_, describe, it )
import Test.Hspec.Expectations.Lifted
( shouldBe )
( shouldBe, shouldReturn )
import Test.Integration.Framework.DSL
( expectCmdStarts )

Expand All @@ -28,25 +32,44 @@ spec = after_ tearDown $ do
d1 <- doesDirectoryExist stateDir
d1 `shouldBe` False

it "LAUNCH - Can start launcher against testnet with --state-dir" $ do
it "LAUNCH - Can start launcher with --state-dir" $ do
let cardanoWalletLauncher = Command "stack"
[ "exec", "--", "cardano-wallet", "launch"
, "--state-dir", stateDir
] (return ())
Inherit
expectCmdStarts cardanoWalletLauncher
expectStateDirExists stateDir

it "LAUNCH - Can start launcher with --state-dir <emptydir>" $ do
createDirectory stateDir
let cardanoWalletLauncher = Command "stack"
[ "exec", "--", "cardano-wallet", "launch"
, "--state-dir", stateDir
] (return ())
Inherit
expectCmdStarts cardanoWalletLauncher
expectStateDirExists stateDir

describe "DaedalusIPC" $ do
it "should reply with the port when asked" $ do
(_, _, _, ph) <-
createProcess (proc "test/integration/js/mock-daedalus.js" [])
waitForProcess ph `shouldReturn` ExitSuccess

d1 <- doesDirectoryExist stateDir
d2 <- doesDirectoryExist (stateDir ++ "/testnet")
w1 <- doesFileExist (stateDir ++ "/wallet.db")
w2 <- doesFileExist (stateDir ++ "/wallet.db-shm")
w3 <- doesFileExist (stateDir ++ "/wallet.db-wal")
d1 `shouldBe` True
d2 `shouldBe` True
w1 `shouldBe` True
w2 `shouldBe` True
w3 `shouldBe` True
where
stateDir = "./test/data/tmpStateDir"
tearDown = do
removePathForcibly stateDir

expectStateDirExists dir = do
d1 <- doesDirectoryExist dir
d2 <- doesDirectoryExist (dir ++ "/testnet")
w1 <- doesFileExist (dir ++ "/wallet.db")
w2 <- doesFileExist (dir ++ "/wallet.db-shm")
w3 <- doesFileExist (dir ++ "/wallet.db-wal")
d1 `shouldBe` True
d2 `shouldBe` True
w1 `shouldBe` True
w2 `shouldBe` True
w3 `shouldBe` True

0 comments on commit ca24707

Please sign in to comment.