diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-07-08 22:34:16 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-07-08 22:34:16 +0400 |
commit | 76b4937c99f131bbe52ef22b03a0bb7317280257 (patch) | |
tree | 4154022e200461f3c1cdbd0a9e036b935e56b639 /tests | |
parent | a437e18badb78bd4946ce4ecec830acdf000abee (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.hs | 8 | ||||
-rw-r--r-- | tests/Server.hs | 1 | ||||
-rw-r--r-- | tests/Shared.hs | 6 |
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 | |||
5 | import Control.Exception | 5 | import Control.Exception |
6 | import qualified Data.ByteString as B | 6 | import qualified Data.ByteString as B |
7 | import Data.BEncode | 7 | import Data.BEncode |
8 | import Data.Map | ||
8 | import System.Environment | 9 | import System.Environment |
9 | import System.Process | 10 | import System.Process |
10 | import System.FilePath | 11 | import 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 | ||
12 | import Data.ByteString (ByteString) | 13 | import Data.ByteString (ByteString) |
@@ -32,4 +33,7 @@ shiftR :: Method ((), Int, [Int]) ([Int], (), Int) | |||
32 | shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"] | 33 | shiftR = method "shiftR" ["x", "y", "z"] ["a", "b", "c"] |
33 | 34 | ||
34 | rawM :: Method BEncode BEncode | 35 | rawM :: Method BEncode BEncode |
35 | rawM = method "rawM" [""] [""] \ No newline at end of file | 36 | rawM = method "rawM" [""] [""] |
37 | |||
38 | rawDictM :: Method BEncode BEncode | ||
39 | rawDictM = method "m" [] [] \ No newline at end of file | ||