|
| 1 | +{-# LANGUAGE OverloadedStrings #-} |
| 2 | +{-# LANGUAGE TemplateHaskell #-} |
| 3 | + |
| 4 | +module Test.Cli.CliIntermediateFormat |
| 5 | + ( tests |
| 6 | + ) where |
| 7 | + |
| 8 | +import Cardano.Prelude |
| 9 | +import Hedgehog (Property, discover) |
| 10 | +import Test.OptParse |
| 11 | + |
| 12 | +import qualified Hedgehog |
| 13 | +import qualified Hedgehog.Extras.Test.Base as H |
| 14 | +import qualified Hedgehog.Extras.Test.File as H |
| 15 | + |
| 16 | +{- HLINT ignore "Use camelCase" -} |
| 17 | + |
| 18 | +-- | We test to make sure that we can deserialize a tx body in the intermediate format |
| 19 | +prop_backwardsCompatibleCliFormat :: Property |
| 20 | +prop_backwardsCompatibleCliFormat = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do |
| 21 | + txBodyFile <- noteInputFile "test/data/golden/babbage/deprecated-cli-format.body" |
| 22 | + witness <- noteInputFile "test/data/golden/babbage/tx-key-witness" |
| 23 | + initialUtxo1SigningKeyFile <- noteInputFile "test/data/golden/shelley/keys/payment_keys/signing_key" |
| 24 | + signedTransactionFile <- noteTempFile tempDir "signed.tx" |
| 25 | + |
| 26 | + |
| 27 | + void $ execCardanoCLI |
| 28 | + [ "transaction","sign" |
| 29 | + , "--mainnet" |
| 30 | + , "--tx-body-file", txBodyFile |
| 31 | + , "--signing-key-file", initialUtxo1SigningKeyFile |
| 32 | + , "--tx-file", signedTransactionFile |
| 33 | + ] |
| 34 | + |
| 35 | + H.assertFileOccurences 1 "Tx BabbageEra" signedTransactionFile |
| 36 | + H.assertEndsWithSingleNewline signedTransactionFile |
| 37 | + |
| 38 | + void $ execCardanoCLI |
| 39 | + [ "transaction","assemble" |
| 40 | + , "--tx-body-file", txBodyFile |
| 41 | + , "--witness-file", witness |
| 42 | + , "--out-file", signedTransactionFile |
| 43 | + ] |
| 44 | + |
| 45 | + H.assertFileOccurences 1 "Tx BabbageEra" signedTransactionFile |
| 46 | + H.assertEndsWithSingleNewline signedTransactionFile |
| 47 | + |
| 48 | +-- ----------------------------------------------------------------------------- |
| 49 | + |
| 50 | +tests :: IO Bool |
| 51 | +tests = |
| 52 | + Hedgehog.checkParallel $$discover |
| 53 | + |
0 commit comments