| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Ouroboros.Network.PeerSelection.PeerMetric
Synopsis
- tests :: TestTree
- newtype TestAddress = TestAddress Int
- data Event
- eventPeer :: Event -> TestAddress
- eventSlot :: Event -> SlotNo
- newtype FixedScript = FixedScript {
- getFixedScript :: Script Event
- mkFixedScript :: Script Event -> FixedScript
- mkTimedScript :: FixedScript -> TimedScript Event
- data PeerMetricsTrace = PeerMetricsTrace {}
- simulatePeerMetricScript :: (MonadDelay m, MonadLabelledSTM m) => Tracer m PeerMetricsTrace -> PeerMetricsConfiguration -> FixedScript -> m ()
- interpretScriptDelay :: ScriptDelay -> DiffTime
- prop_insert_peer :: FixedScript -> Property
- prop_metrics_are_bounded :: FixedScript -> Property
- prop_bounded_size :: Positive Int -> FixedScript -> Property
- microbenchmark1GenerateInput :: Bool -> Int -> IO FixedScript
- microbenchmark1ProcessInput :: FixedScript -> IO ()
- microbenchmark1 :: Bool -> Int -> IO ()
- prop_simScript :: FixedScript -> Property
- simulatePeerMetricScriptWithoutDelays :: MonadLabelledSTM m => Tracer m PeerMetricsTrace -> PeerMetricsConfiguration -> FixedScript -> m ()
Documentation
newtype TestAddress Source #
Constructors
| TestAddress Int |
Instances
Constructors
| FetchedHeader TestAddress SlotNo | |
| FetchedBlock TestAddress SlotNo SizeInBytes |
Instances
eventPeer :: Event -> TestAddress Source #
newtype FixedScript Source #
Constructors
| FixedScript | |
Fields
| |
Instances
| Arbitrary FixedScript Source # | |
| NFData FixedScript Source # | |
Defined in Test.Ouroboros.Network.PeerSelection.PeerMetric Methods rnf :: FixedScript -> () # | |
| Show FixedScript Source # | |
Defined in Test.Ouroboros.Network.PeerSelection.PeerMetric Methods showsPrec :: Int -> FixedScript -> ShowS # show :: FixedScript -> String # showList :: [FixedScript] -> ShowS # | |
mkFixedScript :: Script Event -> FixedScript Source #
Order events by SlotNo
TODO: SizeInBytes should be a function of SlotNo
mkTimedScript :: FixedScript -> TimedScript Event Source #
data PeerMetricsTrace Source #
Constructors
| PeerMetricsTrace | |
Fields | |
Instances
| Show PeerMetricsTrace Source # | |
Defined in Test.Ouroboros.Network.PeerSelection.PeerMetric Methods showsPrec :: Int -> PeerMetricsTrace -> ShowS # show :: PeerMetricsTrace -> String # showList :: [PeerMetricsTrace] -> ShowS # | |
simulatePeerMetricScript :: (MonadDelay m, MonadLabelledSTM m) => Tracer m PeerMetricsTrace -> PeerMetricsConfiguration -> FixedScript -> m () Source #
interpretScriptDelay :: ScriptDelay -> DiffTime Source #
prop_insert_peer :: FixedScript -> Property Source #
Check that newly added peer is never in the 20% worst performing peers (if there are at least 5 results).
prop_metrics_are_bounded :: FixedScript -> Property Source #
Check that the results are always positive.
prop_bounded_size :: Positive Int -> FixedScript -> Property Source #
Check that the result are bounded.
The bound is maxEntriesToTrack times number of peers in the simulation.
This could be lowered by computing number of peers in each
maxEntriesToTrack slots window.
microbenchmark1GenerateInput :: Bool -> Int -> IO FixedScript Source #
microbenchmark1 n - one test of simple property on a FixedScript of length n: one input, one property, one test.
We split into generating input and running/checking it so we can more accurately measure the latter.
we shouldn't use QuickCheck
and we shouldn't use IOSim (which prop_simScript) is using.
microbenchmark1ProcessInput :: FixedScript -> IO () Source #
prop_simScript :: FixedScript -> Property Source #
one simple property (pmtUpstreamyness >= 0) checked on the trace of a script:
simulatePeerMetricScriptWithoutDelays :: MonadLabelledSTM m => Tracer m PeerMetricsTrace -> PeerMetricsConfiguration -> FixedScript -> m () Source #
similar to simulatePeerMetricScript: but we don't do in
"real/simulated" time: not calling getMonotonicTime and
threadDelay.