diff options
-rw-r--r-- | .ghci | 1 | ||||
-rw-r--r-- | tests/Network/KRPCSpec.hs | 9 |
2 files changed, 7 insertions, 3 deletions
@@ -1,3 +1,4 @@ | |||
1 | :set -isrc -itests -XRecordWildCards | ||
1 | import Control.Concurrent | 2 | import Control.Concurrent |
2 | import Data.BEncode | 3 | import Data.BEncode |
3 | import Network | 4 | import Network |
diff --git a/tests/Network/KRPCSpec.hs b/tests/Network/KRPCSpec.hs index 0a6dc8fb..eabcc817 100644 --- a/tests/Network/KRPCSpec.hs +++ b/tests/Network/KRPCSpec.hs | |||
@@ -25,6 +25,9 @@ opts = def { optQueryTimeout = 1 } | |||
25 | 25 | ||
26 | spec :: Spec | 26 | spec :: Spec |
27 | spec = do | 27 | spec = do |
28 | let qr :: MonadKRPC h m => SockAddr -> Echo Int -> m (Echo Int) | ||
29 | qr = query | ||
30 | |||
28 | describe "manager" $ do | 31 | describe "manager" $ do |
29 | it "is active until closeManager called" $ do | 32 | it "is active until closeManager called" $ do |
30 | m <- newManager opts servAddr [] | 33 | m <- newManager opts servAddr [] |
@@ -43,14 +46,14 @@ spec = do | |||
43 | it "count transactions properly" $ do | 46 | it "count transactions properly" $ do |
44 | (withManager opts servAddr handlers $ runReaderT $ do | 47 | (withManager opts servAddr handlers $ runReaderT $ do |
45 | listen | 48 | listen |
46 | _ <- query servAddr (Echo (0xabcd :: Int)) | 49 | _ <- qr servAddr (Echo 0xabcd) |
47 | _ <- query servAddr (Echo (0xabcd :: Int)) | 50 | _ <- qr servAddr (Echo 0xabcd) |
48 | getQueryCount | 51 | getQueryCount |
49 | ) | 52 | ) |
50 | `shouldReturn` 2 | 53 | `shouldReturn` 2 |
51 | 54 | ||
52 | it "throw timeout exception" $ do | 55 | it "throw timeout exception" $ do |
53 | (withManager opts servAddr handlers $ runReaderT $ do | 56 | (withManager opts servAddr handlers $ runReaderT $ do |
54 | query servAddr (Echo (0xabcd :: Int)) | 57 | qr servAddr (Echo 0xabcd) |
55 | ) | 58 | ) |
56 | `shouldThrow` (== TimeoutExpired) | 59 | `shouldThrow` (== TimeoutExpired) |