diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-04-08 03:11:59 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-04-08 03:11:59 +0400 |
commit | 2a9a39dccbe7ed46b537d6b051c42432c275e156 (patch) | |
tree | 546c52a97f5f149a438e10ddb0c70b92e70e20ed /tests/Network/BitTorrent/Core/NodeInfoSpec.hs | |
parent | 784aead759a47eea59317e51edfaddc55bb4ddbd (diff) |
Fold CoreSpec modules
Diffstat (limited to 'tests/Network/BitTorrent/Core/NodeInfoSpec.hs')
-rw-r--r-- | tests/Network/BitTorrent/Core/NodeInfoSpec.hs | 52 |
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 #-} | ||
2 | module Network.BitTorrent.Core.NodeInfoSpec (spec) where | ||
3 | import Control.Applicative | ||
4 | import Data.Serialize as S | ||
5 | import Data.String | ||
6 | import Test.Hspec | ||
7 | import Test.QuickCheck | ||
8 | |||
9 | import Network.BitTorrent.Address | ||
10 | import Network.BitTorrent.Core.PeerAddrSpec () | ||
11 | |||
12 | instance Arbitrary NodeId where | ||
13 | arbitrary = fromString <$> vector 20 | ||
14 | |||
15 | instance Arbitrary a => Arbitrary (NodeAddr a) where | ||
16 | arbitrary = NodeAddr <$> arbitrary <*> arbitrary | ||
17 | |||
18 | instance Arbitrary a => Arbitrary (NodeInfo a) where | ||
19 | arbitrary = NodeInfo <$> arbitrary <*> arbitrary | ||
20 | |||
21 | spec :: Spec | ||
22 | spec = 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) | ||