summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/DHT/MessageSpec.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-27 05:58:26 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-27 05:58:26 +0400
commit31b7dbfe7e62c5aaa4026504e2ebd908bd3d2cbb (patch)
tree61a7ef6e977f2a023b8d4fc014db150362f288f0 /tests/Network/BitTorrent/DHT/MessageSpec.hs
parente06b3dbd76a0a76c872ca27b4ea33b4465d14da3 (diff)
Add implied_port field to DHT announce query
Diffstat (limited to 'tests/Network/BitTorrent/DHT/MessageSpec.hs')
-rw-r--r--tests/Network/BitTorrent/DHT/MessageSpec.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/Network/BitTorrent/DHT/MessageSpec.hs b/tests/Network/BitTorrent/DHT/MessageSpec.hs
index 52bda932..11a8fb15 100644
--- a/tests/Network/BitTorrent/DHT/MessageSpec.hs
+++ b/tests/Network/BitTorrent/DHT/MessageSpec.hs
@@ -143,15 +143,24 @@ spec = do
143 \5:token8:aoeusnth\ 143 \5:token8:aoeusnth\
144 \e" `shouldBe` Right 144 \e" `shouldBe` Right
145 (Query "abcdefghij0123456789" 145 (Query "abcdefghij0123456789"
146 (Announce "mnopqrstuvwxyz123456" 6881 "aoeusnth")) 146 (Announce False "mnopqrstuvwxyz123456" 6881 "aoeusnth"))
147
148 BE.decode "d2:id20:abcdefghij0123456789\
149 \12:implied_porti1e\
150 \9:info_hash20:mnopqrstuvwxyz123456\
151 \4:porti6881e\
152 \5:token8:aoeusnth\
153 \e" `shouldBe` Right
154 (Query "abcdefghij0123456789"
155 (Announce True "mnopqrstuvwxyz123456" 6881 "aoeusnth"))
147 156
148 157
149 BE.decode "d2:id20:mnopqrstuvwxyz123456e" 158 BE.decode "d2:id20:mnopqrstuvwxyz123456e"
150 `shouldBe` Right 159 `shouldBe` Right
151 (Response "mnopqrstuvwxyz123456" Announced) 160 (Response "mnopqrstuvwxyz123456" Announced)
152 161
153 it "properly bencoded (iso)" $ property $ \ nid topic port token -> do 162 it "properly bencoded (iso)" $ property $ \ nid flag topic port token -> do
154 prop_bencode (Query nid (Announce topic port token)) 163 prop_bencode (Query nid (Announce flag topic port token))
155 prop_bencode (Response nid (Announced)) 164 prop_bencode (Response nid (Announced))
156 165
157 166
@@ -160,7 +169,7 @@ spec = do
160 Response _remoteId Announced <- rpc $ do 169 Response _remoteId Announced <- rpc $ do
161 Response _ GotPeers {..} <- query remoteAddr (Query nid (GetPeers def)) 170 Response _ GotPeers {..} <- query remoteAddr (Query nid (GetPeers def))
162 let _ = peers :: Either [NodeInfo IPv4] [PeerAddr IPv4] 171 let _ = peers :: Either [NodeInfo IPv4] [PeerAddr IPv4]
163 query remoteAddr (Query nid (Announce def thisPort grantedToken)) 172 query remoteAddr (Query nid (Announce False def thisPort grantedToken))
164 return () 173 return ()
165 174
166 it "does fail on invalid token" $ do 175 it "does fail on invalid token" $ do
@@ -169,6 +178,6 @@ spec = do
169 Response _ GotPeers {..} <- query remoteAddr (Query nid (GetPeers def)) 178 Response _ GotPeers {..} <- query remoteAddr (Query nid (GetPeers def))
170 let _ = peers :: Either [NodeInfo IPv4] [PeerAddr IPv4] 179 let _ = peers :: Either [NodeInfo IPv4] [PeerAddr IPv4]
171 let invalidToken = "" 180 let invalidToken = ""
172 query remoteAddr (Query nid (Announce def thisPort invalidToken))) 181 query remoteAddr (Query nid (Announce False def thisPort invalidToken)))
173 `shouldThrow` isProtocolError 182 `shouldThrow` isProtocolError
174 return () 183 return ()