summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-07-08 22:34:16 +0400
committerSam T <pxqr.sta@gmail.com>2013-07-08 22:34:16 +0400
commit76b4937c99f131bbe52ef22b03a0bb7317280257 (patch)
tree4154022e200461f3c1cdbd0a9e036b935e56b639 /tests
parenta437e18badb78bd4946ce4ecec830acdf000abee (diff)
~ Allow passing raw dictionaries.
We need this in Kademlia DHT -- there are method which return dictionaries with different keys depending on DHT server state.
Diffstat (limited to 'tests')
-rw-r--r--tests/Client.hs8
-rw-r--r--tests/Server.hs1
-rw-r--r--tests/Shared.hs6
3 files changed, 14 insertions, 1 deletions
diff --git a/tests/Client.hs b/tests/Client.hs
index 1b9ef8d2..313cd56e 100644
--- a/tests/Client.hs
+++ b/tests/Client.hs
@@ -5,6 +5,7 @@ import Control.Concurrent
5import Control.Exception 5import Control.Exception
6import qualified Data.ByteString as B 6import qualified Data.ByteString as B
7import Data.BEncode 7import Data.BEncode
8import Data.Map
8import System.Environment 9import System.Environment
9import System.Process 10import System.Process
10import System.FilePath 11import System.FilePath
@@ -69,4 +70,11 @@ tests =
69 70
70 , testCase "raw method" $ 71 , testCase "raw method" $
71 BInteger 10 ==? call addr rawM (BInteger 10) 72 BInteger 10 ==? call addr rawM (BInteger 10)
73
74 , testCase "raw dict" $
75 let dict = BDict $ fromList
76 [ ("some_int", BInteger 100)
77 , ("some_list", BList [BInteger 10])
78 ]
79 in dict ==? call addr rawDictM dict
72 ] 80 ]
diff --git a/tests/Server.hs b/tests/Server.hs
index 7cd6a5d6..aaf6d9f2 100644
--- a/tests/Server.hs
+++ b/tests/Server.hs
@@ -15,4 +15,5 @@ main = server 6000
15 , reverseM ==> return . reverse 15 , reverseM ==> return . reverse
16 , shiftR ==> \(a, b, c) -> return (c, a, b) 16 , shiftR ==> \(a, b, c) -> return (c, a, b)
17 , rawM ==> return 17 , rawM ==> return
18 , rawDictM ==> return
18 ] 19 ]
diff --git a/tests/Shared.hs b/tests/Shared.hs
index a04b6093..f64112da 100644
--- a/tests/Shared.hs
+++ b/tests/Shared.hs
@@ -7,6 +7,7 @@ module Shared
7 , reverseM 7 , reverseM
8 , shiftR 8 , shiftR
9 , rawM 9 , rawM
10 , rawDictM
10 ) where 11 ) where
11 12
12import Data.ByteString (ByteString) 13import Data.ByteString (ByteString)
@@ -32,4 +33,7 @@ shiftR :: Method ((), Int, [Int]) ([Int], (), Int)
32shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"] 33shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"]
33 34
34rawM :: Method BEncode BEncode 35rawM :: Method BEncode BEncode
35rawM = method "rawM" [""] [""] \ No newline at end of file 36rawM = method "rawM" [""] [""]
37
38rawDictM :: Method BEncode BEncode
39rawDictM = method "m" [] [] \ No newline at end of file