summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent')
-rw-r--r--tests/Network/BitTorrent/Exchange/DownloadSpec.hs (renamed from tests/Network/BitTorrent/Exchange/Session/MetadataSpec.hs)17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/Network/BitTorrent/Exchange/Session/MetadataSpec.hs b/tests/Network/BitTorrent/Exchange/DownloadSpec.hs
index fc5236da..a0d40af3 100644
--- a/tests/Network/BitTorrent/Exchange/Session/MetadataSpec.hs
+++ b/tests/Network/BitTorrent/Exchange/DownloadSpec.hs
@@ -1,5 +1,5 @@
1{-# LANGUAGE RecordWildCards #-} 1{-# LANGUAGE RecordWildCards #-}
2module Network.BitTorrent.Exchange.Session.MetadataSpec (spec) where 2module Network.BitTorrent.Exchange.DownloadSpec (spec) where
3import Control.Concurrent 3import Control.Concurrent
4import Data.ByteString as BS 4import Data.ByteString as BS
5import Data.ByteString.Lazy as BL 5import Data.ByteString.Lazy as BL
@@ -9,8 +9,8 @@ import Test.QuickCheck
9import Data.BEncode as BE 9import Data.BEncode as BE
10import Data.Torrent as Torrent 10import Data.Torrent as Torrent
11import Network.BitTorrent.Address 11import Network.BitTorrent.Address
12import Network.BitTorrent.Exchange.Download
12import Network.BitTorrent.Exchange.Message 13import Network.BitTorrent.Exchange.Message
13import Network.BitTorrent.Exchange.Session.Metadata
14 14
15import Config 15import Config
16import Network.BitTorrent.CoreSpec () 16import Network.BitTorrent.CoreSpec ()
@@ -24,14 +24,15 @@ chunkBy s bs
24 | BS.null bs = [] 24 | BS.null bs = []
25 | otherwise = BS.take s bs : chunkBy s (BS.drop s bs) 25 | otherwise = BS.take s bs : chunkBy s (BS.drop s bs)
26 26
27withUpdates :: Updates a -> IO a 27withUpdates :: Updates s a -> IO a
28withUpdates m = do 28withUpdates m = do
29 Torrent {..} <- getTestTorrent 29 Torrent {..} <- getTestTorrent
30 let infoDictLen = fromIntegral $ BL.length $ BE.encode tInfoDict 30 let infoDictLen = fromIntegral $ BL.length $ BE.encode tInfoDict
31 mvar <- newMVar (nullStatus infoDictLen) 31 --mvar <- newMVar (nullStatus infoDictLen)
32 runUpdates mvar placeholderAddr m 32 --runUpdates mvar placeholderAddr m
33 undefined
33 34
34simulateFetch :: InfoDict -> Updates (Maybe InfoDict) 35simulateFetch :: InfoDict -> Updates s (Maybe InfoDict)
35simulateFetch dict = go 36simulateFetch dict = go
36 where 37 where
37 blocks = chunkBy metadataPieceSize (BL.toStrict (BE.encode dict)) 38 blocks = chunkBy metadataPieceSize (BL.toStrict (BE.encode dict))
@@ -39,11 +40,11 @@ simulateFetch dict = go
39 ih = idInfoHash dict 40 ih = idInfoHash dict
40 41
41 go = do 42 go = do
42 mix <- scheduleBlock 43 mix <- scheduleBlock undefined undefined
43 case mix of 44 case mix of
44 Nothing -> return Nothing 45 Nothing -> return Nothing
45 Just ix -> do 46 Just ix -> do
46 mdict <- pushBlock (packPiece ix) ih 47 mdict <- pushBlock undefined (packPiece ix)
47 maybe go (return . Just) mdict 48 maybe go (return . Just) mdict
48 49
49spec :: Spec 50spec :: Spec