diff options
Diffstat (limited to 'tests/Network/BitTorrent/Exchange')
-rw-r--r-- | tests/Network/BitTorrent/Exchange/BitfieldSpec.hs | 13 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Exchange/ConnectionSpec.hs | 3 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Exchange/DownloadSpec.hs (renamed from tests/Network/BitTorrent/Exchange/Session/MetadataSpec.hs) | 32 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Exchange/MessageSpec.hs | 6 | ||||
-rw-r--r-- | tests/Network/BitTorrent/Exchange/SessionSpec.hs | 2 |
5 files changed, 28 insertions, 28 deletions
diff --git a/tests/Network/BitTorrent/Exchange/BitfieldSpec.hs b/tests/Network/BitTorrent/Exchange/BitfieldSpec.hs new file mode 100644 index 00000000..234965fa --- /dev/null +++ b/tests/Network/BitTorrent/Exchange/BitfieldSpec.hs | |||
@@ -0,0 +1,13 @@ | |||
1 | {-# OPTIONS -fno-warn-orphans #-} | ||
2 | module Network.BitTorrent.Exchange.BitfieldSpec (spec) where | ||
3 | import Control.Applicative | ||
4 | import Test.Hspec | ||
5 | import Test.QuickCheck | ||
6 | |||
7 | import Network.BitTorrent.Exchange.Bitfield | ||
8 | |||
9 | instance Arbitrary Bitfield where | ||
10 | arbitrary = fromBitmap <$> arbitrary | ||
11 | |||
12 | spec :: Spec | ||
13 | spec = return () \ No newline at end of file | ||
diff --git a/tests/Network/BitTorrent/Exchange/ConnectionSpec.hs b/tests/Network/BitTorrent/Exchange/ConnectionSpec.hs index c21f55ef..d654cda1 100644 --- a/tests/Network/BitTorrent/Exchange/ConnectionSpec.hs +++ b/tests/Network/BitTorrent/Exchange/ConnectionSpec.hs | |||
@@ -8,8 +8,7 @@ import Test.Hspec | |||
8 | import Test.QuickCheck | 8 | import Test.QuickCheck |
9 | 9 | ||
10 | import Data.Torrent | 10 | import Data.Torrent |
11 | import Data.Torrent.InfoHash | 11 | import Network.BitTorrent.Address |
12 | import Network.BitTorrent.Core | ||
13 | import Network.BitTorrent.Exchange.Connection | 12 | import Network.BitTorrent.Exchange.Connection |
14 | import Network.BitTorrent.Exchange.Message | 13 | import Network.BitTorrent.Exchange.Message |
15 | 14 | ||
diff --git a/tests/Network/BitTorrent/Exchange/Session/MetadataSpec.hs b/tests/Network/BitTorrent/Exchange/DownloadSpec.hs index 975ceb5b..d46f2034 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 |
@@ -7,11 +7,10 @@ import Test.Hspec | |||
7 | import Test.QuickCheck | 7 | import Test.QuickCheck |
8 | 8 | ||
9 | import Data.BEncode as BE | 9 | import Data.BEncode as BE |
10 | import Data.Torrent | 10 | import Data.Torrent as Torrent |
11 | import Data.Torrent.Piece as P | 11 | import Network.BitTorrent.Address |
12 | import Network.BitTorrent.Core | 12 | import Network.BitTorrent.Exchange.Download |
13 | import Network.BitTorrent.Exchange.Message | 13 | import Network.BitTorrent.Exchange.Message |
14 | import Network.BitTorrent.Exchange.Session.Metadata | ||
15 | 14 | ||
16 | import Config | 15 | import Config |
17 | import Network.BitTorrent.CoreSpec () | 16 | import Network.BitTorrent.CoreSpec () |
@@ -25,27 +24,16 @@ chunkBy s bs | |||
25 | | BS.null bs = [] | 24 | | BS.null bs = [] |
26 | | otherwise = BS.take s bs : chunkBy s (BS.drop s bs) | 25 | | otherwise = BS.take s bs : chunkBy s (BS.drop s bs) |
27 | 26 | ||
28 | withUpdates :: Updates a -> IO a | 27 | withUpdates :: Updates s a -> IO a |
29 | withUpdates m = do | 28 | withUpdates m = do |
30 | Torrent {..} <- getTestTorrent | 29 | Torrent {..} <- getTestTorrent |
31 | let infoDictLen = fromIntegral $ BL.length $ BE.encode tInfoDict | 30 | let infoDictLen = fromIntegral $ BL.length $ BE.encode tInfoDict |
32 | mvar <- newMVar (nullStatus infoDictLen) | 31 | --mvar <- newMVar (nullStatus infoDictLen) |
33 | runUpdates mvar placeholderAddr m | 32 | --runUpdates mvar placeholderAddr m |
33 | undefined | ||
34 | 34 | ||
35 | simulateFetch :: InfoDict -> Updates (Maybe InfoDict) | 35 | simulateFetch :: InfoDict -> Updates s (Maybe InfoDict) |
36 | simulateFetch dict = go | 36 | simulateFetch dict = undefined |
37 | where | ||
38 | blocks = chunkBy metadataPieceSize (BL.toStrict (BE.encode dict)) | ||
39 | packPiece ix = P.Piece ix (blocks !! ix) | ||
40 | ih = idInfoHash dict | ||
41 | |||
42 | go = do | ||
43 | mix <- scheduleBlock | ||
44 | case mix of | ||
45 | Nothing -> return Nothing | ||
46 | Just ix -> do | ||
47 | mdict <- pushBlock (packPiece ix) ih | ||
48 | maybe go (return . Just) mdict | ||
49 | 37 | ||
50 | spec :: Spec | 38 | spec :: Spec |
51 | spec = do | 39 | spec = do |
diff --git a/tests/Network/BitTorrent/Exchange/MessageSpec.hs b/tests/Network/BitTorrent/Exchange/MessageSpec.hs index 63d814ff..d615b1ff 100644 --- a/tests/Network/BitTorrent/Exchange/MessageSpec.hs +++ b/tests/Network/BitTorrent/Exchange/MessageSpec.hs | |||
@@ -10,10 +10,10 @@ import Data.String | |||
10 | import Test.Hspec | 10 | import Test.Hspec |
11 | import Test.QuickCheck | 11 | import Test.QuickCheck |
12 | 12 | ||
13 | import Data.Torrent.BitfieldSpec () | 13 | import Data.TorrentSpec () |
14 | import Data.Torrent.InfoHashSpec () | 14 | import Network.BitTorrent.Exchange.BitfieldSpec () |
15 | import Network.BitTorrent.CoreSpec () | 15 | import Network.BitTorrent.CoreSpec () |
16 | import Network.BitTorrent.Core () | 16 | import Network.BitTorrent.Address () |
17 | import Network.BitTorrent.Exchange.BlockSpec () | 17 | import Network.BitTorrent.Exchange.BlockSpec () |
18 | import Network.BitTorrent.Exchange.Message | 18 | import Network.BitTorrent.Exchange.Message |
19 | 19 | ||
diff --git a/tests/Network/BitTorrent/Exchange/SessionSpec.hs b/tests/Network/BitTorrent/Exchange/SessionSpec.hs index c2c76644..bf5b95a1 100644 --- a/tests/Network/BitTorrent/Exchange/SessionSpec.hs +++ b/tests/Network/BitTorrent/Exchange/SessionSpec.hs | |||
@@ -3,7 +3,7 @@ module Network.BitTorrent.Exchange.SessionSpec (spec) where | |||
3 | import Test.Hspec | 3 | import Test.Hspec |
4 | 4 | ||
5 | import Data.Torrent | 5 | import Data.Torrent |
6 | import Network.BitTorrent.Core | 6 | import Network.BitTorrent.Address |
7 | import Network.BitTorrent.Exchange.Session | 7 | import Network.BitTorrent.Exchange.Session |
8 | 8 | ||
9 | import Config | 9 | import Config |