Skip to content

Commit 9ac3f77

Browse files
committed
Improve generation of inputs in NodeSpec
1 parent 58a7501 commit 9ac3f77

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

hydra-node/test/Hydra/NodeSpec.hs

+11-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import Hydra.Options (defaultContestationPeriod)
4242
import Hydra.Party (Party, deriveParty)
4343
import Hydra.Persistence (PersistenceIncremental (..), eventPairFromPersistenceIncremental)
4444
import Test.Hydra.Fixture (alice, aliceSk, bob, bobSk, carol, carolSk, cperiod, deriveOnChainId, testEnvironment, testHeadId, testHeadSeed)
45-
import Test.QuickCheck (classify, counterexample, elements, forAllBlind, forAllShrink, forAllShrinkBlind, idempotentIOProperty, listOf, listOf1, (==>))
45+
import Test.QuickCheck (classify, counterexample, elements, forAllBlind, forAllShrink, forAllShrinkBlind, idempotentIOProperty, listOf, listOf1, resize, (==>))
4646
import Test.Util (isStrictlyMonotonic)
4747

4848
spec :: Spec
@@ -112,16 +112,19 @@ spec = parallel $ do
112112
getMockSinkEvents2 `shouldReturn` events
113113

114114
it "event ids are strictly monotonic" $ \dryNode -> do
115-
forAllShrinkBlind arbitrary shrink $ \someInputs ->
115+
-- NOTE: Arbitrary inputs in open head state results more likely in
116+
-- multiple state change events per input (during tx processing).
117+
let genInputs = do
118+
-- Resize to reducing complexity of additional input contents
119+
someInput <- resize 1 arbitrary
120+
pure $ inputsToOpenHead <> [someInput]
121+
122+
forAllShrinkBlind genInputs shrink $ \someInputs ->
116123
idempotentIOProperty $ do
117124
(sink, getSinkEvents) <- createRecordingSink
118-
119125
hydrate (mockSource []) [sink] dryNode
120126
>>= notConnect
121-
-- NOTE: Arbitrary inputs in open head state results more likely
122-
-- in multiple state change events per input (during tx
123-
-- processing).
124-
>>= primeWith (inputsToOpenHead <> someInputs)
127+
>>= primeWith someInputs
125128
>>= runToCompletion
126129

127130
events <- getSinkEvents
@@ -131,7 +134,7 @@ spec = parallel $ do
131134
& counterexample "Not strictly monotonic"
132135
& counterexample ("Event ids: " <> show eventIds)
133136
& counterexample ("Events: " <> show events)
134-
& counterexample ("Additional inputs: " <> show someInputs)
137+
& counterexample ("Inputs: " <> show someInputs)
135138
& classify (null eventIds) "empty list of events"
136139

137140
it "can continue after re-hydration" $ \dryNode ->

0 commit comments

Comments
 (0)