Skip to content

Commit 85485f6

Browse files
committed
Address review feedback on babbageOnwardsTxOutParseJson and test coverage
Fail when inlineDatumhash is present without inlineDatumRaw, symmetric with the existing check for the opposite case. Correct the Haddock and add an explanatory comment for the Dijkstra skip in prop_new_txout_json_roundtrip.
1 parent 223fb95 commit 85485f6

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

  • cardano-api
    • src/Cardano/Api/Experimental/Tx/Internal/BodyContent
    • test/cardano-api-test/Test/Cardano/Api

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,12 @@ babbageOnwardsTxOutParseJson o = do
580580
<> ", got "
581581
<> show (L.hashBinaryData binaryData)
582582
pure $ L.Datum binaryData
583-
Nothing -> case mDatumHash of
584-
Just dh -> pure $ L.DatumHash dh
585-
Nothing -> pure L.NoDatum
583+
Nothing -> do
584+
when (isJust mInlineDatumHash) $
585+
fail "babbageOnwardsTxOutParseJson: inlineDatumhash present without inlineDatumRaw"
586+
case mDatumHash of
587+
Just dh -> pure $ L.DatumHash dh
588+
Nothing -> pure L.NoDatum
586589
-- Determine reference script
587590
refScript <- case mRefScript of
588591
Nothing -> pure SNothing

cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ go sbe = do
9494
toJSON oldTxOut === toJSON newTxOut
9595

9696
-- | Verify that the new experimental 'TxOut' round-trips through JSON
97-
-- (encode then decode) for all Shelley-based eras.
97+
-- (encode then decode) for all Shelley-based eras except Dijkstra, for which
98+
-- 'shelleyBasedEraConstraints' is not yet implemented.
9899
prop_new_txout_json_roundtrip :: Property
99100
prop_new_txout_json_roundtrip = H.property $ do
100101
AnyShelleyBasedEra sbe <- forAll $ Gen.element [minBound .. maxBound]
@@ -105,7 +106,7 @@ prop_new_txout_json_roundtrip = H.property $ do
105106
ShelleyBasedEraAlonzo -> goRoundtrip sbe
106107
ShelleyBasedEraBabbage -> goRoundtrip sbe
107108
ShelleyBasedEraConway -> goRoundtrip sbe
108-
ShelleyBasedEraDijkstra -> pure ()
109+
ShelleyBasedEraDijkstra -> pure () -- shelleyBasedEraConstraints not yet implemented
109110

110111
goRoundtrip
111112
:: ( L.EraTxOut (ShelleyLedgerEra era)

0 commit comments

Comments
 (0)