From c0dfae2549ee1a5f4f43443dab0f8e1467df63df Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Thu, 11 Apr 2024 15:48:14 +0200 Subject: [PATCH] Add transaction metadata golden test --- .../Cardano/CLI/EraBased/Options/Common.hs | 2 +- .../cardano-cli-golden/Test/Golden/TxView.hs | 76 +++++++++++++++---- ...ansaction-view-metadata-detailedschema.out | 41 ++++++++++ .../transaction-view-metadata-noschema.out | 74 ++++++++++++++++++ .../help/allegra_transaction_build-raw.cli | 2 +- .../golden/help/allegra_transaction_build.cli | 2 +- .../help/alonzo_transaction_build-raw.cli | 2 +- .../golden/help/alonzo_transaction_build.cli | 2 +- .../help/babbage_transaction_build-raw.cli | 2 +- .../golden/help/babbage_transaction_build.cli | 2 +- .../help/conway_transaction_build-raw.cli | 2 +- .../golden/help/conway_transaction_build.cli | 2 +- .../help/latest_transaction_build-raw.cli | 2 +- .../golden/help/latest_transaction_build.cli | 2 +- .../help/legacy_transaction_build-raw.cli | 2 +- .../golden/help/legacy_transaction_build.cli | 2 +- .../help/mary_transaction_build-raw.cli | 2 +- .../golden/help/mary_transaction_build.cli | 2 +- .../help/shelley_transaction_build-raw.cli | 2 +- .../golden/help/shelley_transaction_build.cli | 2 +- .../golden/help/transaction_build-raw.cli | 2 +- .../files/golden/help/transaction_build.cli | 2 +- .../files/input/tx_metadata_noschema.json | 28 +++++++ .../files/input/tx_metadata_withschema.json | 24 ++++++ .../Test/Cli/Shelley/Transaction/Build.hs | 15 ++-- 25 files changed, 254 insertions(+), 42 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-detailedschema.out create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_noschema.json create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_withschema.json diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index ea04cd8fc6..f01094da09 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -1370,7 +1370,7 @@ pTxMetadataJsonSchema = asum [ Opt.flag' () ( Opt.long "json-metadata-no-schema" - <> Opt.help "Use the \"no schema\" conversion from JSON to tx metadata." + <> Opt.help "Use the \"no schema\" conversion from JSON to tx metadata (default)." ) $> TxMetadataJsonNoSchema , Opt.flag' () diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs index ab9274b698..f824371a7a 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs @@ -5,10 +5,13 @@ module Test.Golden.TxView , hprop_golden_view_allegra_yaml , hprop_golden_view_mary_yaml , hprop_golden_view_redeemer + , hprop_golden_view_metadata , hprop_golden_view_alonzo_yaml , hprop_golden_view_alonzo_signed_yaml ) where +import Cardano.Api (TxMetadataJsonSchema (..)) + import Control.Monad (void) import System.FilePath (()) @@ -19,6 +22,11 @@ import Hedgehog.Extras (Integration, moduleWorkspace, note_, propertyO import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} + +goldenDir, inputDir :: FilePath +goldenDir = "test/cardano-cli-golden/files/golden" +inputDir = "test/cardano-cli-golden/files/input" + -- TODO: Expose command to view byron tx files _hprop_golden_view_byron_yaml :: Property _hprop_golden_view_byron_yaml = @@ -42,7 +50,7 @@ _hprop_golden_view_byron_yaml = result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/byron/transaction-view.out" + H.diffVsGoldenFile result $ goldenDir "byron/transaction-view.out" -- TODO: Expose command to view byron tx files _hprop_golden_view_byron_json_default :: Property @@ -67,11 +75,11 @@ _hprop_golden_view_byron_json_default = result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/byron/transaction-view-json.out" + H.diffVsGoldenFile result $ goldenDir "byron/transaction-view-json.out" hprop_golden_view_shelley_yaml :: Property hprop_golden_view_shelley_yaml = let - certDir = "test/cardano-cli-golden/files/input/shelley/certificates" + certDir = inputDir "shelley/certificates" certs = (certDir ) <$> [ "genesis_key_delegation_certificate" @@ -107,7 +115,7 @@ hprop_golden_view_shelley_yaml = let , "--epoch", "64" , "--extra-entropy", extraEntropySeed , "--genesis-verification-key-file" - , "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" + , inputDir "shelley/keys/genesis_keys/verification_key" , "--key-reg-deposit-amt", "71" , "--max-block-body-size", "72" , "--max-block-header-size", "73" @@ -150,7 +158,7 @@ hprop_golden_view_shelley_yaml = let execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/shelley/transaction-view.out" + H.diffVsGoldenFile result $ goldenDir "shelley/transaction-view.out" hprop_golden_view_allegra_yaml :: Property hprop_golden_view_allegra_yaml = @@ -180,7 +188,7 @@ hprop_golden_view_allegra_yaml = result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/allegra/transaction-view.out" + H.diffVsGoldenFile result $ goldenDir "allegra/transaction-view.out" hprop_golden_view_mary_yaml :: Property hprop_golden_view_mary_yaml = @@ -238,8 +246,8 @@ hprop_golden_view_mary_yaml = , " a06ee5ffdd7f9b5bd992eb9543f44418323f81229526b77b0e4be067" , ".736b79" ] - , "--mint-script-file", "test/cardano-cli-golden/files/input/mary/scripts/mint.all" - , "--mint-script-file", "test/cardano-cli-golden/files/input/mary/scripts/mint.sig" + , "--mint-script-file", inputDir "mary/scripts/mint.all" + , "--mint-script-file", inputDir "mary/scripts/mint.sig" , "--out-file", transactionBodyFile ] @@ -247,7 +255,7 @@ hprop_golden_view_mary_yaml = result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/mary/transaction-view.out" + H.diffVsGoldenFile result $ goldenDir "mary/transaction-view.out" hprop_golden_view_redeemer :: Property hprop_golden_view_redeemer = do @@ -261,7 +269,7 @@ hprop_golden_view_redeemer = do execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/babbage/transaction-view-redeemer.out" + H.diffVsGoldenFile result $ goldenDir "babbage/transaction-view-redeemer.out" where scriptTxBody :: FilePath -> Integration () scriptTxBody transactionBodyFile = @@ -271,16 +279,51 @@ hprop_golden_view_redeemer = do , "ed7c8f68c194cc763ee65ad22ef0973e26481be058c65005fd39fb93f9c43a20#213" , "--tx-in-datum-value", "6666" , "--tx-in-redeemer-value", "42" - , "--tx-in-script-file", "test/cardano-cli-golden/files/input/AlwaysSucceeds.plutus" + , "--tx-in-script-file", inputDir "AlwaysSucceeds.plutus" , "--tx-in-execution-units", "(100, 200)" , "--tx-in-collateral" , "c9765d7d0e3955be8920e6d7a38e1f3f2032eac48c7c59b0b9193caa87727e7e#256" , "--protocol-params-file" - , "test/cardano-cli-golden/files/input/babbage/transaction-calculate-min-fee/protocol-params.json" + , inputDir "babbage/transaction-calculate-min-fee/protocol-params.json" , "--fee", "213" , "--out-file", transactionBodyFile ] +-- | Test metadata format +hprop_golden_view_metadata :: Property +hprop_golden_view_metadata = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do + transactionBodyMetaNoSchema <- noteTempFile tempDir "transaction-body-noschema" + makeTxBody TxMetadataJsonNoSchema transactionBodyMetaNoSchema + resultNoSchema <- + execCardanoCLI + ["transaction", "view", "--tx-body-file", transactionBodyMetaNoSchema, "--output-yaml"] + H.diffVsGoldenFile resultNoSchema $ goldenDir "babbage/transaction-view-metadata-noschema.out" + + transactionBodyMetaDetailedSchema <- noteTempFile tempDir "transaction-body-detailedschema" + makeTxBody TxMetadataJsonDetailedSchema transactionBodyMetaDetailedSchema + resultDetailedSchema <- + execCardanoCLI + ["transaction", "view", "--tx-body-file", transactionBodyMetaDetailedSchema, "--output-yaml"] + H.diffVsGoldenFile resultDetailedSchema $ goldenDir "babbage/transaction-view-metadata-detailedschema.out" + where + makeTxBody :: TxMetadataJsonSchema -> FilePath -> Integration () + makeTxBody hasSchema transactionBodyFile = do + let metadataArgs = + case hasSchema of + TxMetadataJsonNoSchema -> + [ "--metadata-json-file", inputDir "tx_metadata_noschema.json" ] + TxMetadataJsonDetailedSchema -> + [ "--json-metadata-detailed-schema" + , "--metadata-json-file", inputDir "tx_metadata_withschema.json" + ] + void . execCardanoCLI $ + [ "babbage", "transaction", "build-raw" + , "--tx-in" , "ed7c8f68c194cc763ee65ad22ef0973e26481be058c65005fd39fb93f9c43a20#213" + , "--tx-out", "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+24910487859" + , "--fee", "21300" + , "--out-file", transactionBodyFile + ] <> metadataArgs + createAlonzoTxBody :: Maybe FilePath -> FilePath -> Integration () createAlonzoTxBody mUpdateProposalFile transactionBodyFile = do void $ @@ -319,7 +362,7 @@ hprop_golden_view_alonzo_yaml = [ "legacy", "governance", "create-update-proposal" , "--epoch", "190" , "--genesis-verification-key-file" - , "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" + , inputDir "shelley/keys/genesis_keys/verification_key" , "--price-execution-steps", "195/196" , "--price-execution-memory", "196/197" , "--max-tx-execution-units", "(197, 198)" @@ -336,13 +379,13 @@ hprop_golden_view_alonzo_yaml = result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"] - H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/alonzo/transaction-view.out" + H.diffVsGoldenFile result $ goldenDir "alonzo/transaction-view.out" hprop_golden_view_alonzo_signed_yaml :: Property hprop_golden_view_alonzo_signed_yaml = propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do - let golden = "test/cardano-cli-golden/files/golden/alonzo" - let input = "test/cardano-cli-golden/files/input/alonzo" + let golden = goldenDir "alonzo" + let input = inputDir "alonzo" transactionBodyFile <- noteTempFile tempDir "transaction-body" transactionFile <- noteTempFile tempDir "transaction" @@ -364,3 +407,4 @@ hprop_golden_view_alonzo_signed_yaml = ["transaction", "view", "--tx-file", transactionFile, "--output-yaml"] H.diffVsGoldenFile result (golden "signed-transaction-view.out") + diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-detailedschema.out b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-detailedschema.out new file mode 100644 index 0000000000..427cf0a5bb --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-detailedschema.out @@ -0,0 +1,41 @@ +auxiliary scripts: null +certificates: null +collateral inputs: [] +era: Babbage +fee: 21300 Lovelace +inputs: +- ed7c8f68c194cc763ee65ad22ef0973e26481be058c65005fd39fb93f9c43a20#213 +metadata: + '0': + - - aaa + - b4 + - - 1 + - b6 + - - aa + - b2 + - - ab + - b3 + - - b + - b5 + - - a + - b1 +mint: null +outputs: +- address: addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc + address era: Shelley + amount: + lovelace: 24910487859 + network: Testnet + payment credential key hash: 52e63f22c5107ed776b70f7b92248b02552fd08f3e747bc745099441 + reference script: null + stake reference: null +redeemers: [] +reference inputs: [] +required signers (payment key hashes needed for scripts): null +return collateral: null +total collateral: null +update proposal: null +validity range: + lower bound: null + upper bound: null +withdrawals: null diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out new file mode 100644 index 0000000000..6f2fec15cc --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out @@ -0,0 +1,74 @@ +auxiliary scripts: null +certificates: null +collateral inputs: [] +era: Babbage +fee: 21300 Lovelace +inputs: +- ed7c8f68c194cc763ee65ad22ef0973e26481be058c65005fd39fb93f9c43a20#213 +metadata: + '0': + - - '"\DLE@A"' + - '"C"' + - - '"\NAK@A"' + - '"D"' + - - '"0A"' + - '"E"' + - - '"A"' + - '"B"' + - - 1 + - 2 + - - 11 + - 3 + - - a + - b + - - aa + - bb + - - aab + - ba + - - ab + - ba + - - aba + - - - '"\DLE@A"' + - '"C"' + - - '"\NAK@A"' + - '"D"' + - - '"0A"' + - '"E"' + - - '"A"' + - '"B"' + - - 1 + - 2 + - - 11 + - 3 + - - a + - b + - - aa + - bb + - - aab + - ba + - - ab + - ba + - - abb + - ba + - - abb + - ba +mint: null +outputs: +- address: addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc + address era: Shelley + amount: + lovelace: 24910487859 + network: Testnet + payment credential key hash: 52e63f22c5107ed776b70f7b92248b02552fd08f3e747bc745099441 + reference script: null + stake reference: null +redeemers: [] +reference inputs: [] +required signers (payment key hashes needed for scripts): null +return collateral: null +total collateral: null +update proposal: null +validity range: + lower bound: null + upper bound: null +withdrawals: null diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli index 9168bbea7d..93a8688b7b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build.cli index 9cd5d33330..cc45f92af6 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_transaction_build.cli @@ -375,7 +375,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli index 440d85c008..c63f95f254 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build.cli index f2de5b5d29..4a3c9ef686 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_transaction_build.cli @@ -375,7 +375,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli index 05256172f9..c119216d13 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build.cli index a3b91f389a..fe53384e9b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_transaction_build.cli @@ -375,7 +375,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli index c65587974d..7aa4368f55 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build-raw.cli @@ -395,7 +395,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build.cli index 73e21d63ac..879442ee77 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_transaction_build.cli @@ -386,7 +386,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli index 1472a33d49..10c8a618f3 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build.cli index a3e9eee307..4e87a67b93 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_transaction_build.cli @@ -375,7 +375,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build-raw.cli index 582979acf4..ca41a11691 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build-raw.cli @@ -393,7 +393,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build.cli index 302aeec2fd..5de6954eca 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_transaction_build.cli @@ -398,7 +398,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli index 8e4f143a52..9bffe744e0 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build.cli index f2b0ea6f0f..93b684e85c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_transaction_build.cli @@ -373,7 +373,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli index 5aa3ff6589..4637e67b33 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build-raw.cli @@ -380,7 +380,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build.cli index 7c7a76b146..7bc1dda8ae 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_transaction_build.cli @@ -375,7 +375,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build-raw.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build-raw.cli index 49d9a1aed1..ab815f8f01 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build-raw.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build-raw.cli @@ -391,7 +391,7 @@ Available options: The time and space units needed by the script. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build.cli index bd62fce705..01c0b0fbc8 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/transaction_build.cli @@ -393,7 +393,7 @@ Available options: including top-level strings and numbers. --json-metadata-no-schema Use the "no schema" conversion from JSON to tx - metadata. + metadata (default). --json-metadata-detailed-schema Use the "detailed schema" conversion from JSON to tx metadata. diff --git a/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_noschema.json b/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_noschema.json new file mode 100644 index 0000000000..949003d801 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_noschema.json @@ -0,0 +1,28 @@ +{ + "0": { + "0x41": "0x42", + "0x154041": "0x44", + "0x104041": "0x43", + "0x3041": "0x45", + "aab": "ba", + "abb": "ba", + "11": 3, + "1": 2, + "a": "b", + "aa": "bb", + "ab": "ba", + "aba": { + "0x41": "0x42", + "0x154041": "0x44", + "0x104041": "0x43", + "0x3041": "0x45", + "aab": "ba", + "abb": "ba", + "11": 3, + "1": 2, + "a": "b", + "aa": "bb", + "ab": "ba" + } + } +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_withschema.json b/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_withschema.json new file mode 100644 index 0000000000..8c82743fd6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/tx_metadata_withschema.json @@ -0,0 +1,24 @@ +{ + "0": { + "map": + [ { "k": {"string": "aaa"} + , "v": {"string": "b4"} + } + , { "k": {"int": 1} + , "v": {"string": "b6"} + } + , { "k": {"string": "aa"} + , "v": {"string": "b2"} + } + , { "k": {"string": "ab"} + , "v": {"string": "b3"} + } + , { "k": {"string": "b"} + , "v": {"string": "b5"} + } + , { "k": {"string": "a"} + , "v": {"string": "b1"} + } + ] + } +} diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Build.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Build.hs index 73b27d59a2..f1a7e5af24 100644 --- a/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Build.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Transaction/Build.hs @@ -2,15 +2,16 @@ module Test.Cli.Shelley.Transaction.Build where import Data.List (isInfixOf) import System.Exit (ExitCode (..)) +import System.FilePath (()) -import Test.Cardano.CLI.Util (execDetailCardanoCLI, propertyOnce) +import Test.Cardano.CLI.Util import Hedgehog import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H -{- HLINT ignore "Use camelCase" -} -{- HLINT ignore "Redundant bracket" -} +inputDir :: FilePath +inputDir = "test/cardano-cli-test/files/input/shelley/transaction" -- | This is a test of https://github.com/IntersectMBO/cardano-cli/issues/662 -- Execute me with: @@ -25,10 +26,10 @@ hprop_conway_transaction_build_one_voter_many_votes = propertyOnce $ H.moduleWor , "--tx-out", "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+24910487859" , "--invalid-hereafter", "24325742" , "--fee" , "178569" - , "--vote-file", "test/cardano-cli-test/files/input/shelley/transaction/vote1.drep.json" - , "--vote-file", "test/cardano-cli-test/files/input/shelley/transaction/vote2.drep.json" + , "--vote-file", inputDir "vote1.drep.json" + , "--vote-file", inputDir "vote2.drep.json" , "--out-file", outFile ] - exitCode H.=== (ExitFailure 1) - H.assertWith stderr ("This would cause ignoring some of the votes" `isInfixOf`) \ No newline at end of file + exitCode H.=== ExitFailure 1 + H.assertWith stderr ("This would cause ignoring some of the votes" `isInfixOf`)