Skip to content

Commit

Permalink
Added reference test for `compatible conway transaction singed-transa…
Browse files Browse the repository at this point in the history
…ction`
  • Loading branch information
carbolymer committed Nov 26, 2024
1 parent 7965ce2 commit 26a1017
Show file tree
Hide file tree
Showing 10 changed files with 572 additions and 13 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ test-suite cardano-cli-test
Test.Cli.Shelley.Run.Hash
Test.Cli.Shelley.Run.Query
Test.Cli.Shelley.Transaction.Build
Test.Cli.Shelley.Transaction.Compatible.Build
Test.Cli.VerificationKey

ghc-options:
Expand Down
32 changes: 19 additions & 13 deletions cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,17 @@ runCompatibleTransactionCmd
| (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits
]

let refInputs =
[ refInput
| (_, Just sWit) <- certsAndMaybeScriptWits
, refInput <- maybeToList $ getScriptWitnessReferenceInput sWit
]
let (refInputs, anyScriptWits) =
unzip
[ (refInput, AnyScriptWitness sWit)
| (_, Just sWit) <- certsAndMaybeScriptWits
, refInput <- maybeToList $ getScriptWitnessReferenceInput sWit
]
-- TODO is this missing something? see EraBased.Run.Transaction L907
validatedRefInputs <- liftEither . first CompatibleTxCmdError $ validateTxInsReference refInputs
let txCerts = convertCertificates certsAndMaybeScriptWits

-- this body is only for witnesses
apiTxBody <-
firstExceptT CompatibleTxBodyError $
hoistEither $
Expand All @@ -269,36 +272,39 @@ runCompatibleTransactionCmd
& setTxIns (map (,BuildTxWith (KeyWitness KeyWitnessForSpending)) ins)
& setTxOuts allOuts
& setTxFee (TxFeeExplicit sbe fee)
& setTxCertificates (convertCertificates certsAndMaybeScriptWits)
& setTxCertificates txCerts
& setTxInsReference validatedRefInputs

let (sksByron, sksShelley) = partitionSomeWitnesses $ map categoriseSomeSigningWitness sks

byronWitnesses <-
firstExceptT CompatibleBootstrapWitnessError $
hoistEither (mkShelleyBootstrapWitnesses sbe mNetworkId apiTxBody sksByron)
firstExceptT CompatibleBootstrapWitnessError . hoistEither $
mkShelleyBootstrapWitnesses sbe mNetworkId apiTxBody sksByron

let newShelleyKeyWits = map (makeShelleyKeyWitness sbe apiTxBody) sksShelley
allKeyWits = newShelleyKeyWits ++ byronWitnesses

(protocolUpdates, votes) <-
caseShelleyToBabbageOrConwayEraOnwards
( const $ do
prop <- maybe (return $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal
prop <- maybe (pure $ NoPParamsUpdate sbe) readUpdateProposalFile mUpdateProposal
return (prop, NoVotes)
)
( \w -> do
prop <- maybe (return $ NoPParamsUpdate sbe) readProposalProcedureFile mProposalProcedure
votesAndWits <- firstExceptT CompatibleVoteError $ newExceptT $ readVotingProceduresFiles w mVotes
prop <- maybe (pure $ NoPParamsUpdate sbe) readProposalProcedureFile mProposalProcedure
votesAndWits <-
firstExceptT CompatibleVoteError . newExceptT $
readVotingProceduresFiles w mVotes
votingProcedures <-
firstExceptT CompatibleVoteMergeError $ hoistEither $ mkTxVotingProcedures votesAndWits
firstExceptT CompatibleVoteMergeError . hoistEither $
mkTxVotingProcedures votesAndWits
return (prop, VotingProcedures w votingProcedures)
)
sbe

signedTx <-
firstExceptT CompatiblePParamsConversionError . hoistEither $
createCompatibleSignedTx sbe ins allOuts allKeyWits fee protocolUpdates votes
createCompatibleSignedTx sbe ins allOuts allKeyWits anyScriptWits fee protocolUpdates votes txCerts

firstExceptT CompatibleFileError $
newExceptT $
Expand Down
114 changes: 114 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -10787,6 +10787,25 @@ Usage: cardano-cli compatible shelley transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down Expand Up @@ -10901,6 +10920,25 @@ Usage: cardano-cli compatible allegra transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down Expand Up @@ -11015,6 +11053,25 @@ Usage: cardano-cli compatible mary transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down Expand Up @@ -11137,6 +11194,25 @@ Usage: cardano-cli compatible alonzo transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down Expand Up @@ -11269,6 +11345,25 @@ Usage: cardano-cli compatible babbage transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down Expand Up @@ -11452,6 +11547,25 @@ Usage: cardano-cli compatible conway transaction signed-transaction
| --testnet-magic NATURAL
]
--fee LOVELACE
[
--certificate-file FILEPATH
[ --certificate-script-file FILEPATH
[
( --certificate-redeemer-cbor-file CBOR_FILE
| --certificate-redeemer-file JSON_FILE
| --certificate-redeemer-value JSON_VALUE
)
--certificate-execution-units (INT, INT)]
| --certificate-tx-in-reference TX-IN
( --certificate-plutus-script-v2
| --certificate-plutus-script-v3
)
( --certificate-reference-tx-in-redeemer-cbor-file CBOR_FILE
| --certificate-reference-tx-in-redeemer-file JSON_FILE
| --certificate-reference-tx-in-redeemer-value JSON_VALUE
)
--certificate-reference-tx-in-execution-units (INT, INT)
]]
--out-file FILEPATH

Create a simple signed transaction.
Expand Down
Loading

0 comments on commit 26a1017

Please sign in to comment.