Skip to content

Commit

Permalink
Update genDecrement to also have sometimes empty commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jul 19, 2024
1 parent e62bd80 commit b21215d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import Hydra.Snapshot (
genConfirmedSnapshot,
getSnapshot,
)
import Test.QuickCheck (choose, oneof, vector)
import Test.QuickCheck (choose, frequency, oneof, suchThat, vector)
import Test.QuickCheck.Gen (elements)
import Test.QuickCheck.Modifiers (Positive (Positive))

Expand Down Expand Up @@ -1023,10 +1023,18 @@ genCommits' genUTxO ctx txInit = do
valueFromList . map (\(an, Quantity q) -> (an, Quantity $ q `div` fromIntegral x)) . valueToList

genCommitFor :: VerificationKey PaymentKey -> Gen UTxO
genCommitFor = genOneUTxOFor
genCommitFor vkey =
frequency
[ (1, pure mempty)
, (10, genOneUTxOFor vkey)
]

genCommit :: Gen UTxO
genCommit = genVerificationKey >>= genOneUTxOFor
genCommit =
frequency
[ (1, pure mempty)
, (10, genVerificationKey >>= genOneUTxOFor)
]

genCollectComTx :: Gen (ChainContext, [UTxO], InitialState, Tx)
genCollectComTx = do
Expand All @@ -1043,7 +1051,7 @@ genCollectComTx = do
genDecrementTx :: Int -> Gen (ChainContext, [TxOut CtxUTxO], OpenState, Tx)
genDecrementTx numParties = do
ctx <- genHydraContextFor numParties
(u0, stOpen@OpenState{headId}) <- genStOpen ctx
(u0, stOpen@OpenState{headId}) <- genStOpen ctx `suchThat` \(u, _) -> not (null u)
cctx <- pickChainContext ctx
let (confirmedUtxo, toDecommit) = splitUTxO u0
let version = 0
Expand Down

0 comments on commit b21215d

Please sign in to comment.