summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs
new file mode 100644
index 00000000..8e95286a
--- /dev/null
+++ b/tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs
@@ -0,0 +1,42 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Network.BitTorrent.Tracker.RPC.MessageSpec (spec) where
3
4import Control.Applicative
5import Data.Word
6import Network
7import Test.Hspec
8import Test.QuickCheck
9
10import Data.Torrent.InfoHashSpec ()
11import Data.Torrent.ProgressSpec ()
12import Network.BitTorrent.Core.PeerIdSpec ()
13
14import Network.BitTorrent.Tracker.RPC.Message
15
16
17--prop_bencode :: Eq a => BEncode a => a -> Bool
18--prop_bencode a = BE.decode (BL.toStrict (BE.encode a)) == return a
19
20--prop_urlencode :: Eq a => URLDecoded a => URLEncoded a => a -> Bool
21--prop_urlencode a = urlDecode (T.pack (urlEncode a)) == a
22
23instance Arbitrary Event where
24 arbitrary = elements [minBound..maxBound]
25
26instance Arbitrary PortNumber where
27 arbitrary = fromIntegral <$> (arbitrary :: Gen Word16)
28
29instance Arbitrary AnnounceQuery where
30 arbitrary = AnnounceQuery
31 <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
32 <*> arbitrary <*> arbitrary <*> arbitrary
33
34spec :: Spec
35spec = do
36 describe "Announce" $ do
37 it "properly url encoded" $ property $ \ q ->
38 parseAnnounceQuery (renderAnnounceQuery q)
39 `shouldBe` Right q
40
41 describe "Scrape" $ do
42 return ()