diff --git a/exe/wallet/Main.hs b/exe/wallet/Main.hs index bccc5853c04..43cda26b42b 100644 --- a/exe/wallet/Main.hs +++ b/exe/wallet/Main.hs @@ -334,7 +334,7 @@ execServer (Port port) (Port bridgePort) = do network `seq` return () -- Force evaluation of ENV[network] db <- MVar.newDBLayer nw <- HttpBridge.newNetworkLayer bridgePort - waitForConnection nw + waitForConnection nw 20 let tl = HttpBridge.newTransactionLayer wallet <- newWalletLayer @_ @HttpBridge db nw tl Server.start settings wallet diff --git a/lib/core/src/Cardano/Wallet/Network.hs b/lib/core/src/Cardano/Wallet/Network.hs index 634c894a1e9..b31cf7552e0 100644 --- a/lib/core/src/Cardano/Wallet/Network.hs +++ b/lib/core/src/Cardano/Wallet/Network.hs @@ -79,8 +79,9 @@ instance Exception ErrPostTx -- | Tries to waits 20 s, until 'networkTip networkLayer' succeeds. waitForConnection :: NetworkLayer IO + -> Int -- ^ Number of retries / timeout in seconds -> IO () -waitForConnection nw = loop 20 +waitForConnection nw = loop where loop :: Int -> IO () loop retries = runExceptT (networkTip nw) >>= \case diff --git a/lib/http-bridge/test/integration/Cardano/Wallet/HttpBridge/NetworkSpec.hs b/lib/http-bridge/test/integration/Cardano/Wallet/HttpBridge/NetworkSpec.hs index 21ed9ac21eb..4c13efc3a03 100644 --- a/lib/http-bridge/test/integration/Cardano/Wallet/HttpBridge/NetworkSpec.hs +++ b/lib/http-bridge/test/integration/Cardano/Wallet/HttpBridge/NetworkSpec.hs @@ -159,7 +159,7 @@ spec = do describe "waitForConnection" $ do it "times out after a short while" $ do nw <- newNetworkLayer - waitForConnection nw `shouldThrow` \case + waitForConnection nw 2 `shouldThrow` \case ErrNetworkTipNetworkUnreachable _ -> True _ -> False @@ -171,7 +171,7 @@ spec = do -- returns within (3s + 3s extra) res <- race (threadDelay 6000000) - (waitForConnection c ) + (waitForConnection c 20) res `shouldSatisfy` isRight cancel handle diff --git a/lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs b/lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs index acfc8581e44..ea8209a10a9 100644 --- a/lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs +++ b/lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs @@ -132,8 +132,9 @@ instance Exception ErrUnexpectedNetworkFailure -- "Cardano.Wallet.Network". waitForConnection :: Jormungandr IO + -> Int -- ^ Number of retries / timeout in seconds -> IO () -waitForConnection j = loop 20 +waitForConnection j = loop where loop :: Int -> IO () loop retries = runExceptT (getTipId j) >>= \case diff --git a/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/NetworkSpec.hs b/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/NetworkSpec.hs index 0858b538c67..8d939bb894c 100644 --- a/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/NetworkSpec.hs +++ b/lib/jormungandr/test/integration/Cardano/Wallet/Jormungandr/NetworkSpec.hs @@ -71,7 +71,7 @@ spec = do describe "waitForConnection" $ do it "times out after a short while" $ do c <- newClient - waitForConnection c `shouldThrow` \case + waitForConnection c 2 `shouldThrow` \case ErrNetworkUnreachable _ -> True it "returns when the network becomes availible" $ do @@ -82,7 +82,7 @@ spec = do -- returns within (3s + 3s extra) res <- race (threadDelay 6000000) - (waitForConnection c ) + (waitForConnection c 20) res `shouldSatisfy` isRight cancel handle @@ -98,7 +98,7 @@ spec = do startNode = do handle <- async $ launch $ return $ jormungandrWithSetup (return ()) client <- newClient - waitForConnection client + waitForConnection client 20 return (handle, client) closeNode (handle, _) = do