diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-03 03:11:45 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-03-03 03:11:45 +0400 |
commit | 33549b27af5c4686ffe6a216d32af164dda33cd3 (patch) | |
tree | 8c543f2a7c115e72db4e258ee37b890c3cdadb71 /tests/Config.hs | |
parent | 863f7a236b86f562309748273f3087035a999ee7 (diff) |
Uncomment session spec
Diffstat (limited to 'tests/Config.hs')
-rw-r--r-- | tests/Config.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/Config.hs b/tests/Config.hs index 3dea6603..b37b727b 100644 --- a/tests/Config.hs +++ b/tests/Config.hs | |||
@@ -11,8 +11,12 @@ module Config | |||
11 | -- * For item specs | 11 | -- * For item specs |
12 | , getEnvOpts | 12 | , getEnvOpts |
13 | , getThisOpts | 13 | , getThisOpts |
14 | , getMyAddr | ||
15 | |||
14 | , getRemoteOpts | 16 | , getRemoteOpts |
15 | , withRemote | 17 | , withRemote |
18 | , withRemoteAddr | ||
19 | |||
16 | , getTestTorrent | 20 | , getTestTorrent |
17 | ) where | 21 | ) where |
18 | 22 | ||
@@ -29,6 +33,7 @@ import System.IO.Unsafe | |||
29 | import Test.Hspec | 33 | import Test.Hspec |
30 | 34 | ||
31 | import Data.Torrent | 35 | import Data.Torrent |
36 | import Network.BitTorrent.Core (IP, PeerAddr (PeerAddr), genPeerId) | ||
32 | 37 | ||
33 | 38 | ||
34 | type ClientName = String | 39 | type ClientName = String |
@@ -138,6 +143,17 @@ withRemote action = do | |||
138 | Nothing -> pendingWith "Remote client isn't running" | 143 | Nothing -> pendingWith "Remote client isn't running" |
139 | Just opts -> action opts | 144 | Just opts -> action opts |
140 | 145 | ||
146 | withRemoteAddr :: (PeerAddr IP -> Expectation) -> Expectation | ||
147 | withRemoteAddr action = do | ||
148 | withRemote $ \ ClientOpts {..} -> | ||
149 | action (PeerAddr Nothing "0.0.0.0" peerPort) | ||
150 | |||
151 | getMyAddr :: IO (PeerAddr (Maybe IP)) | ||
152 | getMyAddr = do | ||
153 | ClientOpts {..} <- getThisOpts | ||
154 | pid <- genPeerId | ||
155 | return $ PeerAddr (Just pid) Nothing peerPort | ||
156 | |||
141 | getTestTorrent :: IO Torrent | 157 | getTestTorrent :: IO Torrent |
142 | getTestTorrent = do | 158 | getTestTorrent = do |
143 | EnvOpts {..} <- getEnvOpts | 159 | EnvOpts {..} <- getEnvOpts |