Skip to content

Commit 2e8a54a

Browse files
committed
Add mocked test for example in documentation
1 parent ab33047 commit 2e8a54a

File tree

8 files changed

+337
-70
lines changed

8 files changed

+337
-70
lines changed

cardano-api/cardano-api.cabal

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,16 @@ test-suite cardano-api-test
333333
containers,
334334
data-default,
335335
directory,
336+
filepath,
336337
hedgehog >=1.1,
337338
hedgehog-extras,
338339
hedgehog-quickcheck,
339340
interpolatedstring-perl6,
341+
lifted-base,
340342
microlens,
343+
monad-control,
341344
mtl,
345+
network,
342346
ouroboros-consensus,
343347
ouroboros-consensus-cardano,
344348
ouroboros-consensus-protocol,
@@ -362,6 +366,7 @@ test-suite cardano-api-test
362366
Test.Cardano.Api.Genesis
363367
Test.Cardano.Api.GovAnchorValidation
364368
Test.Cardano.Api.IO
369+
Test.Cardano.Api.IPCMock
365370
Test.Cardano.Api.Json
366371
Test.Cardano.Api.KeysByron
367372
Test.Cardano.Api.Ledger

cardano-api/src/Cardano/Api/Internal/Tx/Body.hs

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -969,19 +969,19 @@ toShelleyTxOut _ = \case
969969
AlonzoEraOnwardsAlonzo ->
970970
L.mkBasicTxOut (toShelleyAddr addr) value
971971
& L.dataHashTxOutL
972-
.~ toAlonzoTxOutDatumHashUTxO txoutdata
972+
.~ toAlonzoTxOutDatumHashUTxO txoutdata
973973
AlonzoEraOnwardsBabbage ->
974974
L.mkBasicTxOut (toShelleyAddr addr) value
975975
& L.datumTxOutL
976-
.~ toBabbageTxOutDatum txoutdata
976+
.~ toBabbageTxOutDatum txoutdata
977977
& L.referenceScriptTxOutL
978-
.~ refScriptToShelleyScript sbe refScript
978+
.~ refScriptToShelleyScript sbe refScript
979979
AlonzoEraOnwardsConway ->
980980
L.mkBasicTxOut (toShelleyAddr addr) value
981981
& L.datumTxOutL
982-
.~ toBabbageTxOutDatumUTxO txoutdata
982+
.~ toBabbageTxOutDatumUTxO txoutdata
983983
& L.referenceScriptTxOutL
984-
.~ refScriptToShelleyScript sbe refScript
984+
.~ refScriptToShelleyScript sbe refScript
985985
)
986986
sbe
987987

