diff options
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r-- | tests/Network/BitTorrent/Tracker/MessageSpec.hs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/Network/BitTorrent/Tracker/MessageSpec.hs b/tests/Network/BitTorrent/Tracker/MessageSpec.hs new file mode 100644 index 00000000..62b4ab04 --- /dev/null +++ b/tests/Network/BitTorrent/Tracker/MessageSpec.hs | |||
@@ -0,0 +1,47 @@ | |||
1 | {-# OPTIONS -fno-warn-orphans #-} | ||
2 | module Network.BitTorrent.Tracker.MessageSpec (spec) where | ||
3 | |||
4 | import Control.Applicative | ||
5 | import Data.BEncode as BE | ||
6 | import Data.ByteString.Lazy as BL | ||
7 | import Data.Maybe | ||
8 | import Data.Word | ||
9 | import Network | ||
10 | import Network.URI | ||
11 | import Test.Hspec | ||
12 | import Test.QuickCheck | ||
13 | import Network.HTTP.Types.URI | ||
14 | |||
15 | import Data.Torrent.InfoHashSpec hiding (spec) | ||
16 | import Data.Torrent.ProgressSpec hiding (spec) | ||
17 | import Network.BitTorrent.Core.PeerIdSpec hiding (spec) | ||
18 | |||
19 | import Network.BitTorrent.Tracker.Message | ||
20 | |||
21 | |||
22 | prop_bencode :: Eq a => BEncode a => a -> Bool | ||
23 | prop_bencode a = BE.decode (BL.toStrict (BE.encode a)) == return a | ||
24 | |||
25 | --prop_urlencode :: Eq a => URLDecoded a => URLEncoded a => a -> Bool | ||
26 | --prop_urlencode a = urlDecode (T.pack (urlEncode a)) == a | ||
27 | |||
28 | instance Arbitrary Event where | ||
29 | arbitrary = elements [minBound..maxBound] | ||
30 | |||
31 | instance Arbitrary PortNumber where | ||
32 | arbitrary = fromIntegral <$> (arbitrary :: Gen Word16) | ||
33 | |||
34 | instance Arbitrary AnnounceQuery where | ||
35 | arbitrary = AnnounceQuery | ||
36 | <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary | ||
37 | <*> arbitrary <*> arbitrary <*> arbitrary | ||
38 | |||
39 | baseURI :: URI | ||
40 | baseURI = fromJust $ parseURI "http://a" | ||
41 | |||
42 | spec :: Spec | ||
43 | spec = do | ||
44 | describe "Announce" $ do | ||
45 | return () | ||
46 | describe "Scrape" $ do | ||
47 | return () | ||