diff options
Diffstat (limited to 'tests/Network/BitTorrent')
-rw-r--r-- | tests/Network/BitTorrent/DHT/MessageSpec.hs | 19 |
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 () |