Skip to content

Commit ad743f9

Browse files
committed
Add module description
1 parent a3792fe commit ad743f9

File tree

1 file changed

+17
-10
lines changed
  • ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/GSM

1 file changed

+17
-10
lines changed

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/GSM/QD.hs

+17-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717

1818
{-# OPTIONS_GHC -Wno-orphans #-}
1919

20-
-- | Tests for the Genesis State Machine using the quickcheck-dynamic library
21-
20+
-- | Tests for the Genesis State Machine using the [quickcheck-dynamic](https://hackage.haskell.org/package/quickcheck-dynamic) library.
21+
--
22+
-- The instance 'QD.StateModel (Model params)' describes the actions that the model supports,
23+
-- and their semantics in terms for the model and the system-under-test.
24+
--
25+
-- We use the [reflection](https://hackage.haskell.org/package/reflection) library to solve the problem of
26+
-- injecting user-supplied or quickcheck-generated values into the instance of QD.StateModel.
27+
-- See the definition of the 'initialState' method, where we access the reflected configuration, and
28+
-- see 'prop_sequential_iosim' for the construction and reification of the configuration.
2229
module Test.Consensus.GSM.QD (tests) where
2330

2431
import Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked
@@ -63,10 +70,10 @@ tests = adhoc <> core
6370
adhoc = [ testProperty "GSM yield regression" prop_yield_regression
6471
]
6572
core = [
66-
adjustQuickCheckTests (* 10) $
67-
testProperty ("GSM (" <> coreTestName upstreamPeerBound <> ")") $
68-
prop_sequential_iosim upstreamPeerBound
69-
| upstreamPeerBound <- Nothing : map Just [minBound .. maxBound :: UpstreamPeer]
73+
adjustQuickCheckTests (* 10)
74+
$ testProperty ("GSM (" <> coreTestName upstreamPeerBound <> ")")
75+
$ prop_sequential_iosim upstreamPeerBound
76+
| upstreamPeerBound <- Nothing : map Just [minBound .. maxBound :: UpstreamPeer]
7077
]
7178

7279
coreTestName = \case
@@ -97,14 +104,14 @@ prop_yield_regression =
97104
<> (wrapPositiveAction $ ExtendSelection (S (-4)))
98105
<> (wrapPositiveAction $ ReadMarker)
99106

100-
prop_sequential_iosim :: Maybe UpstreamPeer -> QC.Property
101-
prop_sequential_iosim pUpstreamPeerBound =
102-
QC.forAll QC.arbitrary $ \pInitialJudgement ->
103-
QC.forAll QC.arbitrary $ \(QC.Fun _ pIsHaaSatisfied) ->
107+
prop_sequential_iosim :: Maybe UpstreamPeer -> LedgerStateJudgement -> QC.Fun (Set.Set UpstreamPeer) Bool -> QC.Property
108+
prop_sequential_iosim pUpstreamPeerBound pInitialJudgement (QC.Fun _ pIsHaaSatisfied) =
104109
Reflection.reify (StaticParams{ pUpstreamPeerBound
105110
, pInitialJudgement
106111
, pIsHaaSatisfied
107112
}) $ \(Proxy :: Proxy params) ->
113+
-- NOTE: the actions have to be generated with an explicit call, as
114+
-- 'generator' relies on reflection for access to the parameters
108115
QC.forAll QC.arbitrary $ \actions ->
109116
runIOSimProp $ prop_sequential_iosim1 @_ @params actions
110117

0 commit comments

Comments
 (0)