git.iko.soy/distributed-process
on master help sign in
d-p-tests: Fix SpawnRace.

The transport is wrapped to drop some messages. But the transport was not made to fail and this sometimes caused the test to fail with no good reason.

commitdfff79f5843e705b785c2a10bae32e7ab77ff40c authorFacundo Domínguez <facundo.dominguez@tweag.io> dateWed 17 Aug 2016, 10:10 (10 years ago) parent5a5baf2
1 file changed+5−3
distributed-process-tests/src/Control/Distributed/Process/Tests/Closure.hs+5−3
distributed-process-tests/src/Control/Distributed/Process/Tests/Closure.hs+5−3
@@ -305,14 +305,16 @@ testSpawnRace TestTransport{..} rtable = do
305305 wrapEP e =
306306 e { NT.connect = \x y z -> do
307307 healthy <- newIORef True
308− fmap (fmap $ wrapConnection healthy) $ NT.connect e x y z
308+ fmap (fmap $ wrapConnection healthy e x) $ NT.connect e x y z
309309 }
310310
311− wrapConnection :: IORef Bool -> NT.Connection -> NT.Connection
312− wrapConnection healthy (NT.Connection s closeC) =
311+ wrapConnection :: IORef Bool -> NT.EndPoint -> NT.EndPointAddress
312+ -> NT.Connection -> NT.Connection
313+ wrapConnection healthy e remoteAddr (NT.Connection s closeC) =
313314 flip NT.Connection closeC $ \msg -> do
314315 when (msg == messageToPayload (createMessage ())) $ do
315316 writeIORef healthy False
317+ testBreakConnection (NT.address e) remoteAddr
316318 isHealthy <- readIORef healthy
317319 if isHealthy then s msg
318320 else return $ Left $ NT.TransportError NT.SendFailed ""