Skip to content

Commit bad1bc1

Browse files
authored
Merge pull request #1180 from input-output-hk/cardano-cli-text-envelope-format
Check if cardano-cli works with DraftCommitTxResponse json output
2 parents 8f4aedc + e607e47 commit bad1bc1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

hydra-cluster/hydra-cluster.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ test-suite tests
154154
Test.DirectChainSpec
155155
Test.EndToEndSpec
156156
Test.GeneratorSpec
157+
Test.Hydra.Cluster.CardanoCliSpec
157158
Test.Hydra.Cluster.FaucetSpec
158159
Test.Ledger.Cardano.ConfigurationSpec
159160
Test.LogFilterSpec
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Test.Hydra.Cluster.CardanoCliSpec where
2+
3+
import Hydra.Prelude hiding (toString)
4+
import Test.Hydra.Prelude
5+
6+
import Control.Lens ((^?))
7+
import Data.Aeson (encodeFile)
8+
import Data.Aeson.Lens (key, _String)
9+
import Hydra.API.HTTPServer (DraftCommitTxResponse (DraftCommitTxResponse))
10+
import Hydra.Cardano.Api (Tx)
11+
import System.Exit (ExitCode (..))
12+
import System.FilePath ((</>))
13+
import System.Process (proc, readCreateProcessWithExitCode)
14+
import Test.QuickCheck (generate)
15+
16+
spec :: Spec
17+
spec =
18+
describe "cardano-cli" $
19+
it "cardano-cli can accept a draft commit tx in text-envelope format" $
20+
withTempDir "cardano-cli" $ \tmpDir -> do
21+
let txFile = tmpDir </> "tx.raw"
22+
draftCommitResponse <- DraftCommitTxResponse <$> generate (arbitrary :: Gen Tx)
23+
encodeFile txFile draftCommitResponse
24+
25+
(exitCode, output, _errors) <- readCreateProcessWithExitCode (cardanoCliSign txFile) ""
26+
exitCode `shouldBe` ExitSuccess
27+
output
28+
^? key "type" . _String `shouldSatisfy` \case
29+
Nothing -> False
30+
Just something -> something == "Witnessed Tx BabbageEra"
31+
where
32+
cardanoCliSign txFile =
33+
proc
34+
"cardano-cli"
35+
[ "transaction"
36+
, "sign"
37+
, "--tx-file"
38+
, txFile
39+
, "--signing-key-file"
40+
, "config/credentials/alice.sk"
41+
, "--testnet-magic"
42+
, "42"
43+
, "--out-file"
44+
, "/dev/stdout"
45+
]

nix/hydra/packages.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ rec {
113113
nativePkgs.hydra-cluster.components.tests.tests
114114
hydra-node
115115
cardano-node.packages.${system}.cardano-node
116+
cardano-node.packages.${system}.cardano-cli
116117
hydra-chain-observer
117118
];
118119
};

0 commit comments

Comments
 (0)