refactor exn handling function.
This commit is contained in:
parent
147f1edfbf
commit
69e16aa056
1 changed files with 5 additions and 8 deletions
13
Tests.hs
13
Tests.hs
|
@ -143,14 +143,8 @@ prop_handshake_initiate = do
|
||||||
params <- pick arbitraryPairParams
|
params <- pick arbitraryPairParams
|
||||||
(cCtx, sCtx) <- run $ newPairContext pipe params
|
(cCtx, sCtx) <- run $ newPairContext pipe params
|
||||||
|
|
||||||
run $ forkIO $ do
|
run $ forkIO $ catch (tlsServer sCtx resultQueue) (printAndRaise "server")
|
||||||
catch (tlsServer sCtx resultQueue)
|
run $ forkIO $ catch (tlsClient startQueue cCtx) (printAndRaise "client")
|
||||||
(\e -> putStrLn ("server exception: " ++ show e) >> throw (e :: SomeException))
|
|
||||||
return ()
|
|
||||||
run $ forkIO $ do
|
|
||||||
catch (tlsClient startQueue cCtx)
|
|
||||||
(\e -> putStrLn ("client exception: " ++ show e) >> throw (e :: SomeException))
|
|
||||||
return ()
|
|
||||||
|
|
||||||
{- the test involves writing data on one side of the data "pipe" and
|
{- the test involves writing data on one side of the data "pipe" and
|
||||||
- then checking we received them on the other side of the data "pipe" -}
|
- then checking we received them on the other side of the data "pipe" -}
|
||||||
|
@ -162,6 +156,9 @@ prop_handshake_initiate = do
|
||||||
|
|
||||||
return ()
|
return ()
|
||||||
where
|
where
|
||||||
|
printAndRaise :: String -> SomeException -> IO ()
|
||||||
|
printAndRaise s e = putStrLn (s ++ " exception: " ++ show e) >> throw e
|
||||||
|
|
||||||
someWords8 :: Int -> Gen [Word8]
|
someWords8 :: Int -> Gen [Word8]
|
||||||
someWords8 i = replicateM i (fromIntegral <$> (choose (0,255) :: Gen Int))
|
someWords8 i = replicateM i (fromIntegral <$> (choose (0,255) :: Gen Int))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue