@@ -7,6 +7,7 @@ import GHC.Generics
7import Control.Concurrent.MVar
7import Control.Concurrent.MVar
8import Network.Socket (SockAddr(..))
8import Network.Socket (SockAddr(..))
9import Control.Concurrent.Async
9import Control.Concurrent.Async
11import Network.RPC.Curryer.Server
12import Network.RPC.Curryer.Server
12import Network.RPC.Curryer.Client
13import Network.RPC.Curryer.Client
@@ -43,6 +44,7 @@ testServerMessageHandler mAsyncMVar msg = do
43 Nothing -> pure ()
44 Nothing -> pure ()
44 Just mvar -> putMVar mvar s
45 Just mvar -> putMVar mvar s
45 pure NoResponse
46 pure NoResponse
47+ TestAsyncReq _ -> pure NoResponse
47-- test a simple client-to-server round-trip function execution
49-- test a simple client-to-server round-trip function execution
48testSimpleCall :: Assertion
50testSimpleCall :: Assertion
@@ -59,9 +61,11 @@ testSimpleCall = do
59 conn <- mkConn
61 conn <- mkConn
60 let c :: IO (Either ConnectionError TestResponse)
62 let c :: IO (Either ConnectionError TestResponse)
61 c = call conn (AddTwoNumbersReq 1 1)
63 c = call conn (AddTwoNumbersReq 1 1)
64+ replicateM_ 5 $ do --make five AddTwo calls to shake out parallelism bugs
63− assertEqual "server request+response" (Right (AddTwoNumbersResp 2)) x
66+ assertEqual "server request+response" (Right (AddTwoNumbersResp 2)) x
64 close conn
67 close conn
66--test that the client can proces a server-initiated asynchronous callback from the server
70--test that the client can proces a server-initiated asynchronous callback from the server
67testAsyncServerCall :: Assertion
71testAsyncServerCall :: Assertion
@@ -84,6 +88,7 @@ testAsyncServerCall = do
84 asyncMessage <- takeMVar receivedAsyncMessageVar
88 asyncMessage <- takeMVar receivedAsyncMessageVar
85 assertEqual "async message" "welcome" asyncMessage
89 assertEqual "async message" "welcome" asyncMessage
86 close conn
90 close conn
88--test that the client can make a non-blocking call
93--test that the client can make a non-blocking call
89testAsyncClientCall :: Assertion
94testAsyncClientCall :: Assertion
@@ -100,3 +105,4 @@ testAsyncClientCall = do
100 asyncMessage <- takeMVar receivedAsyncMessageVar
105 asyncMessage <- takeMVar receivedAsyncMessageVar
101 assertEqual "async message" "hi server" asyncMessage
106 assertEqual "async message" "hi server" asyncMessage
102 close conn
107 close conn