-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move common
{coarbitrary,gen,shrink}WalletUTxO
functions to `CoinSe…
…lection.Gen`.
- Loading branch information
1 parent
9e99da9
commit 28dabdd
Showing
7 changed files
with
75 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Cardano.Wallet.CoinSelection.Gen | ||
( coarbitraryWalletUTxO | ||
, genWalletUTxO | ||
, genWalletUTxOFunction | ||
, genWalletUTxOLargeRange | ||
, shrinkWalletUTxO | ||
) | ||
where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.CoinSelection | ||
( WalletUTxO (..) ) | ||
import Cardano.Wallet.Primitive.Types.Address.Gen | ||
( genAddress, shrinkAddress ) | ||
import Cardano.Wallet.Primitive.Types.Tx.Gen | ||
( genTxIn, genTxInLargeRange, shrinkTxIn ) | ||
import Generics.SOP | ||
( NP (..) ) | ||
import Test.QuickCheck | ||
( Gen, coarbitrary ) | ||
import Test.QuickCheck.Extra | ||
( genFunction, genSized2, genericRoundRobinShrink, (<:>), (<@>) ) | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Wallet UTxO identifiers chosen according to the size parameter | ||
-------------------------------------------------------------------------------- | ||
|
||
coarbitraryWalletUTxO :: WalletUTxO -> Gen a -> Gen a | ||
coarbitraryWalletUTxO = coarbitrary . show | ||
|
||
genWalletUTxO :: Gen WalletUTxO | ||
genWalletUTxO = uncurry WalletUTxO <$> genSized2 genTxIn genAddress | ||
|
||
shrinkWalletUTxO :: WalletUTxO -> [WalletUTxO] | ||
shrinkWalletUTxO = genericRoundRobinShrink | ||
<@> shrinkTxIn | ||
<:> shrinkAddress | ||
<:> Nil | ||
|
||
genWalletUTxOFunction :: Gen a -> Gen (WalletUTxO -> a) | ||
genWalletUTxOFunction = genFunction coarbitraryWalletUTxO | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Wallet UTxO identifiers chosen from a large range | ||
-------------------------------------------------------------------------------- | ||
|
||
genWalletUTxOLargeRange :: Gen WalletUTxO | ||
genWalletUTxOLargeRange = WalletUTxO <$> genTxInLargeRange <*> genAddress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.