From 57c07536dd59595ec4cbcce24f0e6352e99a82c6 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sat, 15 Mar 2014 19:02:23 +0400 Subject: Add exchange session spec stubs --- tests/Network/BitTorrent/Exchange/SessionSpec.hs | 66 +++++++++++++++++------- 1 file changed, 47 insertions(+), 19 deletions(-) (limited to 'tests/Network/BitTorrent/Exchange/SessionSpec.hs') 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 nullLogger :: LogFun nullLogger _ _ x _ = print x +simpleSession :: InfoDict -> (Session -> IO ()) -> IO () +simpleSession dict action = do + withRemoteAddr $ \ addr -> do + myAddr <- getMyAddr + ses <- newSession nullLogger myAddr "" dict + connect addr ses + action ses + closeSession ses + spec :: Spec spec = do - describe "metadata exchange" $ do - it "should fetch info dictionary" $ do - withRemoteAddr $ \ addr -> 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 - myAddr <- getMyAddr - ses <- newSession nullLogger myAddr "" tInfoDict - connect addr ses - dict <- waitMetadata ses - closeSession ses - dict `shouldBe` tInfoDict - - it "should serve info dictionary" $ do - pending - - describe "content exchange" $ do - it "should fetch torrent content" $ do - pending - - it "should serve torrent content" $ do - pending + 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 -- cgit v1.2.3