blob: 30abc8670f95712096efc5127970e5b6f3e46be2 (
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
|
module Network.BitTorrent.DHTSpec (spec) where
import Control.Exception
import Control.Monad
import Data.Default
import Data.List as L
import Test.Hspec
import System.Timeout
import Data.Torrent
import Network.BitTorrent.DHT
partialBootstrapTimeout :: Int
partialBootstrapTimeout = 10 * 1000000
opts :: Options
opts = def { optBucketCount = 1 }
-- NOTE to shorten test cases run time include only "good" infohashes
-- with many nodes
existingInfoHashes :: [InfoHash]
existingInfoHashes =
[
]
-- TODO use Test.Hspec.parallel
spec :: Spec
spec = do
describe "bootstrapping" $ do
it "should resolve all default bootstrap nodes" $ do
nodes <- forM defaultBootstrapNodes resolveHostName
_ <- evaluate nodes
return ()
it "partial bootstrapping should finish in less than 10 seconds" $ do
node <- resolveHostName (L.head defaultBootstrapNodes)
res <- timeout partialBootstrapTimeout $ do
dht opts def $ do
bootstrap [node]
isBootstrapped
res `shouldBe` Just True
describe "initialization" $ do
it "should be bootstrapped after restore process" $ do
pending
describe "lookup" $ do
describe "for any existing infohash" $ do
forM_ existingInfoHashes $ \ ih -> do
context (show ih) $ do
it "should find peers" $ do
pending
describe "insert" $ do
it "should return this peer if announced" $ do
pending
describe "delete" $ do
return ()
|