@@ -2218,9 +2218,9 @@ createTransactionBody sbe bc =
22182218
let ledgerTxBody =
22192219
mkCommonTxBody sbe (txIns bc) (txOuts bc) (txFee bc) (txWithdrawals bc) txAuxData
22202220
& A.certsTxBodyL sbe
2221-
.~ certs
2221+
.~ certs
22222222
& A.invalidHereAfterTxBodyL sbe
2223-
.~ convValidityUpperBound sbe (txValidityUpperBound bc)
2223+
.~ convValidityUpperBound sbe (txValidityUpperBound bc)
22242224
& appEndo
22252225
( mconcat
22262226
[ setUpdateProposal
@@ -3073,15 +3073,15 @@ mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData =
30733073
A.TxBody $
30743074
L.mkBasicTxBody
30753075
& L.inputsTxBodyL
3076-
.~ convTxIns txIns
3076+
.~ convTxIns txIns
30773077
& L.outputsTxBodyL
3078-
.~ convTxOuts sbe txOuts
3078+
.~ convTxOuts sbe txOuts
30793079
& L.feeTxBodyL
3080-
.~ convTransactionFee sbe txFee
3080+
.~ convTransactionFee sbe txFee
30813081
& L.withdrawalsTxBodyL
3082-
.~ convWithdrawals txWithdrawals
3082+
.~ convWithdrawals txWithdrawals
30833083
& L.auxDataHashTxBodyL
3084-
.~ maybe SNothing (SJust . Ledger.hashTxAuxData) txAuxData
3084+
.~ maybe SNothing (SJust . Ledger.hashTxAuxData) txAuxData
30853085

30863086
makeShelleyTransactionBody
30873087
:: forall era
@@ -3107,11 +3107,11 @@ makeShelleyTransactionBody
31073107
let txbody =
31083108
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
31093109
& A.certsTxBodyL sbe
3110-
.~ convCertificates sbe txCertificates
3110+
.~ convCertificates sbe txCertificates
31113111
& A.updateTxBodyL s2b
3112-
.~ update
3112+
.~ update
31133113
& A.invalidHereAfterTxBodyL sbe
3114-
.~ convValidityUpperBound sbe txValidityUpperBound
3114+
.~ convValidityUpperBound sbe txValidityUpperBound
31153115
)
31163116
^. A.txBodyL
31173117
return $
@@ -3154,13 +3154,13 @@ makeShelleyTransactionBody
31543154
let txbody =
31553155
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
31563156
& A.certsTxBodyL sbe
3157-
.~ convCertificates sbe txCertificates
3157+
.~ convCertificates sbe txCertificates
31583158
& A.invalidBeforeTxBodyL aOn
3159-
.~ convValidityLowerBound txValidityLowerBound
3159+
.~ convValidityLowerBound txValidityLowerBound
31603160
& A.invalidHereAfterTxBodyL sbe
3161-
.~ convValidityUpperBound sbe txValidityUpperBound
3161+
.~ convValidityUpperBound sbe txValidityUpperBound
31623162
& A.updateTxBodyL s2b
3163-
.~ update
3163+
.~ update
31643164
)
31653165
^. A.txBodyL
31663166
return $
@@ -3205,15 +3205,15 @@ makeShelleyTransactionBody
32053205
let txbody =
32063206
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
32073207
& A.certsTxBodyL sbe
3208-
.~ convCertificates sbe txCertificates
3208+
.~ convCertificates sbe txCertificates
32093209
& A.invalidBeforeTxBodyL aOn
3210-
.~ convValidityLowerBound txValidityLowerBound
3210+
.~ convValidityLowerBound txValidityLowerBound
32113211
& A.invalidHereAfterTxBodyL sbe
3212-
.~ convValidityUpperBound sbe txValidityUpperBound
3212+
.~ convValidityUpperBound sbe txValidityUpperBound
32133213
& A.updateTxBodyL s2b
3214-
.~ update
3214+
.~ update
32153215
& A.mintTxBodyL mOn
3216-
.~ convMintValue txMintValue
3216+
.~ convMintValue txMintValue
32173217
)
32183218
^. A.txBodyL
32193219
return $
@@ -3265,23 +3265,23 @@ makeShelleyTransactionBody
32653265
let txbody =
32663266
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
32673267
& A.collateralInputsTxBodyL azOn
3268-
.~ convCollateralTxIns txInsCollateral
3268+
.~ convCollateralTxIns txInsCollateral
32693269
& A.certsTxBodyL sbe
3270-
.~ convCertificates sbe txCertificates
3270+
.~ convCertificates sbe txCertificates
32713271
& A.invalidBeforeTxBodyL aOn
3272-
.~ convValidityLowerBound txValidityLowerBound
3272+
.~ convValidityLowerBound txValidityLowerBound
32733273
& A.invalidHereAfterTxBodyL sbe
3274-
.~ convValidityUpperBound sbe txValidityUpperBound
3274+
.~ convValidityUpperBound sbe txValidityUpperBound
32753275
& A.updateTxBodyL s2b
3276-
.~ update
3276+
.~ update
32773277
& A.reqSignerHashesTxBodyL azOn
3278-
.~ convExtraKeyWitnesses txExtraKeyWits
3278+
.~ convExtraKeyWitnesses txExtraKeyWits
32793279
& A.mintTxBodyL mOn
3280-
.~ convMintValue txMintValue
3280+
.~ convMintValue txMintValue
32813281
& A.scriptIntegrityHashTxBodyL azOn
3282-
.~ scriptIntegrityHash
3283-
-- TODO Alonzo: support optional network id in TxBodyContent
3284-
-- & L.networkIdTxBodyL .~ SNothing
3282+
.~ scriptIntegrityHash
3283+
-- TODO Alonzo: support optional network id in TxBodyContent
3284+
-- & L.networkIdTxBodyL .~ SNothing
32853285
)
32863286
^. A.txBodyL
32873287
return $
@@ -3387,29 +3387,29 @@ makeShelleyTransactionBody
33873387
let txbody =
33883388
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
33893389
& A.collateralInputsTxBodyL azOn
3390-
.~ convCollateralTxIns txInsCollateral
3390+
.~ convCollateralTxIns txInsCollateral
33913391
& A.referenceInputsTxBodyL bOn
3392-
.~ convReferenceInputs txInsReference
3392+
.~ convReferenceInputs txInsReference
33933393
& A.collateralReturnTxBodyL bOn
3394-
.~ convReturnCollateral sbe txReturnCollateral
3394+
.~ convReturnCollateral sbe txReturnCollateral
33953395
& A.totalCollateralTxBodyL bOn
3396-
.~ convTotalCollateral txTotalCollateral
3396+
.~ convTotalCollateral txTotalCollateral
33973397
& A.certsTxBodyL sbe
3398-
.~ convCertificates sbe txCertificates
3398+
.~ convCertificates sbe txCertificates
33993399
& A.invalidBeforeTxBodyL aOn
3400-
.~ convValidityLowerBound txValidityLowerBound
3400+
.~ convValidityLowerBound txValidityLowerBound
34013401
& A.invalidHereAfterTxBodyL sbe
3402-
.~ convValidityUpperBound sbe txValidityUpperBound
3402+
.~ convValidityUpperBound sbe txValidityUpperBound
34033403
& A.updateTxBodyL s2b
3404-
.~ update
3404+
.~ update
34053405
& A.reqSignerHashesTxBodyL azOn
3406-
.~ convExtraKeyWitnesses txExtraKeyWits
3406+
.~ convExtraKeyWitnesses txExtraKeyWits
34073407
& A.mintTxBodyL mOn
3408-
.~ convMintValue txMintValue
3408+
.~ convMintValue txMintValue
34093409
& A.scriptIntegrityHashTxBodyL azOn
3410-
.~ scriptIntegrityHash
3411-
-- TODO Babbage: support optional network id in TxBodyContent
3412-
-- & L.networkIdTxBodyL .~ SNothing
3410+
.~ scriptIntegrityHash
3411+
-- TODO Babbage: support optional network id in TxBodyContent
3412+
-- & L.networkIdTxBodyL .~ SNothing
34133413
)
34143414
^. A.txBodyL
34153415
return $
@@ -3529,37 +3529,37 @@ makeShelleyTransactionBody
35293529
let txbody =
35303530
( mkCommonTxBody sbe txIns txOuts txFee txWithdrawals txAuxData
35313531
& A.collateralInputsTxBodyL azOn
3532-
.~ case txInsCollateral of
3533-
TxInsCollateralNone -> Set.empty
3534-
TxInsCollateral _ txins -> fromList (map toShelleyTxIn txins)
3532+
.~ case txInsCollateral of
3533+
TxInsCollateralNone -> Set.empty
3534+
TxInsCollateral _ txins -> fromList (map toShelleyTxIn txins)
35353535
& A.referenceInputsTxBodyL bOn
3536-
.~ convReferenceInputs txInsReference
3536+
.~ convReferenceInputs txInsReference
35373537
& A.collateralReturnTxBodyL bOn
3538-
.~ convReturnCollateral sbe txReturnCollateral
3538+
.~ convReturnCollateral sbe txReturnCollateral
35393539
& A.totalCollateralTxBodyL bOn
3540-
.~ convTotalCollateral txTotalCollateral
3540+
.~ convTotalCollateral txTotalCollateral
35413541
& A.certsTxBodyL sbe
3542-
.~ convCertificates sbe txCertificates
3542+
.~ convCertificates sbe txCertificates
35433543
& A.invalidBeforeTxBodyL aOn
3544-
.~ convValidityLowerBound txValidityLowerBound
3544+
.~ convValidityLowerBound txValidityLowerBound
35453545
& A.invalidHereAfterTxBodyL sbe
3546-
.~ convValidityUpperBound sbe txValidityUpperBound
3546+
.~ convValidityUpperBound sbe txValidityUpperBound
35473547
& A.reqSignerHashesTxBodyL azOn
3548-
.~ convExtraKeyWitnesses txExtraKeyWits
3548+
.~ convExtraKeyWitnesses txExtraKeyWits
35493549
& A.mintTxBodyL mOn
3550-
.~ convMintValue txMintValue
3550+
.~ convMintValue txMintValue
35513551
& A.scriptIntegrityHashTxBodyL azOn
3552-
.~ scriptIntegrityHash
3552+
.~ scriptIntegrityHash
35533553
& A.votingProceduresTxBodyL cOn
3554-
.~ convVotingProcedures (maybe TxVotingProceduresNone unFeatured txVotingProcedures)
3554+
.~ convVotingProcedures (maybe TxVotingProceduresNone unFeatured txVotingProcedures)
35553555
& A.proposalProceduresTxBodyL cOn
3556-
.~ convProposalProcedures (maybe TxProposalProceduresNone unFeatured txProposalProcedures)
3556+
.~ convProposalProcedures (maybe TxProposalProceduresNone unFeatured txProposalProcedures)
35573557
& A.currentTreasuryValueTxBodyL cOn
3558-
.~ Ledger.maybeToStrictMaybe (unFeatured =<< txCurrentTreasuryValue)
3558+
.~ Ledger.maybeToStrictMaybe (unFeatured =<< txCurrentTreasuryValue)
35593559
& A.treasuryDonationTxBodyL cOn
3560-
.~ maybe (L.Coin 0) unFeatured txTreasuryDonation
3561-
-- TODO Conway: support optional network id in TxBodyContent
3562-
-- & L.networkIdTxBodyL .~ SNothing
3560+
.~ maybe (L.Coin 0) unFeatured txTreasuryDonation
3561+
-- TODO Conway: support optional network id in TxBodyContent
3562+
-- & L.networkIdTxBodyL .~ SNothing
35633563
)
35643564
^. A.txBodyL
35653565
return $
@@ -3665,19 +3665,19 @@ toShelleyTxOutAny _ = \case
36653665
AlonzoEraOnwardsAlonzo ->
36663666
L.mkBasicTxOut (toShelleyAddr addr) value
36673667
& L.dataHashTxOutL
3668-
.~ toAlonzoTxOutDatumHash txoutdata
3668+
.~ toAlonzoTxOutDatumHash txoutdata
36693669
AlonzoEraOnwardsBabbage ->
36703670
L.mkBasicTxOut (toShelleyAddr addr) value
36713671
& L.datumTxOutL
3672-
.~ toBabbageTxOutDatum txoutdata
3672+
.~ toBabbageTxOutDatum txoutdata
36733673
& L.referenceScriptTxOutL
3674-
.~ refScriptToShelleyScript sbe refScript
3674+
.~ refScriptToShelleyScript sbe refScript
36753675
AlonzoEraOnwardsConway ->
36763676
L.mkBasicTxOut (toShelleyAddr addr) value
36773677
& L.datumTxOutL
3678-
.~ toBabbageTxOutDatum txoutdata
3678+
.~ toBabbageTxOutDatum txoutdata
36793679
& L.referenceScriptTxOutL
3680-
.~ refScriptToShelleyScript sbe refScript
3680+
.~ refScriptToShelleyScript sbe refScript
36813681
)
36823682
sbe
36833683

0 commit comments

Comments
 (0)