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 25, 2024
1 parent 7965ce2 commit bd0fc1e
Show file tree
Hide file tree
Showing 10 changed files with 566 additions and 8 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
21 changes: 13 additions & 8 deletions cardano-cli/src/Cardano/CLI/Compatible/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ runCompatibleTransactionCmd
]
-- 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 +271,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 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 bd0fc1e

Please sign in to comment.