-- check 2: non-ADA inputs and non-ADA outputs cancel each other out
tokIns <> negateValue tokOuts `shouldBe` mempty
Left selFailedMsg -> counterexample ("selection failed: " <> selFailedMsg) False
describe "findMinUtxo" do
first (\message -> show (message :: ConstraintError 'V1))
$ findMinUtxo protocolTestnet (inAddress, fromCardanoScriptData <$> inDatum, inValue)
pure $ (inDatum, outValue) `shouldBe` (inDatum, expected)
describe "ensureMinUtxo" do
prop "non-lovelace value is unchanged" do
, payoutOutputs = Map.empty
-
-- Generate a random amount and add the specified amount of Lovelace to it
-
genAdaOnlyAssets :: Integer -> Chain.Assets
-
genAdaOnlyAssets maxLovelace = Chain.Assets
-
(fromCardanoLovelace $ Lovelace maxLovelace)
+
-- Convenience function to build a chain Assets with the specified amount of only ADA
+
mkAdaOnlyAssets :: Integer -> Chain.Assets
+
mkAdaOnlyAssets lovelace = Chain.Assets
+
(fromCardanoLovelace $ Lovelace lovelace)
+
-- Generate a random amount and add the specified amount of Lovelace to it
+
genAtLeastThisMuchAda :: Integer -> Gen Chain.Assets
+
genAtLeastThisMuchAda minLovelace = do
+
additionalLovelaceValue <- suchThat arbitrary (>= 0)
+
pure . mkAdaOnlyAssets $ minLovelace + additionalLovelaceValue
-- The simplest wallet context:
-- availableUtxos = A single ADA-only Utxo
-- collateralUtxos = A set containing the one Utxo from above
wc <- genWalletContext marloweVersion constraints
+
assets <- genAtLeastThisMuchAda minLovelace
-
assets = genAdaOnlyAssets minLovelace
txOut = Chain.TransactionOutput stubAddress assets Nothing Nothing
utxos = Chain.UTxOs $ Map.singleton txOutRef txOut
pure $ wc { availableUtxos = utxos, collateralUtxos = Set.singleton txOutRef }