@@ -74,14 +74,14 @@ output tag pairs = object $ ("tag" .= tag) : pairs
74
74
-- | Wait some time for a single API server output from each of given nodes.
75
75
-- This function waits for @delay@ seconds for message @expected@ to be seen by all
76
76
-- given @nodes@.
77
- waitFor :: HasCallStack => Tracer IO HydraNodeLog -> DiffTime -> [HydraClient ] -> Aeson. Value -> IO ()
77
+ waitFor :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient ] -> Aeson. Value -> IO ()
78
78
waitFor tracer delay nodes v = waitForAll tracer delay nodes [v]
79
79
80
80
-- | Wait up to some time for an API server output to match the given predicate.
81
- waitMatch :: HasCallStack => DiffTime -> HydraClient -> (Aeson. Value -> Maybe a ) -> IO a
81
+ waitMatch :: HasCallStack => NominalDiffTime -> HydraClient -> (Aeson. Value -> Maybe a ) -> IO a
82
82
waitMatch delay client@ HydraClient {tracer, hydraNodeId} match = do
83
83
seenMsgs <- newTVarIO []
84
- timeout delay (go seenMsgs) >>= \ case
84
+ timeout ( realToFrac delay) (go seenMsgs) >>= \ case
85
85
Just x -> pure x
86
86
Nothing -> do
87
87
msgs <- readTVarIO seenMsgs
@@ -106,7 +106,7 @@ waitMatch delay client@HydraClient{tracer, hydraNodeId} match = do
106
106
-- | Wait up to some `delay` for some JSON `Value` to match given function.
107
107
--
108
108
-- This is a generalisation of `waitMatch` to multiple nodes.
109
- waitForAllMatch :: (Eq a , Show a , HasCallStack ) => DiffTime -> [HydraClient ] -> (Aeson. Value -> Maybe a ) -> IO a
109
+ waitForAllMatch :: (Eq a , Show a , HasCallStack ) => NominalDiffTime -> [HydraClient ] -> (Aeson. Value -> Maybe a ) -> IO a
110
110
waitForAllMatch delay nodes match = do
111
111
when (null nodes) $
112
112
failure " no clients to wait for"
@@ -122,13 +122,12 @@ waitForAllMatch delay nodes match = do
122
122
-- | Wait some time for a list of outputs from each of given nodes.
123
123
-- This function is the generalised version of 'waitFor', allowing several messages
124
124
-- to be waited for and received in /any order/.
125
- waitForAll :: HasCallStack => Tracer IO HydraNodeLog -> DiffTime -> [HydraClient ] -> [Aeson. Value ] -> IO ()
125
+ waitForAll :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient ] -> [Aeson. Value ] -> IO ()
126
126
waitForAll tracer delay nodes expected = do
127
127
traceWith tracer (StartWaiting (map hydraNodeId nodes) expected)
128
128
forConcurrently_ nodes $ \ client@ HydraClient {hydraNodeId} -> do
129
129
msgs <- newIORef []
130
- -- The chain is slow...
131
- result <- timeout delay $ tryNext client msgs expected
130
+ result <- timeout (realToFrac delay) $ tryNext client msgs expected
132
131
case result of
133
132
Just x -> pure x
134
133
Nothing -> do
@@ -393,13 +392,13 @@ withConnectionToNode tracer hydraNodeId action = do
393
392
hydraNodeProcess :: RunOptions -> CreateProcess
394
393
hydraNodeProcess = proc " hydra-node" . toArgs
395
394
396
- waitForNodesConnected :: HasCallStack => Tracer IO HydraNodeLog -> DiffTime -> [HydraClient ] -> IO ()
397
- waitForNodesConnected tracer timeOut clients =
395
+ waitForNodesConnected :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient ] -> IO ()
396
+ waitForNodesConnected tracer delay clients =
398
397
mapM_ waitForNodeConnected clients
399
398
where
400
399
allNodeIds = hydraNodeId <$> clients
401
400
waitForNodeConnected n@ HydraClient {hydraNodeId} =
402
- waitForAll tracer timeOut [n] $
401
+ waitForAll tracer delay [n] $
403
402
fmap
404
403
( \ nodeId ->
405
404
object
0 commit comments