diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-15 19:02:23 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-15 19:02:23 +0400 |
commit | 57c07536dd59595ec4cbcce24f0e6352e99a82c6 (patch) | |
tree | 6c378dadb4625ba20bdde87153d0f30d99afe8d1 /tests/Network | |
parent | e80c53754833a0c37e318bf1ba10847e21d1d980 (diff) |
Add exchange session spec stubs
Diffstat (limited to 'tests/Network')
-rw-r--r-- | tests/Network/BitTorrent/Exchange/SessionSpec.hs | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/tests/Network/BitTorrent/Exchange/SessionSpec.hs b/tests/Network/BitTorrent/Exchange/SessionSpec.hs index f80fc864..0eec8f41 100644 --- a/tests/Network/BitTorrent/Exchange/SessionSpec.hs +++ b/tests/Network/BitTorrent/Exchange/SessionSpec.hs | |||
@@ -12,25 +12,53 @@ import Config | |||
12 | nullLogger :: LogFun | 12 | nullLogger :: LogFun |
13 | nullLogger _ _ x _ = print x | 13 | nullLogger _ _ x _ = print x |
14 | 14 | ||
15 | simpleSession :: InfoDict -> (Session -> IO ()) -> IO () | ||
16 | simpleSession dict action = do | ||
17 | withRemoteAddr $ \ addr -> do | ||
18 | myAddr <- getMyAddr | ||
19 | ses <- newSession nullLogger myAddr "" dict | ||
20 | connect addr ses | ||
21 | action ses | ||
22 | closeSession ses | ||
23 | |||
15 | spec :: Spec | 24 | spec :: Spec |
16 | spec = do | 25 | spec = do |
17 | describe "metadata exchange" $ do | 26 | describe "construction" $ do |
18 | it "should fetch info dictionary" $ do | 27 | describe "newSession" $ do |
19 | withRemoteAddr $ \ addr -> do | 28 | it "" $ do |
29 | pending | ||
30 | |||
31 | describe "closeSession" $ do | ||
32 | it "" $ do | ||
33 | pending | ||
34 | |||
35 | describe "connection set" $ do | ||
36 | describe "connect" $ do | ||
37 | it "" $ do | ||
38 | pending | ||
39 | |||
40 | describe "establish" $ do | ||
41 | it "" $ do | ||
42 | pending | ||
43 | |||
44 | describe "exchange" $ do | ||
45 | describe "metadata" $ do | ||
46 | it "should fetch info dictionary" $ do | ||
20 | Torrent {..} <- getTestTorrent | 47 | Torrent {..} <- getTestTorrent |
21 | myAddr <- getMyAddr | 48 | simpleSession tInfoDict $ \ ses -> do |
22 | ses <- newSession nullLogger myAddr "" tInfoDict | 49 | dict <- waitMetadata ses |
23 | connect addr ses | 50 | dict `shouldBe` tInfoDict |
24 | dict <- waitMetadata ses | 51 | |
25 | closeSession ses | 52 | it "should serve info dictionary" $ do |
26 | dict `shouldBe` tInfoDict | 53 | pending |
27 | 54 | ||
28 | it "should serve info dictionary" $ do | 55 | describe "content" $ do |
29 | pending | 56 | it "should fetch torrent content" $ do |
30 | 57 | Torrent {..} <- getTestTorrent | |
31 | describe "content exchange" $ do | 58 | simpleSession tInfoDict $ \ ses -> do |
32 | it "should fetch torrent content" $ do | 59 | pending |
33 | pending | 60 | -- st <- waitData ses |
34 | 61 | -- verifyStorage st (idPieceInfo tInfoDict) | |
35 | it "should serve torrent content" $ do | 62 | |
36 | pending | 63 | it "should serve torrent content" $ do |
64 | pending | ||