@@ -374,7 +374,7 @@ testParallelConnects transport numPings = do
374374
375375-- | Test that sending on a closed connection gives an error
376376testSendAfterClose :: Transport -> Int -> IO ()
377−testSendAfterClose transport _ = do
377+testSendAfterClose transport numRepeats = do
378378 server <- spawn transport echoServer
379379 clientDone <- newEmptyMVar
380380
@@ -382,19 +382,22 @@ testSendAfterClose transport _ = do
382382 Right endpoint <- newEndPoint transport
383383
384384 -- We request two lightweight connections
385− Right conn1 <- connect endpoint server ReliableOrdered
386− Right conn2 <- connect endpoint server ReliableOrdered
387−
388− -- Close the second, but leave the first open; then output on the second
389− -- connection (i.e., on a closed connection while there is still another
390− -- connection open)
391− close conn2
392− Left (TransportError SendFailed _) <- send conn2 ["ping2"]
385+ replicateM numRepeats $ do
386+ Right conn1 <- connect endpoint server ReliableOrdered
387+ Right conn2 <- connect endpoint server ReliableOrdered
388+
389+ -- Close the second, but leave the first open; then output on the second
390+ -- connection (i.e., on a closed connection while there is still another
391+ -- connection open)
392+ close conn2
393+ Left (TransportError SendFailed _) <- send conn2 ["ping2"]
394+
395+ -- Now close the first connection, and output on it (i.e., output while
396+ -- there are no lightweight connection at all anymore)
397+ close conn1
398+ Left (TransportError SendFailed _) <- send conn2 ["ping2"]
393399
394− -- Now close the first connection, and output on it (i.e., output while
395− -- there are no lightweight connection at all anymore)
396− close conn1
397− Left (TransportError SendFailed _) <- send conn2 ["ping2"]
400+ return ()
398401
399402 putMVar clientDone ()
400403
@@ -402,32 +405,35 @@ testSendAfterClose transport _ = do
402405
403406-- | Test that closing the same connection twice has no effect
404407testCloseTwice :: Transport -> Int -> IO ()
405−testCloseTwice transport _ = do
408+testCloseTwice transport numRepeats = do
406409 server <- spawn transport echoServer
407410 clientDone <- newEmptyMVar
408411
409412 forkTry $ do
410413 Right endpoint <- newEndPoint transport
411414
412− -- We request two lightweight connections
413− Right conn1 <- connect endpoint server ReliableOrdered
414− Right conn2 <- connect endpoint server ReliableOrdered
415−
416− -- Close the second one twice
417− close conn2
418− close conn2
419−
420− -- Then send a message on the first and close that too
421− send conn1 ["ping"]
422− close conn1
423−
424− -- Verify expected response from the echo server
425− ConnectionOpened cid1 _ _ <- receive endpoint
426− ConnectionOpened cid2 _ _ <- receive endpoint
427− ConnectionClosed cid2' <- receive endpoint ; True <- return $ cid2' == cid2
428− Received cid1' ["ping"] <- receive endpoint ; True <- return $ cid1' == cid1
429− ConnectionClosed cid1'' <- receive endpoint ; True <- return $ cid1'' == cid1
415+ replicateM numRepeats $ do
416+ -- We request two lightweight connections
417+ Right conn1 <- connect endpoint server ReliableOrdered
418+ Right conn2 <- connect endpoint server ReliableOrdered
419+
420+ -- Close the second one twice
421+ close conn2
422+ close conn2
423+
424+ -- Then send a message on the first and close that twice too
425+ send conn1 ["ping"]
426+ close conn1
430427
428+ -- Verify expected response from the echo server
429+ ConnectionOpened cid1 _ _ <- receive endpoint
430+ ConnectionOpened cid2 _ _ <- receive endpoint
431+ ConnectionClosed cid2' <- receive endpoint ; True <- return $ cid2' == cid2
432+ Received cid1' ["ping"] <- receive endpoint ; True <- return $ cid1' == cid1
433+ ConnectionClosed cid1'' <- receive endpoint ; True <- return $ cid1'' == cid1
434+
435+ return ()
436+
431437 putMVar clientDone ()
432438
433439 takeMVar clientDone
@@ -722,7 +728,7 @@ testTransport newTransport = do
722728 , ("ConnectToSelf", testConnectToSelf transport numPings)
723729 , ("ConnectToSelfTwice", testConnectToSelfTwice transport numPings)
724730 , ("CloseEndPoint", testCloseEndPoint transport numPings)
725− , ("CloseTransport", testCloseTransport newTransport)
731+ , ("CloseTransport", testCloseTransport newTransport)
726732 ]
727733 where
728734 numPings = 10000 :: Int