@@ -374,7 +374,7 @@ testParallelConnects transport numPings = do
375-- | Test that sending on a closed connection gives an error
375-- | Test that sending on a closed connection gives an error
376testSendAfterClose :: Transport -> Int -> IO ()
376testSendAfterClose :: Transport -> Int -> IO ()
377−testSendAfterClose transport _ = do
377+testSendAfterClose transport numRepeats = do
378 server <- spawn transport echoServer
378 server <- spawn transport echoServer
379 clientDone <- newEmptyMVar
379 clientDone <- newEmptyMVar
@@ -382,19 +382,22 @@ testSendAfterClose transport _ = do
382 Right endpoint <- newEndPoint transport
382 Right endpoint <- newEndPoint transport
384 -- We request two lightweight connections
384 -- We request two lightweight connections
385+ replicateM numRepeats $ do
385− Right conn1 <- connect endpoint server ReliableOrdered
386+ Right conn1 <- connect endpoint server ReliableOrdered
386− Right conn2 <- connect endpoint server ReliableOrdered
387+ Right conn2 <- connect endpoint server ReliableOrdered
388− -- Close the second, but leave the first open; then output on the second
389+ -- 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 (i.e., on a closed connection while there is still another
390− -- connection open)
391+ -- connection open)
391− close conn2
392+ close conn2
393+ Left (TransportError SendFailed _) <- send conn2 ["ping2"]
395+ -- Now close the first connection, and output on it (i.e., output while
396+ -- there are no lightweight connection at all anymore)
392− Left (TransportError SendFailed _) <- send conn2 ["ping2"]
398+ Left (TransportError SendFailed _) <- send conn2 ["ping2"]
394− -- Now close the first connection, and output on it (i.e., output while
400+ return ()
395− -- there are no lightweight connection at all anymore)
397− Left (TransportError SendFailed _) <- send conn2 ["ping2"]
399 putMVar clientDone ()
402 putMVar clientDone ()
@@ -402,32 +405,35 @@ testSendAfterClose transport _ = do
403-- | Test that closing the same connection twice has no effect
406-- | Test that closing the same connection twice has no effect
404testCloseTwice :: Transport -> Int -> IO ()
407testCloseTwice :: Transport -> Int -> IO ()
405−testCloseTwice transport _ = do
408+testCloseTwice transport numRepeats = do
406 server <- spawn transport echoServer
409 server <- spawn transport echoServer
407 clientDone <- newEmptyMVar
410 clientDone <- newEmptyMVar
409 forkTry $ do
412 forkTry $ do
410 Right endpoint <- newEndPoint transport
413 Right endpoint <- newEndPoint transport
415+ replicateM numRepeats $ do
412− -- We request two lightweight connections
416+ -- We request two lightweight connections
413− Right conn1 <- connect endpoint server ReliableOrdered
417+ Right conn1 <- connect endpoint server ReliableOrdered
414− Right conn2 <- connect endpoint server ReliableOrdered
418+ Right conn2 <- connect endpoint server ReliableOrdered
416− -- Close the second one twice
420+ -- Close the second one twice
417− close conn2
421+ close conn2
418− close conn2
422+ close conn2
420− -- Then send a message on the first and close that too
424+ -- Then send a message on the first and close that twice too
421− send conn1 ["ping"]
425+ send conn1 ["ping"]
422− close conn1
426+ close conn1
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
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
431 putMVar clientDone ()
437 putMVar clientDone ()
433 takeMVar clientDone
439 takeMVar clientDone
@@ -722,7 +728,7 @@ testTransport newTransport = do
722 , ("ConnectToSelf", testConnectToSelf transport numPings)
728 , ("ConnectToSelf", testConnectToSelf transport numPings)
723 , ("ConnectToSelfTwice", testConnectToSelfTwice transport numPings)
729 , ("ConnectToSelfTwice", testConnectToSelfTwice transport numPings)
724 , ("CloseEndPoint", testCloseEndPoint transport numPings)
730 , ("CloseEndPoint", testCloseEndPoint transport numPings)
725− , ("CloseTransport", testCloseTransport newTransport)
731+ , ("CloseTransport", testCloseTransport newTransport)
728 numPings = 10000 :: Int
734 numPings = 10000 :: Int