git.iko.soy/distributed-process
on master help sign in
Reenable the early disconnect test
commit86903914cb687a2793c91455a38c9b0cbdeb7507 authorEdsko de Vries <edsko@edsko.net> dateWed 2 May 2012, 09:56 (14 years ago) parent528cfd8
2 files changed+10−10
network-transport-2/src/Network/Transport/TCP.hs+3−2 network-transport-2/tests/TestTCP.hs+7−8
network-transport-2/src/Network/Transport/TCP.hs+3−2
@@ -6,12 +6,13 @@
66-- @192.168.0.1:8080@ and /B/ subsequently connects tries to connect to /A/ as
77-- @client1.local:http-alt@ then the transport layer will not realize that the
88-- TCP connection can be reused.
9−module Network.Transport.TCP {- ( -- * Main API
9+module Network.Transport.TCP ( -- * Main API
1010 createTransport
1111 , -- * TCP specific functionality
1212 EndPointId
1313 , decodeEndPointAddress
1414 , ControlHeader(..)
15+ , ConnectionRequestResponse(..)
1516 -- * Design notes
1617 -- ** Overview
1718 -- $overview
@@ -19,7 +20,7 @@ module Network.Transport.TCP {- ( -- * Main API
1920 -- $connecting
2021 -- ** Disconnecting
2122 -- $disconnecting
22− ) -} where
23+ ) where
2324
2425import Network.Transport
2526import Network.Transport.Internal.TCP ( forkServer
network-transport-2/tests/TestTCP.hs+7−8
@@ -3,12 +3,11 @@ module Main where
33import TestTransport
44import Network.Transport
55import Network.Transport.TCP (createTransport)
6−{-
76import Data.Int (Int32)
87import Data.Maybe (fromJust)
98import Control.Concurrent (forkIO)
109import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar, takeMVar, readMVar)
11−import Network.Transport.TCP (decodeEndPointAddress, EndPointId, ControlHeader(..))
10+import Network.Transport.TCP (decodeEndPointAddress, EndPointId, ControlHeader(..), ConnectionRequestResponse(..))
1211import Network.Transport.Internal (encodeInt32, prependLength)
1312import Network.Transport.Internal.TCP (recvInt32)
1413import qualified Network.Socket as N ( getAddrInfo
@@ -25,11 +24,10 @@ import qualified Network.Socket as N ( getAddrInfo
2524 , ServiceName
2625 )
2726import Network.Socket.ByteString (sendMany)
28−-}
2927
28+-- Test that the server gets a ConnectionClosed message when the client closes
29+-- the socket without sending an explicit control message to the server first
3030testEarlyDisconnect :: IO ()
31−testEarlyDisconnect = return ()
32−{-
3331testEarlyDisconnect = do
3432 serverAddr <- newEmptyMVar
3533 serverDone <- newEmptyMVar
@@ -63,7 +61,7 @@ testEarlyDisconnect = do
6361 sendMany sock (encodeInt32 endPointIx : prependLength [myAddress])
6462
6563 -- Wait for acknowledgement
66− ValidEndPoint <- recvInt32 sock
64+ ConnectionRequestAccepted <- recvInt32 sock
6765
6866 -- Request a new connection, but don't wait for the response
6967 let reqId = 0 :: Int32
@@ -72,13 +70,14 @@ testEarlyDisconnect = do
7270 -- Close the socket without closing the connection explicitly
7371 -- The server should still receive a ConnectionClosed message
7472 N.sClose sock
75−-}
7673
74+-- | Test the creation of a transport with an invalid address
7775testInvalidAddress :: IO ()
7876testInvalidAddress = do
7977 Left _ <- createTransport "invalidHostName" "8082"
8078 return ()
8179
80+-- | Test connecting to invalid or non-existing endpoints
8281testInvalidConnect :: IO ()
8382testInvalidConnect = do
8483 Right transport <- createTransport "127.0.0.1" "8083"
@@ -104,7 +103,7 @@ testInvalidConnect = do
104103
105104main :: IO ()
106105main = do
107− -- runTestIO "EarlyDisconnect" testEarlyDisconnect
106+ runTestIO "EarlyDisconnect" testEarlyDisconnect
108107 runTestIO "InvalidAddress" testInvalidAddress
109108 runTestIO "InvalidConnect" testInvalidConnect
110109 Right transport <- createTransport "127.0.0.1" "8080"