Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 7, 2024
1 parent bf2055e commit 23b5d55
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ import Test.QuickCheck
)
import Test.QuickCheck.Extra
( genMapFromKeysWith
, genMapWith
, genNonEmptyDisjointMap
, shrinkMapToSubmaps
)

import qualified Data.Map.Strict as Map
import qualified Internal.Cardano.Write.Tx.TxWithUTxO as TxWithUTxO

-- | Generates a 'TxWithUTxO' object.
Expand Down Expand Up @@ -86,7 +85,7 @@ generateWithMinimalUTxO genTx _genTxIn genTxOut = do
where
txInputs = view (bodyTxL . allInputsTxBodyF)

-- | Generates a 'TxWithUTxO' object that has a non-minimal UTxO set.
-- | Generates a 'TxWithUTxO' object that has a surplus UTxO set.
--
-- The domain of the UTxO map is a strict superset of the transaction input set.
--
Expand All @@ -99,14 +98,9 @@ generateWithSurplusUTxO
-> Gen (TxWithUTxO era)
generateWithSurplusUTxO genTx genTxIn genTxOut =
generateWithMinimalUTxO genTx genTxIn genTxOut >>= \case
TxWithUTxO tx minimalUTxO -> do
surplusUTxO <- genNonEmptyUTxO
pure $ TxWithUTxO.constructFiltered tx (minimalUTxO <> surplusUTxO)
where
genNonEmptyUTxO :: Gen (UTxO era)
genNonEmptyUTxO
= fmap UTxO
$ Map.insert <$> genTxIn <*> genTxOut <*> genMapWith genTxIn genTxOut
TxWithUTxO tx (UTxO utxo) -> do
utxoSurplus <- genNonEmptyDisjointMap genTxIn genTxOut utxo
pure $ TxWithUTxO.constructFiltered tx $ UTxO (utxo <> utxoSurplus)

-- TODO: Parameterise this by `Tx era -> [Tx era]` shrinker.
shrink :: IsRecentEra era => TxWithUTxO era -> [TxWithUTxO era]
Expand Down

0 comments on commit 23b5d55

Please sign in to comment.