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/Data/Torrent/MetainfoSpec.hs | 2 +- tests/Network/BitTorrent/Core/NodeInfoSpec.hs | 52 +++++++++++++++++++++++++++ tests/Network/BitTorrent/Core/NodeSpec.hs | 52 --------------------------- tests/Network/BitTorrent/CoreSpec.hs | 6 ++-- 4 files changed, 56 insertions(+), 56 deletions(-) create mode 100644 tests/Network/BitTorrent/Core/NodeInfoSpec.hs delete mode 100644 tests/Network/BitTorrent/Core/NodeSpec.hs (limited to 'tests') diff --git a/tests/Data/Torrent/MetainfoSpec.hs b/tests/Data/Torrent/MetainfoSpec.hs index 3d1a9213..369c5e0f 100644 --- a/tests/Data/Torrent/MetainfoSpec.hs +++ b/tests/Data/Torrent/MetainfoSpec.hs @@ -17,7 +17,7 @@ import Data.Torrent.Piece import Data.Torrent.Layout import Data.Torrent import Data.Torrent.LayoutSpec () -import Network.BitTorrent.Core.NodeSpec () +import Network.BitTorrent.Core.NodeInfoSpec () {----------------------------------------------------------------------- -- Common 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