summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Network/BitTorrent/Core/PeerAddrSpec.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/Network/BitTorrent/Core/PeerAddrSpec.hs b/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
index 1bc8d4b4..abb90183 100644
--- a/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
+++ b/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
@@ -99,7 +99,7 @@ spec = do
99 `shouldBe` 99 `shouldBe`
100 "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10" 100 "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10"
101 101
102 it "properly serialized iso" $ property $ \ ip -> 102 it "properly serialized (iso)" $ property $ \ ip ->
103 S.decode (S.encode ip) `shouldBe` Right (ip :: IPv6) 103 S.decode (S.encode ip) `shouldBe` Right (ip :: IPv6)
104 104
105 it "properly bencoded" $ do 105 it "properly bencoded" $ do
@@ -125,6 +125,25 @@ spec = do
125 125
126 126
127 describe "Peer IP" $ do 127 describe "Peer IP" $ do
128 it "properly serialized IPv6" $ do
129 S.decode "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10"
130 `shouldBe`
131 Right ("102:304:506:708:90a:b0c:d0e:f10" :: IP)
132
133 S.encode ("102:304:506:708:90a:b0c:d0e:f10" :: IP)
134 `shouldBe`
135 "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10"
136
137 it "properly serialized (iso) IPv6" $ property $ \ ip ->
138 S.decode (S.encode ip) `shouldBe` Right (ip :: IP)
139
140 it "properly serialized IPv4" $ do
141 S.decode "\x1\x2\x3\x4" `shouldBe` Right (IPv4 $ toIPv4 [1, 2, 3, 4])
142 S.encode (toIPv4 [1, 2, 3, 4]) `shouldBe` "\x1\x2\x3\x4"
143
144 it "properly serialized (iso) IPv4" $ property $ \ ip -> do
145 S.decode (S.encode ip) `shouldBe` Right (ip :: IP)
146
128 it "properly bencoded" $ do 147 it "properly bencoded" $ do
129 BE.decode "11:168.192.0.1" `shouldBe` 148 BE.decode "11:168.192.0.1" `shouldBe`
130 Right (IPv4 (toIPv4 [168, 192, 0, 1])) 149 Right (IPv4 (toIPv4 [168, 192, 0, 1]))