Skip to content

Commit 759a646

Browse files
committed
Add tests for --out-file option of the 'calculate-min-fee' command
1 parent ba37c5d commit 759a646

File tree

4 files changed

+32
-95
lines changed

4 files changed

+32
-95
lines changed

cardano-cli/test/Test/Golden/Shelley.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ import Test.Golden.Shelley.Transaction.Build (golden_shelleyTransactio
8383
golden_shelleyTransactionBuild_TxInScriptWitnessed,
8484
golden_shelleyTransactionBuild_WithdrawalScriptWitnessed)
8585
import Test.Golden.Shelley.Transaction.CalculateMinFee
86-
(golden_shelleyTransactionCalculateMinFee)
86+
(golden_shelleyTransactionCalculateMinFee,
87+
golden_shelleyTransactionCalculateMinFee_outFile)
8788
import Test.Golden.Shelley.Transaction.CreateWitness
8889
(golden_shelleyTransactionSigningKeyWitness)
8990
import Test.Golden.Shelley.Transaction.Sign (golden_shelleyTransactionSign)
@@ -131,6 +132,7 @@ keyTests =
131132
, ("golden_shelleyTransactionBuild_CertificateScriptWitnessed", golden_shelleyTransactionBuild_CertificateScriptWitnessed)
132133
, ("golden_shelleyTransactionBuild_WithdrawalScriptWitnessed", golden_shelleyTransactionBuild_WithdrawalScriptWitnessed)
133134
, ("golden_shelleyTransactionCalculateMinFee", golden_shelleyTransactionCalculateMinFee)
135+
, ("golden_shelleyTransactionCalculateMinFee_outFile", golden_shelleyTransactionCalculateMinFee_outFile)
134136
, ("golden_shelleyTransactionSign", golden_shelleyTransactionSign)
135137
, ("golden_shelleyVRFKeys", golden_shelleyVRFKeys)
136138
, ("golden_version", golden_version)

cardano-cli/test/Test/Golden/Shelley/Transaction/CalculateMinFee.hs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
module Test.Golden.Shelley.Transaction.CalculateMinFee
44
( golden_shelleyTransactionCalculateMinFee
5+
, golden_shelleyTransactionCalculateMinFee_outFile
56
) where
67

7-
import Hedgehog (Property)
8-
import Test.OptParse
9-
8+
import Hedgehog (Property, (===))
109
import qualified Hedgehog.Extras.Test.Base as H
1110
import qualified Hedgehog.Extras.Test.File as H
11+
import qualified Hedgehog.Extras.Test.Golden as H
12+
import Test.OptParse
1213

1314
{- HLINT ignore "Use camelCase" -}
1415

@@ -34,3 +35,27 @@ golden_shelleyTransactionCalculateMinFee = propertyOnce $ H.moduleWorkspace "tmp
3435
H.assertFileOccurences 1 "5083100" minFeeTxtFile
3536
H.assertFileLines (== 1) minFeeTxtFile
3637
H.assertEndsWithSingleNewline minFeeTxtFile
38+
39+
golden_shelleyTransactionCalculateMinFee_outFile :: Property
40+
golden_shelleyTransactionCalculateMinFee_outFile = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
41+
protocolParamsJsonFile <- noteInputFile "test/data/golden/shelley/transaction-calculate-min-fee/protocol-params.json"
42+
txBodyFile <- noteInputFile "test/data/golden/shelley/tx/txbody"
43+
outFile <- noteTempFile tempDir "out-file"
44+
45+
minFeeTxt <- execCardanoCLI
46+
[ "transaction","calculate-min-fee"
47+
, "--out-file", outFile
48+
, "--tx-in-count", "32"
49+
, "--tx-out-count", "27"
50+
, "--byron-witness-count", "5"
51+
, "--witness-count", "10"
52+
, "--testnet-magic", "4036000900"
53+
, "--protocol-params-file", protocolParamsJsonFile
54+
, "--tx-body-file", txBodyFile
55+
]
56+
57+
minFeeTxt === ""
58+
59+
resultJson <- H.readFile outFile
60+
61+
H.diffVsGoldenFile resultJson "test/data/golden/shelley/tx/calculate-min-fee/out-file.json"

cardano-cli/test/Test/Utilities.hs

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5083100

0 commit comments

Comments
 (0)