summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Core/NodeInfoSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent/Core/NodeInfoSpec.hs')
-rw-r--r--tests/Network/BitTorrent/Core/NodeInfoSpec.hs52
1 files changed, 0 insertions, 52 deletions
diff --git a/tests/Network/BitTorrent/Core/NodeInfoSpec.hs b/tests/Network/BitTorrent/Core/NodeInfoSpec.hs
deleted file mode 100644
index 0d30b9a6..00000000
--- a/tests/Network/BitTorrent/Core/NodeInfoSpec.hs
+++ /dev/null
@@ -1,52 +0,0 @@
1{-# OPTIONS -fno-warn-orphans #-}
2module Network.BitTorrent.Core.NodeInfoSpec (spec) where
3import Control.Applicative
4import Data.Serialize as S
5import Data.String
6import Test.Hspec
7import Test.QuickCheck
8
9import Network.BitTorrent.Address
10import Network.BitTorrent.Core.PeerAddrSpec ()
11
12instance Arbitrary NodeId where
13 arbitrary = fromString <$> vector 20
14
15instance Arbitrary a => Arbitrary (NodeAddr a) where
16 arbitrary = NodeAddr <$> arbitrary <*> arbitrary
17
18instance Arbitrary a => Arbitrary (NodeInfo a) where
19 arbitrary = NodeInfo <$> arbitrary <*> arbitrary
20
21spec :: Spec
22spec = do
23 describe "NodeId" $ do
24 it "properly serialized" $ do
25 S.decode "mnopqrstuvwxyz123456"
26 `shouldBe` Right ("mnopqrstuvwxyz123456" :: NodeId)
27
28 S.encode ("mnopqrstuvwxyz123456" :: NodeId)
29 `shouldBe` "mnopqrstuvwxyz123456"
30
31 it "properly serialized (iso)" $ property $ \ nid ->
32 S.decode (S.encode nid) `shouldBe`
33 Right (nid :: NodeId)
34
35 describe "NodeAddr" $ do
36 it "properly serialized" $ do
37 S.decode "\127\0\0\1\1\2" `shouldBe`
38 Right ("127.0.0.1:258" :: NodeAddr IPv4)
39
40 it "properly serialized (iso)" $ property $ \ nid ->
41 S.decode (S.encode nid) `shouldBe`
42 Right (nid :: NodeAddr IPv4)
43
44 describe "NodeInfo" $ do
45 it "properly serialized" $ do
46 S.decode "mnopqrstuvwxyz123456\
47 \\127\0\0\1\1\2" `shouldBe` Right
48 (NodeInfo "mnopqrstuvwxyz123456" "127.0.0.1:258" :: NodeInfo IPv4)
49
50 it "properly serialized (iso)" $ property $ \ nid ->
51 S.decode (S.encode nid) `shouldBe`
52 Right (nid :: NodeInfo IPv4)