Skip to content

Commit a1cb8ac

Browse files
committed
Add tests for --out-file option of the 'calculate-min-fee' command
1 parent 761c668 commit a1cb8ac

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ import Test.Golden.Shelley.Transaction.Build (golden_shelleyTransactio
8484
golden_shelleyTransactionBuild_TxInScriptWitnessed,
8585
golden_shelleyTransactionBuild_WithdrawalScriptWitnessed)
8686
import Test.Golden.Shelley.Transaction.CalculateMinFee
87-
(golden_shelleyTransactionCalculateMinFee)
87+
(golden_shelleyTransactionCalculateMinFee,
88+
golden_shelleyTransactionCalculateMinFee_outFile)
8889
import Test.Golden.Shelley.Transaction.CreateWitness
8990
(golden_shelleyTransactionSigningKeyWitness)
9091
import Test.Golden.Shelley.Transaction.Sign (golden_shelleyTransactionSign)
@@ -132,6 +133,7 @@ keyTests =
132133
, ("golden_shelleyTransactionBuild_CertificateScriptWitnessed", golden_shelleyTransactionBuild_CertificateScriptWitnessed)
133134
, ("golden_shelleyTransactionBuild_WithdrawalScriptWitnessed", golden_shelleyTransactionBuild_WithdrawalScriptWitnessed)
134135
, ("golden_shelleyTransactionCalculateMinFee", golden_shelleyTransactionCalculateMinFee)
136+
, ("golden_shelleyTransactionCalculateMinFee_outFile", golden_shelleyTransactionCalculateMinFee_outFile)
135137
, ("golden_shelleyTransactionSign", golden_shelleyTransactionSign)
136138
, ("golden_shelleyVRFKeys", golden_shelleyVRFKeys)
137139
, ("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 Test.OptParse
12+
import Test.Utilities (diffVsGoldenFile)
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+
diffVsGoldenFile resultJson "test/data/golden/shelley/tx/calculate-min-fee/out-file.json"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5083100

0 commit comments

Comments
 (0)