diff options
Diffstat (limited to 'tests/Network')
-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 #-} |
2 | module Network.BitTorrent.Exchange.Session.MetadataSpec (spec) where | 2 | module Network.BitTorrent.Exchange.DownloadSpec (spec) where |
3 | import Control.Concurrent | 3 | import Control.Concurrent |
4 | import Data.ByteString as BS | 4 | import Data.ByteString as BS |
5 | import Data.ByteString.Lazy as BL | 5 | import Data.ByteString.Lazy as BL |
@@ -9,8 +9,8 @@ import Test.QuickCheck | |||
9 | import Data.BEncode as BE | 9 | import Data.BEncode as BE |
10 | import Data.Torrent as Torrent | 10 | import Data.Torrent as Torrent |
11 | import Network.BitTorrent.Address | 11 | import Network.BitTorrent.Address |
12 | import Network.BitTorrent.Exchange.Download | ||
12 | import Network.BitTorrent.Exchange.Message | 13 | import Network.BitTorrent.Exchange.Message |
13 | import Network.BitTorrent.Exchange.Session.Metadata | ||
14 | 14 | ||
15 | import Config | 15 | import Config |
16 | import Network.BitTorrent.CoreSpec () | 16 | import 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 | ||
27 | withUpdates :: Updates a -> IO a | 27 | withUpdates :: Updates s a -> IO a |
28 | withUpdates m = do | 28 | withUpdates 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 | ||
34 | simulateFetch :: InfoDict -> Updates (Maybe InfoDict) | 35 | simulateFetch :: InfoDict -> Updates s (Maybe InfoDict) |
35 | simulateFetch dict = go | 36 | simulateFetch 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 | ||
49 | spec :: Spec | 50 | spec :: Spec |