-
Notifications
You must be signed in to change notification settings - Fork 86
/
Testnet.hs
56 lines (45 loc) · 1.74 KB
/
Testnet.hs
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
{-# LANGUAGE RankNTypes #-}
module Test.Ouroboros.Network.Testnet (tests) where
import Control.Monad.IOSim
import Data.List (intercalate)
import Data.Void (Void)
import Ouroboros.Network.Testing.Data.AbsBearerInfo
(AbsBearerInfo (..), attenuation, delay, toSduSize)
import Simulation.Network.Snocket (BearerInfo (..))
import Test.Ouroboros.Network.Testnet.Simulation.Node
(DiffusionScript, diffusion_simulation)
import Test.QuickCheck (Property, counterexample)
import Test.Tasty
import Test.Tasty.QuickCheck (testProperty)
tests :: TestTree
tests =
testGroup "Ouroboros.Network.Testnet"
[ testGroup "multinodeSim"
[ testProperty "test"
test
]
]
test :: AbsBearerInfo
-> DiffusionScript
-> Property
test defaultBearerInfo dmnScript =
let trace = traceEvents
$ runSimTrace sim
in counterexample (intercalate "\n"
$ map show
$ take 1000 trace)
True
where
sim :: forall s . IOSim s Void
sim = diffusion_simulation (toBearerInfo defaultBearerInfo) dmnScript
toBearerInfo :: AbsBearerInfo -> BearerInfo
toBearerInfo abi =
BearerInfo {
biConnectionDelay = delay (abiConnectionDelay abi),
biInboundAttenuation = attenuation (abiInboundAttenuation abi),
biOutboundAttenuation = attenuation (abiOutboundAttenuation abi),
biInboundWriteFailure = abiInboundWriteFailure abi,
biOutboundWriteFailure = abiOutboundWriteFailure abi,
biAcceptFailures = Nothing, -- TODO
biSDUSize = toSduSize (abiSDUSize abi)
}