From e6319b176395ce832be2dbe5b38d10f4c90f7b99 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Wed, 27 Jan 2021 13:37:05 +0100 Subject: [PATCH] update benchmarks & shelley transaction specs to work with new transaction layer. --- .../Scenario/API/Shelley/StakePools.hs | 5 +- lib/core/test/unit/Cardano/WalletSpec.hs | 37 ++- lib/shelley/bench/Restore.hs | 14 +- .../src/Cardano/Wallet/Shelley/Transaction.hs | 4 +- .../Cardano/Wallet/Shelley/TransactionSpec.hs | 211 +++++++++++------- 5 files changed, 161 insertions(+), 110 deletions(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs index f61f115efae..40892d10ffe 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -36,10 +36,9 @@ import Cardano.Wallet.Primitive.AddressDerivation ( PaymentAddress ) import Cardano.Wallet.Primitive.AddressDerivation.Shelley ( ShelleyKey ) -import Cardano.Wallet.Primitive.Fee - ( FeePolicy (..) ) import Cardano.Wallet.Primitive.Types - ( PoolId (..) + ( FeePolicy (..) + , PoolId (..) , PoolMetadataGCStatus (..) , PoolMetadataSource (..) , StakePoolMetadata (..) diff --git a/lib/core/test/unit/Cardano/WalletSpec.hs b/lib/core/test/unit/Cardano/WalletSpec.hs index 9e0da3791d5..e9777dd372f 100644 --- a/lib/core/test/unit/Cardano/WalletSpec.hs +++ b/lib/core/test/unit/Cardano/WalletSpec.hs @@ -120,9 +120,7 @@ import Control.Monad import Control.Monad.IO.Class ( liftIO ) import Control.Monad.Trans.Except - ( ExceptT (..), runExceptT ) -import Control.Monad.Trans.State.Strict - ( State, evalState, state ) + ( runExceptT ) import Crypto.Hash ( hash ) import Data.ByteString @@ -164,7 +162,6 @@ import Test.QuickCheck , arbitrarySizedBoundedIntegral , checkCoverage , choose - , counterexample , cover , elements , label @@ -175,7 +172,6 @@ import Test.QuickCheck , shrinkIntegral , vector , withMaxSuccess - , (.&&.) , (===) , (==>) ) @@ -525,7 +521,7 @@ walletKeyIsReencrypted (wid, wname) (xprv, pwd) newPwd = W.signTransaction @_ @_ wl wid () credentials newPwd ctx selection txOld `shouldBe` txNew where - selection = SelectionResult TxOut + selection = SelectionResult { inputsSelected = NE.fromList [ ( TxIn (Hash "eb4ab6028bd0ac971809d514c92db1") 1 , TxOut (Address "source") (TokenBundle.fromCoin $ Coin 42) @@ -536,7 +532,7 @@ walletKeyIsReencrypted (wid, wname) (xprv, pwd) newPwd = , outputsCovered = [ TxOut (Address "destination") (TokenBundle.fromCoin $ Coin 14) ] , changeGenerated = NE.fromList - [ TxOut (Address "change") (TokenBundle.fromCoin $ Coin 14) ] + [ (TokenBundle.fromCoin $ Coin 1) ] , utxoRemaining = UTxOIndex.empty } @@ -628,13 +624,13 @@ setupFixture (wid, wname, wstate) = do -- implements a fake signer that still produces sort of witnesses dummyTransactionLayer :: TransactionLayer ShelleyKey dummyTransactionLayer = TransactionLayer - { mkStdTx = \_ _ keyFrom _slot _md cs -> do - let inps' = map (second txOutCoin) (CS.inputs cs) - let tid = mkTxId inps' (CS.outputs cs) mempty Nothing - let tx = Tx tid Nothing inps' (CS.outputs cs) mempty Nothing - wit <- forM (CS.inputs cs) $ \(_, TxOut addr _) -> do + { mkTransaction = \_era _stakeCredentials keystore _pp _ctx cs -> do + let inps' = NE.toList $ second txOutCoin <$> inputsSelected cs + let tid = mkTxId inps' (outputsCovered cs) mempty Nothing + let tx = Tx tid Nothing inps' (outputsCovered cs) mempty Nothing + wit <- forM (inputsSelected cs) $ \(_, TxOut addr _) -> do (xprv, Passphrase pwd) <- withEither - (ErrKeyNotFoundForAddress addr) $ keyFrom addr + (ErrKeyNotFoundForAddress addr) $ keystore addr let (Hash sigData) = txId tx let sig = CC.unXSignature $ CC.sign pwd (getKey xprv) sigData return $ xpubToBytes (getKey $ publicKey xprv) <> sig @@ -642,14 +638,13 @@ dummyTransactionLayer = TransactionLayer -- (tx1, wit1) == (tx2, wit2) <==> fakebinary1 == fakebinary2 let fakeBinary = SealedTx . B8.pack $ show (tx, wit) return (tx, fakeBinary) - , initDelegationSelection = - error "dummyTransactionLayer: initDelegationSelection not implemented" - , mkDelegationJoinTx = - error "dummyTransactionLayer: mkDelegationJoinTx not implemented" - , mkDelegationQuitTx = - error "dummyTransactionLayer: mkDelegationQuitTx not implemented" - , minimumFee = - error "dummyTransactionLayer: minimumFee not implemented" + + , initSelectionCriteria = + error "dummyTransactionLayer: initSelectionCriteria not implemented" + , calcMinimumCost = + error "dummyTransactionLayer: calcMinimumCost not implemented" + , calcMinimumCoinValue = + error "dummyTransactionLayer: calcMinimumCoinValue not implemented" , estimateMaxNumberOfInputs = error "dummyTransactionLayer: estimateMaxNumberOfInputs not implemented" , decodeSignedTx = diff --git a/lib/shelley/bench/Restore.hs b/lib/shelley/bench/Restore.hs index c802d914a62..a14ce2e9dd4 100644 --- a/lib/shelley/bench/Restore.hs +++ b/lib/shelley/bench/Restore.hs @@ -103,6 +103,8 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Sequential , mkSeqAnyState , purposeCIP1852 ) +import Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin + ( selectionDelta ) import Cardano.Wallet.Primitive.Model ( Wallet, currentTip, getState, totalUTxO ) import Cardano.Wallet.Primitive.Slotting @@ -446,8 +448,10 @@ benchmarksRnd _ w wid wname benchname restoreTime = do (_, estimateFeesTime) <- bench "estimate tx fee" $ do let out = TxOut (dummyAddress @n) (TokenBundle.fromCoin $ Coin 1) - runExceptT $ withExceptT show $ W.estimateFeeForPayment @_ @s @k - w wid (out :| []) (Coin 0) Nothing + let txCtx = defaultTransactionCtx + let getFee = const (selectionDelta TokenBundle.getCoin) + let runSelection = W.selectAssets @_ @s @k w wid txCtx (out :| []) getFee + runExceptT $ withExceptT show $ W.estimateFee runSelection oneAddress <- genAddresses 1 cp (_, importOneAddressTime) <- bench "import one addresses" $ do @@ -533,8 +537,10 @@ benchmarksSeq _ w wid _wname benchname restoreTime = do (_, estimateFeesTime) <- bench "estimate tx fee" $ do let out = TxOut (dummyAddress @n) (TokenBundle.fromCoin $ Coin 1) - runExceptT $ withExceptT show $ W.estimateFeeForPayment @_ @s @k - w wid (out :| []) (Coin 0) Nothing + let txCtx = defaultTransactionCtx + let getFee = const (selectionDelta TokenBundle.getCoin) + let runSelection = W.selectAssets @_ @s @k w wid txCtx (out :| []) getFee + runExceptT $ withExceptT show $ W.estimateFee runSelection let walletOverview = WalletOverview{utxo,addresses,transactions} diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs index 8095c6d425e..dc96ffcdceb 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs @@ -72,10 +72,8 @@ import Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin , prepareOutputsWith , selectionDelta ) -import Cardano.Wallet.Primitive.Fee - ( FeePolicy (..) ) import Cardano.Wallet.Primitive.Types - ( ProtocolParameters (..), TxParameters (..) ) + ( FeePolicy (..), ProtocolParameters (..), TxParameters (..) ) import Cardano.Wallet.Primitive.Types.Address ( Address (..) ) import Cardano.Wallet.Primitive.Types.Coin diff --git a/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index ac0fd9eb96d..24fc652ac50 100644 --- a/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -4,6 +4,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -21,13 +22,7 @@ import Prelude import Cardano.Address.Derivation ( XPrv, xprvFromBytes, xprvToBytes ) import Cardano.Wallet - ( ErrSelectForPayment (..) - , FeeEstimation (..) - , coinSelOpts - , estimateFeeForCoinSelection - , feeOpts - , handleCannotCover - ) + ( ErrSelectAssets (..), FeeEstimation (..), estimateFee ) import Cardano.Wallet.Primitive.AddressDerivation ( Passphrase (..) , PassphraseMaxLength (..) @@ -42,16 +37,19 @@ import Cardano.Wallet.Primitive.AddressDerivation.Icarus ( IcarusKey ) import Cardano.Wallet.Primitive.AddressDerivation.Shelley ( ShelleyKey ) -import Cardano.Wallet.Primitive.CoinSelection - ( CoinSelection, CoinSelectionOptions ) -import Cardano.Wallet.Primitive.Fee - ( Fee (..), FeeOptions (..), FeePolicy (..), adjustForFee ) +import Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin + ( SelectionError (..) + , SelectionResult (..) + , UnableToConstructChangeError (..) + , emptySkeleton + , selectionDelta + ) import Cardano.Wallet.Primitive.Types - ( TxParameters (..) ) + ( FeePolicy (..), ProtocolParameters (..), TxParameters (..) ) import Cardano.Wallet.Primitive.Types.Address ( Address (..) ) import Cardano.Wallet.Primitive.Types.Coin - ( Coin (..), coinQuantity ) + ( Coin (..), coinToInteger ) import Cardano.Wallet.Primitive.Types.Coin.Gen ( genCoinLargePositive, shrinkCoinLargePositive ) import Cardano.Wallet.Primitive.Types.Hash @@ -66,11 +64,12 @@ import Cardano.Wallet.Primitive.Types.Tx , TxMetadataValue (..) , TxOut (..) , txMetadataIsNull + , txOutCoin ) import Cardano.Wallet.Primitive.Types.UTxO ( UTxO (..) ) import Cardano.Wallet.Shelley.Compatibility - ( fromAllegraTx, fromShelleyTx, sealShelleyTx ) + ( fromAllegraTx, fromShelleyTx, sealShelleyTx, toCardanoLovelace ) import Cardano.Wallet.Shelley.Transaction ( TxWitnessTagFor , mkByronWitness @@ -81,11 +80,15 @@ import Cardano.Wallet.Shelley.Transaction , _estimateMaxNumberOfInputs ) import Cardano.Wallet.Transaction - ( ErrDecodeSignedTx (..), TransactionLayer (..) ) + ( ErrDecodeSignedTx (..) + , TransactionCtx (..) + , TransactionLayer (..) + , defaultTransactionCtx + ) import Control.Monad ( forM_, replicateM ) import Control.Monad.Trans.Except - ( catchE, runExceptT, withExceptT ) + ( except, runExceptT ) import Data.Function ( on, (&) ) import Data.Maybe @@ -123,9 +126,8 @@ import Test.QuickCheck ) import qualified Cardano.Api.Typed as Cardano -import qualified Cardano.Wallet.Primitive.CoinSelection as CS -import qualified Cardano.Wallet.Primitive.CoinSelection.Random as CS import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle +import qualified Cardano.Wallet.Primitive.Types.UTxOIndex as UTxOIndex import qualified Data.ByteArray as BA import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as B8 @@ -151,33 +153,37 @@ spec = do [(1,17),(10,11),(20,4),(30,0)] describe "fee calculations" $ do - let policy :: FeePolicy - policy = LinearFee (Quantity 100_000) (Quantity 100) - - minFee :: Maybe TxMetadata -> CoinSelection -> Integer - minFee md = fromIntegral . getFee . minimumFee tl policy Nothing md - where tl = testTxLayer - - it "withdrawals incur fees" $ property $ \withdrawal -> + let pp :: ProtocolParameters + pp = dummyProtocolParameters + { txParameters = dummyTxParameters + { getFeePolicy = LinearFee (Quantity 100_000) (Quantity 100) + } + } + + minFee :: TransactionCtx -> Integer + minFee ctx = coinToInteger $ calcMinimumCost testTxLayer pp ctx sel + where sel = emptySkeleton + + it "withdrawals incur fees" $ property $ \txWithdrawal -> let - costWith = minFee Nothing (mempty { CS.withdrawal = withdrawal }) - costWithout = minFee Nothing mempty + costWith = minFee $ defaultTransactionCtx { txWithdrawal } + costWithout = minFee defaultTransactionCtx marginalCost :: Integer marginalCost = costWith - costWithout in - (if withdrawal == 0 + (if txWithdrawal == Coin 0 then property $ marginalCost == 0 else property $ marginalCost > 0 - ) & classify (withdrawal == 0) "null withdrawal" + ) & classify (txWithdrawal == Coin 0) "null withdrawal" & counterexample ("marginal cost: " <> show marginalCost) & counterexample ("cost with: " <> show costWith) & counterexample ("cost without: " <> show costWithout) it "metadata incurs fees" $ property $ \md -> let - costWith = minFee (Just md) mempty - costWithout = minFee Nothing mempty + costWith = minFee $ defaultTransactionCtx { txMetadata = Just md } + costWithout = minFee defaultTransactionCtx marginalCost :: Integer marginalCost = costWith - costWithout @@ -189,25 +195,17 @@ spec = do & counterexample ("cost without: " <> show costWithout) it "regression #1740 - fee estimation at the boundaries" $ do - let utxo = UTxO $ Map.fromList - [ ( TxIn dummyTxId 0 - , TxOut (dummyAddress 0) (coinToBundle 5000000) - ) - ] - let recipients = NE.fromList - [ TxOut (dummyAddress 0) (coinToBundle 4834720) - ] - - let wdrl = Coin 0 - - let selectCoins = flip catchE (handleCannotCover utxo wdrl recipients) $ do - (sel, utxo') <- withExceptT ErrSelectForPaymentCoinSelection $ do - CS.random testCoinSelOpts recipients (coinQuantity wdrl) utxo - withExceptT ErrSelectForPaymentFee $ - (Fee . CS.feeBalance) <$> adjustForFee testFeeOpts utxo' sel - res <- runExceptT $ estimateFeeForCoinSelection Nothing selectCoins - - res `shouldBe` Right (FeeEstimation 166029 166029 Nothing) + let requiredCost = Coin 166029 + let runSelection = except $ Left + $ ErrSelectAssetsSelectionError + $ UnableToConstructChange + $ UnableToConstructChangeError + { requiredCost + , shortfall = Coin 100000 + } + result <- runExceptT (estimateFee runSelection) + result `shouldBe` + Right (FeeEstimation (unCoin requiredCost) (unCoin requiredCost)) -- fixme: it would be nice to repeat the tests for multiple eras let era = Cardano.ShelleyBasedEraAllegra @@ -215,15 +213,23 @@ spec = do describe "tx binary calculations - Byron witnesses - mainnet" $ do let slotNo = SlotNo 7750 md = Nothing - calculateBinary utxo outs pairs = toBase16 (Cardano.serialiseToCBOR ledgerTx) + calculateBinary utxo outs chgs pairs = + toBase16 (Cardano.serialiseToCBOR ledgerTx) where toBase16 = T.decodeUtf8 . hex ledgerTx = Cardano.makeSignedTransaction addrWits unsigned mkByronWitness' unsignedTx (_, (TxOut addr _)) = mkByronWitness unsignedTx Cardano.Mainnet addr addrWits = zipWith (mkByronWitness' unsigned) inps pairs - Right unsigned = mkUnsignedTx era slotNo cs md mempty [] - cs = mempty { CS.inputs = inps, CS.outputs = outs } + fee = toCardanoLovelace $ selectionDelta txOutCoin cs + Right unsigned = mkUnsignedTx era slotNo cs md mempty [] fee + cs = SelectionResult + { inputsSelected = NE.fromList inps + , extraCoinSource = Nothing + , outputsCovered = outs + , changeGenerated = NE.fromList chgs + , utxoRemaining = UTxOIndex.empty + } inps = Map.toList $ getUTxO utxo it "1 input, 2 outputs" $ do let pairs = [dummyWit 0] @@ -238,9 +244,11 @@ spec = do ] let outs = [ TxOut (dummyAddress 1) (coinToBundle amtOut) - , TxOut (dummyAddress 2) (coinToBundle amtChange) ] - calculateBinary utxo outs pairs `shouldBe` + let chgs = + [ TxOut (dummyAddress 2) (coinToBundle amtChange) + ] + calculateBinary utxo outs chgs pairs `shouldBe` "83a40081825820000000000000000000000000000000000000000000000000\ \00000000000000000001828258390101010101010101010101010101010101\ \01010101010101010101010101010101010101010101010101010101010101\ @@ -270,9 +278,11 @@ spec = do let outs = [ TxOut (dummyAddress 2) (coinToBundle amtOut) , TxOut (dummyAddress 3) (coinToBundle amtOut) - , TxOut (dummyAddress 4) (coinToBundle amtChange) ] - calculateBinary utxo outs pairs `shouldBe` + let chgs = + [ TxOut (dummyAddress 4) (coinToBundle amtChange) + ] + calculateBinary utxo outs chgs pairs `shouldBe` "83a40082825820000000000000000000000000000000000000000000000000\ \00000000000000000082582000000000000000000000000000000000000000\ \00000000000000000000000000010183825839010202020202020202020202\ @@ -296,7 +306,8 @@ spec = do describe "tx binary calculations - Byron witnesses - testnet" $ do let slotNo = SlotNo 7750 md = Nothing - calculateBinary utxo outs pairs = toBase16 (Cardano.serialiseToCBOR ledgerTx) + calculateBinary utxo outs chgs pairs = + toBase16 (Cardano.serialiseToCBOR ledgerTx) where toBase16 = T.decodeUtf8 . hex ledgerTx = Cardano.makeSignedTransaction addrWits unsigned @@ -304,8 +315,15 @@ spec = do mkByronWitness' unsignedTx (_, (TxOut addr _)) = mkByronWitness unsignedTx net addr addrWits = zipWith (mkByronWitness' unsigned) inps pairs - Right unsigned = mkUnsignedTx era slotNo cs md mempty [] - cs = mempty { CS.inputs = inps, CS.outputs = outs } + fee = toCardanoLovelace $ selectionDelta txOutCoin cs + Right unsigned = mkUnsignedTx era slotNo cs md mempty [] fee + cs = SelectionResult + { inputsSelected = NE.fromList inps + , extraCoinSource = Nothing + , outputsCovered = outs + , changeGenerated = NE.fromList chgs + , utxoRemaining = UTxOIndex.empty + } inps = Map.toList $ getUTxO utxo it "1 input, 2 outputs" $ do let pairs = [dummyWit 0] @@ -320,9 +338,11 @@ spec = do ] let outs = [ TxOut (dummyAddress 1) (coinToBundle amtOut) - , TxOut (dummyAddress 2) (coinToBundle amtChange) ] - calculateBinary utxo outs pairs `shouldBe` + let chgs = + [ TxOut (dummyAddress 2) (coinToBundle amtChange) + ] + calculateBinary utxo outs chgs pairs `shouldBe` "83a40081825820000000000000000000000000000000000000000000000000\ \00000000000000000001828258390101010101010101010101010101010101\ \01010101010101010101010101010101010101010101010101010101010101\ @@ -352,9 +372,11 @@ spec = do let outs = [ TxOut (dummyAddress 2) (coinToBundle amtOut) , TxOut (dummyAddress 3) (coinToBundle amtOut) - , TxOut (dummyAddress 4) (coinToBundle amtChange) ] - calculateBinary utxo outs pairs `shouldBe` + let chgs = + [ TxOut (dummyAddress 4) (coinToBundle amtChange) + ] + calculateBinary utxo outs chgs pairs `shouldBe` "83a40082825820000000000000000000000000000000000000000000000000\ \00000000000000000082582000000000000000000000000000000000000000\ \00000000000000000000000000010183825839010202020202020202020202\ @@ -408,8 +430,9 @@ prop_decodeSignedShelleyTxRoundtrip prop_decodeSignedShelleyTxRoundtrip shelleyEra (DecodeShelleySetup utxo outs md slotNo pairs) = do let anyEra = Cardano.anyCardanoEra (Cardano.cardanoEra @era) let inps = Map.toList $ getUTxO utxo - let cs = mempty { CS.inputs = inps, CS.outputs = outs } - let Right unsigned = mkUnsignedTx shelleyEra slotNo cs md mempty [] + let cs = mkSelection inps + let fee = toCardanoLovelace $ selectionDelta txOutCoin cs + let Right unsigned = mkUnsignedTx shelleyEra slotNo cs md mempty [] fee let addrWits = map (mkShelleyWitness unsigned) pairs let wits = addrWits let ledgerTx = Cardano.makeSignedTransaction wits unsigned @@ -419,6 +442,14 @@ prop_decodeSignedShelleyTxRoundtrip shelleyEra (DecodeShelleySetup utxo outs md Cardano.ShelleyBasedEraMary -> Left ErrDecodeSignedTxNotSupported _decodeSignedTx anyEra (Cardano.serialiseToCBOR ledgerTx) === expected + where + mkSelection inps = SelectionResult + { inputsSelected = NE.fromList inps + , extraCoinSource = Nothing + , outputsCovered = [] + , changeGenerated = NE.fromList outs + , utxoRemaining = UTxOIndex.empty + } prop_decodeSignedByronTxRoundtrip :: DecodeByronSetup @@ -427,8 +458,9 @@ prop_decodeSignedByronTxRoundtrip (DecodeByronSetup utxo outs slotNo ntwrk pairs let era = Cardano.AnyCardanoEra Cardano.AllegraEra let shelleyEra = Cardano.ShelleyBasedEraAllegra let inps = Map.toList $ getUTxO utxo - let cs = mempty { CS.inputs = inps, CS.outputs = outs } - let Right unsigned = mkUnsignedTx shelleyEra slotNo cs Nothing mempty [] + let cs = mkSelection inps + let fee = toCardanoLovelace $ selectionDelta txOutCoin cs + let Right unsigned = mkUnsignedTx shelleyEra slotNo cs Nothing mempty [] fee let byronWits = zipWith (mkByronWitness' unsigned) inps pairs let ledgerTx = Cardano.makeSignedTransaction byronWits unsigned @@ -437,6 +469,13 @@ prop_decodeSignedByronTxRoundtrip (DecodeByronSetup utxo outs slotNo ntwrk pairs where mkByronWitness' unsigned (_, (TxOut addr _)) = mkByronWitness unsigned ntwrk addr + mkSelection inps = SelectionResult + { inputsSelected = NE.fromList inps + , extraCoinSource = Nothing + , outputsCovered = [] + , changeGenerated = NE.fromList outs + , utxoRemaining = UTxOIndex.empty + } -- | Increasing the number of outputs reduces the number of inputs. prop_moreOutputsMeansLessInputs @@ -480,16 +519,6 @@ prop_biggerMaxSizeMeansMoreInputs (Quantity size) nOuts <= _estimateMaxNumberOfInputs @k (Quantity (size * 2)) Nothing nOuts -testCoinSelOpts :: CoinSelectionOptions -testCoinSelOpts = coinSelOpts testTxLayer (Quantity 4096) Nothing - -testFeeOpts :: FeeOptions -testFeeOpts = feeOpts testTxLayer Nothing Nothing txParams (Coin 0) mempty - where - txParams = TxParameters feePolicy txMaxSize - feePolicy = LinearFee (Quantity 155381) (Quantity 44) - txMaxSize = Quantity maxBound - testTxLayer :: TransactionLayer ShelleyKey testTxLayer = newTransactionLayer @ShelleyKey Cardano.Mainnet @@ -639,3 +668,27 @@ dummyWit b = dummyTxId :: Hash "Tx" dummyTxId = Hash $ BS.pack $ replicate 32 0 + +dummyTxParameters :: TxParameters +dummyTxParameters = TxParameters + { getFeePolicy = + error "dummyTxParameters: getFeePolicy" + , getTxMaxSize = + error "dummyTxParameters: getTxMaxSize" + } + +dummyProtocolParameters :: ProtocolParameters +dummyProtocolParameters = ProtocolParameters + { decentralizationLevel = + error "dummyProtocolParameters: decentralizationLevel" + , txParameters = + error "dummyProtocolParameters: txParameters" + , desiredNumberOfStakePools = + error "dummyProtocolParameters: desiredNumberOfStakePools" + , minimumUTxOvalue = + error "dummyProtocolParameters: minimumUTxOvalue" + , stakeKeyDeposit = + error "dummyProtocolParameters: stakeKeyDeposit" + , hardforkEpochNo = + error "dummyProtocolParameters: hardforkEpochNo" + }