Skip to content

Commit

Permalink
Add generators and shrinkers for type UTxOSelection.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Sep 24, 2021
1 parent ea666e7 commit 2afd9e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/core/cardano-wallet-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ library
Cardano.Wallet.Primitive.Types.Tx.Gen
Cardano.Wallet.Primitive.Types.UTxO.Gen
Cardano.Wallet.Primitive.Types.UTxOIndex.Gen
Cardano.Wallet.Primitive.Types.UTxOSelection.Gen
Cardano.Wallet.Gen
other-modules:
Paths_cardano_wallet_core
Expand Down
30 changes: 30 additions & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Types/UTxOSelection/Gen.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Cardano.Wallet.Primitive.Types.UTxOSelection.Gen
( genUTxOSelection
, shrinkUTxOSelection
)
where

import Prelude

import Cardano.Wallet.Primitive.Types.Tx
( TxIn )
import Cardano.Wallet.Primitive.Types.UTxOIndex.Gen
( genUTxOIndex, shrinkUTxOIndex )
import Cardano.Wallet.Primitive.Types.UTxOSelection
( UTxOSelection )
import Test.QuickCheck
( Gen, liftShrink2, shrinkMapBy )

import qualified Cardano.Wallet.Primitive.Types.UTxOSelection as UTxOSelection

genUTxOSelection :: (TxIn -> Bool) -> Gen UTxOSelection
genUTxOSelection f = UTxOSelection.fromIndexFiltered
<$> genUTxOIndex
<*> pure f

shrinkUTxOSelection :: UTxOSelection -> [UTxOSelection]
shrinkUTxOSelection =
shrinkMapBy UTxOSelection.fromIndexPair UTxOSelection.toIndexPair $
liftShrink2
shrinkUTxOIndex
shrinkUTxOIndex

0 comments on commit 2afd9e8

Please sign in to comment.