blob: bf5b95a13a44a8d0887523f0ae03fde259b7022e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
{-# LANGUAGE RecordWildCards #-}
module Network.BitTorrent.Exchange.SessionSpec (spec) where
import Test.Hspec
import Data.Torrent
import Network.BitTorrent.Address
import Network.BitTorrent.Exchange.Session
import Config
nullLogger :: LogFun
nullLogger _ _ x _ = print x
simpleSession :: InfoDict -> (Session -> IO ()) -> IO ()
simpleSession dict action = do
withRemoteAddr $ \ addr -> do
myAddr <- getMyAddr
ses <- newSession nullLogger myAddr "" (Right dict)
connect addr ses
action ses
closeSession ses
spec :: Spec
spec = do
describe "construction" $ do
describe "newSession" $ do
it "" $ do
pending
describe "closeSession" $ do
it "" $ do
pending
describe "connection set" $ do
describe "connect" $ do
it "" $ do
pending
describe "establish" $ do
it "" $ do
pending
describe "exchange" $ do
describe "metadata" $ do
it "should fetch info dictionary" $ do
Torrent {..} <- getTestTorrent
simpleSession tInfoDict $ \ ses -> do
dict <- waitMetadata ses
dict `shouldBe` tInfoDict
it "should serve info dictionary" $ do
pending
describe "content" $ do
it "should fetch torrent content" $ do
Torrent {..} <- getTestTorrent
simpleSession tInfoDict $ \ ses -> do
pending
-- st <- waitData ses
-- verifyStorage st (idPieceInfo tInfoDict)
it "should serve torrent content" $ do
pending
|