From 3cc3e07e6db83b4b213d84c79dcb4b3aa1331b6c Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 9 Jan 2014 05:40:13 +0400 Subject: Rename Node.hs to NodeInfo.hs --- tests/Network/BitTorrent/Core/NodeInfoSpec.hs | 52 +++++++++++++++++++++++++++ tests/Network/BitTorrent/Core/NodeSpec.hs | 52 --------------------------- tests/Network/BitTorrent/CoreSpec.hs | 6 ++-- 3 files changed, 55 insertions(+), 55 deletions(-) create mode 100644 tests/Network/BitTorrent/Core/NodeInfoSpec.hs delete mode 100644 tests/Network/BitTorrent/Core/NodeSpec.hs (limited to 'tests/Network') diff --git a/tests/Network/BitTorrent/Core/NodeInfoSpec.hs b/tests/Network/BitTorrent/Core/NodeInfoSpec.hs new file mode 100644 index 00000000..fb777440 --- /dev/null +++ b/tests/Network/BitTorrent/Core/NodeInfoSpec.hs @@ -0,0 +1,52 @@ +{-# OPTIONS -fno-warn-orphans #-} +module Network.BitTorrent.Core.NodeInfoSpec (spec) where +import Control.Applicative +import Data.Serialize as S +import Data.String +import Test.Hspec +import Test.QuickCheck + +import Network.BitTorrent.Core +import Network.BitTorrent.Core.PeerAddrSpec () + +instance Arbitrary NodeId where + arbitrary = fromString <$> vector 20 + +instance Arbitrary a => Arbitrary (NodeAddr a) where + arbitrary = NodeAddr <$> arbitrary <*> arbitrary + +instance Arbitrary a => Arbitrary (NodeInfo a) where + arbitrary = NodeInfo <$> arbitrary <*> arbitrary + +spec :: Spec +spec = do + describe "NodeId" $ do + it "properly serialized" $ do + S.decode "mnopqrstuvwxyz123456" + `shouldBe` Right ("mnopqrstuvwxyz123456" :: NodeId) + + S.encode ("mnopqrstuvwxyz123456" :: NodeId) + `shouldBe` "mnopqrstuvwxyz123456" + + it "properly serialized (iso)" $ property $ \ nid -> + S.decode (S.encode nid) `shouldBe` + Right (nid :: NodeId) + + describe "NodeAddr" $ do + it "properly serialized" $ do + S.decode "\127\0\0\1\1\2" `shouldBe` + Right ("127.0.0.1:258" :: NodeAddr IPv4) + + it "properly serialized (iso)" $ property $ \ nid -> + S.decode (S.encode nid) `shouldBe` + Right (nid :: NodeAddr IPv4) + + describe "NodeInfo" $ do + it "properly serialized" $ do + S.decode "mnopqrstuvwxyz123456\ + \\127\0\0\1\1\2" `shouldBe` Right + (NodeInfo "mnopqrstuvwxyz123456" "127.0.0.1:258" :: NodeInfo IPv4) + + it "properly serialized (iso)" $ property $ \ nid -> + S.decode (S.encode nid) `shouldBe` + Right (nid :: NodeInfo IPv4) diff --git a/tests/Network/BitTorrent/Core/NodeSpec.hs b/tests/Network/BitTorrent/Core/NodeSpec.hs deleted file mode 100644 index 3f27f9eb..00000000 --- a/tests/Network/BitTorrent/Core/NodeSpec.hs +++ /dev/null @@ -1,52 +0,0 @@ -{-# OPTIONS -fno-warn-orphans #-} -module Network.BitTorrent.Core.NodeSpec (spec) where -import Control.Applicative -import Data.Serialize as S -import Data.String -import Test.Hspec -import Test.QuickCheck - -import Network.BitTorrent.Core -import Network.BitTorrent.Core.PeerAddrSpec () - -instance Arbitrary NodeId where - arbitrary = fromString <$> vector 20 - -instance Arbitrary a => Arbitrary (NodeAddr a) where - arbitrary = NodeAddr <$> arbitrary <*> arbitrary - -instance Arbitrary a => Arbitrary (NodeInfo a) where - arbitrary = NodeInfo <$> arbitrary <*> arbitrary - -spec :: Spec -spec = do - describe "NodeId" $ do - it "properly serialized" $ do - S.decode "mnopqrstuvwxyz123456" - `shouldBe` Right ("mnopqrstuvwxyz123456" :: NodeId) - - S.encode ("mnopqrstuvwxyz123456" :: NodeId) - `shouldBe` "mnopqrstuvwxyz123456" - - it "properly serialized (iso)" $ property $ \ nid -> - S.decode (S.encode nid) `shouldBe` - Right (nid :: NodeId) - - describe "NodeAddr" $ do - it "properly serialized" $ do - S.decode "\127\0\0\1\1\2" `shouldBe` - Right ("127.0.0.1:258" :: NodeAddr IPv4) - - it "properly serialized (iso)" $ property $ \ nid -> - S.decode (S.encode nid) `shouldBe` - Right (nid :: NodeAddr IPv4) - - describe "NodeInfo" $ do - it "properly serialized" $ do - S.decode "mnopqrstuvwxyz123456\ - \\127\0\0\1\1\2" `shouldBe` Right - (NodeInfo "mnopqrstuvwxyz123456" "127.0.0.1:258" :: NodeInfo IPv4) - - it "properly serialized (iso)" $ property $ \ nid -> - S.decode (S.encode nid) `shouldBe` - Right (nid :: NodeInfo IPv4) diff --git a/tests/Network/BitTorrent/CoreSpec.hs b/tests/Network/BitTorrent/CoreSpec.hs index 9f9eb0eb..460c52be 100644 --- a/tests/Network/BitTorrent/CoreSpec.hs +++ b/tests/Network/BitTorrent/CoreSpec.hs @@ -1,9 +1,9 @@ -- | Re-export modules. module Network.BitTorrent.CoreSpec (spec) where import Network.BitTorrent.Core.FingerprintSpec as CoreSpec () -import Network.BitTorrent.Core.NodeSpec as CoreSpec () -import Network.BitTorrent.Core.PeerIdSpec as CoreSpec () -import Network.BitTorrent.Core.PeerAddrSpec as CoreSpec () +import Network.BitTorrent.Core.NodeInfoSpec as CoreSpec () +import Network.BitTorrent.Core.PeerIdSpec as CoreSpec () +import Network.BitTorrent.Core.PeerAddrSpec as CoreSpec () import Test.Hspec (Spec) -- cgit v1.2.3