Skip to content

Commit

Permalink
Add coverage checks for minted and burned assets in `prop_performSele…
Browse files Browse the repository at this point in the history
…ction_small`.
  • Loading branch information
jonathanknowles committed Jul 7, 2021
1 parent 693e879 commit 7e208a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ data SelectionCriteria = SelectionCriteria
-- algorithm, requiring it to select more UTxO entries in order to
-- cover the burn.
}
deriving (Eq, Show)
deriving (Eq, Generic, Show)

-- | A skeleton selection that can be used to estimate the cost of a final
-- selection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ prop_performSelection_small minCoinValueFor costFor (Blind (Small criteria)) =
"No assets to cover" $
cover 2 (outputsHaveAtLeastOneAsset && not utxoHasAtLeastOneAsset)
"Assets to cover, but no assets in UTxO" $
cover 2 (someMintedAssetsAreBurned)
"Some minted assets are burned" $
cover 2 (noMintedAssetsAreBurned)
"No minted assets are burned" $
prop_performSelection minCoinValueFor costFor (Blind criteria) $ \result ->
cover 10 (selectionUnlimited && selectionSufficient result)
"selection unlimited and sufficient"
Expand Down Expand Up @@ -714,6 +718,20 @@ prop_performSelection_small minCoinValueFor costFor (Blind (Small criteria)) =
Left (SelectionInsufficient _) -> True
_ -> False

someMintedAssetsAreBurned :: Bool
someMintedAssetsAreBurned
= TokenMap.isNotEmpty
$ TokenMap.intersection
(view #assetsToMint criteria)
(view #assetsToBurn criteria)

noMintedAssetsAreBurned :: Bool
noMintedAssetsAreBurned
= TokenMap.isEmpty
$ TokenMap.intersection
(view #assetsToMint criteria)
(view #assetsToBurn criteria)

prop_performSelection_large
:: MinCoinValueFor
-> CostFor
Expand Down

0 comments on commit 7e208a0

Please sign in to comment.