diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-30 11:10:38 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-30 11:10:38 +0400 |
commit | 7f54308b57615bc61c0727538af2b5a54366eadb (patch) | |
tree | 8d47fb66163a8e9d114f1debf5711eca45500055 /tests/Network/BitTorrent/Tracker/RPC | |
parent | d4ee859973b200d3f81ea56b2e40847ed8c93510 (diff) |
Redesign tracker subsustem
Diffstat (limited to 'tests/Network/BitTorrent/Tracker/RPC')
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/MessageSpec.hs | 42 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | 7 |
2 files changed, 49 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 #-} | ||
2 | module Network.BitTorrent.Tracker.RPC.MessageSpec (spec) where | ||
3 | |||
4 | import Control.Applicative | ||
5 | import Data.Word | ||
6 | import Network | ||
7 | import Test.Hspec | ||
8 | import Test.QuickCheck | ||
9 | |||
10 | import Data.Torrent.InfoHashSpec () | ||
11 | import Data.Torrent.ProgressSpec () | ||
12 | import Network.BitTorrent.Core.PeerIdSpec () | ||
13 | |||
14 | import 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 | |||
23 | instance Arbitrary Event where | ||
24 | arbitrary = elements [minBound..maxBound] | ||
25 | |||
26 | instance Arbitrary PortNumber where | ||
27 | arbitrary = fromIntegral <$> (arbitrary :: Gen Word16) | ||
28 | |||
29 | instance Arbitrary AnnounceQuery where | ||
30 | arbitrary = AnnounceQuery | ||
31 | <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary | ||
32 | <*> arbitrary <*> arbitrary <*> arbitrary | ||
33 | |||
34 | spec :: Spec | ||
35 | spec = 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 () | ||
diff --git a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs new file mode 100644 index 00000000..4cbaa09d --- /dev/null +++ b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs | |||
@@ -0,0 +1,7 @@ | |||
1 | module Network.BitTorrent.Tracker.RPC.UDPSpec (spec) where | ||
2 | import Test.Hspec | ||
3 | |||
4 | spec :: Spec | ||
5 | spec = | ||
6 | describe "UDP tracker client RPC" $ do | ||
7 | return () \ No newline at end of file | ||