Skip to content

Commit

Permalink
Small tuning on generators
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Oct 10, 2024
1 parent 740c088 commit 642bd24
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions hydra-node/test/Hydra/Chain/Direct/TxTraceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import Test.Hydra.Tx.Gen (
genVerificationKey,
)
import Test.Hydra.Tx.Mutation (addParticipationTokens)
import Test.QuickCheck (Property, Smart (..), Testable, checkCoverage, choose, cover, elements, frequency, ioProperty, oneof, sublistOf, (===))
import Test.QuickCheck (Property, Smart (..), Testable, checkCoverage, choose, cover, elements, frequency, ioProperty, sublistOf, (===))
import Test.QuickCheck.Monadic (monadic)
import Test.QuickCheck.StateModel (
ActionWithPolarity (..),
Expand Down Expand Up @@ -184,7 +184,7 @@ prop_runActions actions =
coversInterestingActions actions
. monadic runAppMProperty
$ do
print actions
-- print actions
void (runActions actions)
where
runAppMProperty :: AppM Property -> Property
Expand Down Expand Up @@ -300,42 +300,44 @@ instance StateModel Model where
arbitraryAction _lookup Model{headState, knownSnapshots, currentVersion, utxoInHead, pendingDecommitUTxO} =
case headState of
Open{} ->
oneof $
[Some . NewSnapshot <$> genSnapshot]
<> [ do
actor <- elements allActors
snapshot <- elements knownSnapshots
pure $ Some Decrement{actor, snapshot}
frequency $
[(5, Some . NewSnapshot <$> genSnapshot)]
<> [ ( 10
, do
actor <- elements allActors
snapshot <- elements knownSnapshots
pure $ Some Decrement{actor, snapshot}
)
| not (null knownSnapshots) -- XXX: DRY this check
]
<> [ do
actor <- elements allActors
snapshot <- elements knownSnapshots
pure $ Some $ Close{actor, snapshot = snapshot}
<> [ ( 1
, do
actor <- elements allActors
snapshot <- elements knownSnapshots
pure $ Some $ Close{actor, snapshot = snapshot}
)
| not (null knownSnapshots)
]
Closed{} ->
frequency $
[
( 1
, do
-- Fanout with the currently known model state.
pure $
Some $
Fanout
{ utxo = utxoInHead
, deltaUTxO = pendingDecommitUTxO
}
)
]
<> [ ( 10
, do
( 1
, do
-- Fanout with the currently known model state.
pure $
Some $
Fanout
{ utxo = utxoInHead
, deltaUTxO = pendingDecommitUTxO
}
)
: [ ( 3
, do
actor <- elements allActors
snapshot <- elements knownSnapshots
pure $ Some Contest{actor, snapshot}
)
| not (null knownSnapshots)
]
)
| not (null knownSnapshots)
]
Final -> pure $ Some Stop
where
-- TODO: Generate a snapshot an honest node would sign given the current model state.
Expand Down

0 comments on commit 642bd24

Please sign in to comment.