Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable reading of Conway TxWitnesses #367

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ test-suite cardano-cli-golden
Test.Golden.Byron.UpdateProposal
Test.Golden.Byron.Vote
Test.Golden.Byron.Witness
Test.Golden.Conway.Transaction.Assemble
Test.Golden.EraBased.Governance.AnswerPoll
Test.Golden.EraBased.Governance.CreatePoll
Test.Golden.EraBased.Governance.VerifyPoll
Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ readCddlWitness fp = do
, FromCDDLWitness "TxWitness MaryEra" CddlWitness
, FromCDDLWitness "TxWitness AlonzoEra" CddlWitness
, FromCDDLWitness "TxWitness BabbageEra" CddlWitness
, FromCDDLWitness "TxWitness ConwayEra" CddlWitness
]

-- Witness handling
Expand Down Expand Up @@ -860,6 +861,7 @@ readFileInAnyCardanoEra
, HasTextEnvelope (thing MaryEra)
, HasTextEnvelope (thing AlonzoEra)
, HasTextEnvelope (thing BabbageEra)
, HasTextEnvelope (thing ConwayEra)
)
=> (forall era. AsType era -> AsType (thing era))
-> FileOrPipe
Expand All @@ -872,6 +874,7 @@ readFileInAnyCardanoEra asThing =
, FromSomeType (asThing AsMaryEra) (InAnyCardanoEra MaryEra)
, FromSomeType (asThing AsAlonzoEra) (InAnyCardanoEra AlonzoEra)
, FromSomeType (asThing AsBabbageEra) (InAnyCardanoEra BabbageEra)
, FromSomeType (asThing AsConwayEra) (InAnyCardanoEra ConwayEra)
]

-- | We need a type for handling files that may be actually be things like
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Conway.Transaction.Assemble where

import Control.Monad (void)

import Test.Cardano.CLI.Util

import Hedgehog (Property)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H

{- HLINT ignore "Use camelCase" -}

-- Check that we can assemble a txbody and a tx witness to form a transaction

hprop_golden_conwayTransactionAssembleWitness_SigningKey :: Property
hprop_golden_conwayTransactionAssembleWitness_SigningKey = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
witnessTx <- noteTempFile tempDir "single-signing-key-witness-tx"
txBodyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/txbody"
signingKeyWitnessFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/singleSigningKeyWitness"
void $ execCardanoCLI
[ "conway", "transaction", "assemble"
, "--tx-body-file", txBodyFile
, "--witness-file", signingKeyWitnessFile
, "--witness-file", signingKeyWitnessFile
, "--out-file", witnessTx
]

H.assertFileOccurences 1 "Witnessed Tx ConwayEra" witnessTx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "TxWitness ConwayEra",
"description": "Key Witness ShelleyEra",
"cborHex": "825820c16f6bf723e38013f88588539fbbf1cd6b57bbbd8bb2cf318e641f00dcd527875840e62f3050bf7ee1d1547badd6f8346c00957b20c8d8f201fc8cf9d64485b3b3c944392afe00619516a00d98c6ccfa44a7de8c1a093efdc10832bb6fdf4cde8e08"
}
5 changes: 5 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/input/conway/txbody
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "Unwitnessed Tx ConwayEra",
"description": "Ledger Cddl Format",
"cborHex": "84a5008182582054b5f2d5ed0fa142e724c9a982864d9e080b10648a66c8f7956eb3cc2cf16c0000018182581d6052e63f22c5107ed776b70f7b92248b02552fd08f3e747bc7450994411b0000000235cfef6d021a0002ff51031a0099d1dd04828a03581ce6eb963e591bc66401b5e1c763f4c9bc27adf58eb720f63c809981d75820dacc52f2d73542ab0fc3b1f8051d00b0e50f1130935e5a21982bd289705852ae1b000000174876e8001b00000002540be400d81e82010a581de05e35891efec9c4a4e08d2a6a6d03598056d014e287618548e2556f8c81581c5e35891efec9c4a4e08d2a6a6d03598056d014e287618548e2556f8c818400190bb9447f000001f682783268747470733a2f2f6d792d69702e61742f746573742f636f6e77617974657374706f6f6c2e6d657461646174612e6a736f6e58207cd083e6682892afc2b4e315fca93784f43dccde8bae1daa81db0b587e27155f83028200581c5e35891efec9c4a4e08d2a6a6d03598056d014e287618548e2556f8c581ce6eb963e591bc66401b5e1c763f4c9bc27adf58eb720f63c809981d7a0f5f6"
}