From 27981c13697ed8898a8842236ed8fe5639958bc7 Mon Sep 17 00:00:00 2001 From: George Flerovsky Date: Fri, 29 Dec 2023 10:41:05 -0500 Subject: [PATCH] Add golden test: calculate-min-fee for babbage tx --- cardano-cli/cardano-cli.cabal | 3 +- .../Babbage/Transaction/CalculateMinFee.hs | 25 ++ .../protocol-params.json | 385 ++++++++++++++++++ .../files/input/babbage/tx/txbody | 5 + 4 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Transaction/CalculateMinFee.hs create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/babbage/tx/txbody diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 77fde72918..e29cb2f198 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -357,7 +357,8 @@ test-suite cardano-cli-golden build-tool-depends: cardano-cli:cardano-cli , tasty-discover:tasty-discover - other-modules: Test.Golden.Byron.SigningKeys + other-modules: Test.Golden.Babbage.Transaction.CalculateMinFee + Test.Golden.Byron.SigningKeys Test.Golden.Byron.Tx Test.Golden.Byron.TxBody Test.Golden.Byron.UpdateProposal diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Transaction/CalculateMinFee.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Transaction/CalculateMinFee.hs new file mode 100644 index 0000000000..1e3d252a98 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Transaction/CalculateMinFee.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Test.Golden.Babbage.Transaction.CalculateMinFee + where + +import Test.Cardano.CLI.Util + +import Hedgehog (Property) +import qualified Hedgehog as H + +{- HLINT ignore "Use camelCase" -} + +hprop_golden_shelley_transaction_calculate_min_fee :: Property +hprop_golden_shelley_transaction_calculate_min_fee = propertyOnce $ do + protocolParamsJsonFile <- noteInputFile "test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json" + txBodyFile <- noteInputFile "test/cardano-cli-golden/files/input/babbage/tx/txbody" + + minFeeTxt <- execCardanoCLI + [ "transaction","calculate-min-fee" + , "--witness-count", "1" + , "--protocol-params-file", protocolParamsJsonFile + , "--tx-body-file", txBodyFile + ] + + H.diff minFeeTxt (==) "165633 Lovelace\n" diff --git a/cardano-cli/test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json b/cardano-cli/test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json new file mode 100644 index 0000000000..5e54127e5e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json @@ -0,0 +1,385 @@ +{ + "collateralPercentage": 150, + "costModels": { + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 57996947, + 18975, + 10 + ], + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 57996947, + 18975, + 10, + 38887044, + 32947, + 10 + ] + }, + "decentralization": null, + "executionUnitPrices": { + "priceMemory": 5.77e-2, + "priceSteps": 7.21e-5 + }, + "extraPraosEntropy": null, + "maxBlockBodySize": 90112, + "maxBlockExecutionUnits": { + "memory": 62000000, + "steps": 20000000000 + }, + "maxBlockHeaderSize": 1100, + "maxCollateralInputs": 3, + "maxTxExecutionUnits": { + "memory": 14000000, + "steps": 10000000000 + }, + "maxTxSize": 16384, + "maxValueSize": 5000, + "minPoolCost": 170000000, + "minUTxOValue": null, + "monetaryExpansion": 3.0e-3, + "poolPledgeInfluence": 0.3, + "poolRetireMaxEpoch": 18, + "protocolVersion": { + "major": 8, + "minor": 0 + }, + "stakeAddressDeposit": 2000000, + "stakePoolDeposit": 500000000, + "stakePoolTargetNum": 500, + "treasuryCut": 0.2, + "txFeeFixed": 155381, + "txFeePerByte": 44, + "utxoCostPerByte": 4310 +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/babbage/tx/txbody b/cardano-cli/test/cardano-cli-golden/files/input/babbage/tx/txbody new file mode 100644 index 0000000000..c07b525558 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/babbage/tx/txbody @@ -0,0 +1,5 @@ +{ + "type": "Unwitnessed Tx BabbageEra", + "description": "Ledger Cddl Format", + "cborHex": "84a40081825820325683345ccbb29ac1eb76b8d1d776f139768fb30a1207d199a889285adfd2a100018282581d6129fe632bb0f66526aa201858b062fa94d6fc09df17dbcb7ee3062e691a004c4b4082581d6129fd280480232d72b2839fcf47275e790a1a3a45dafafd8f641806121a004100b4021a0002a331031a06b228c0a0f5f6" +}