Skip to content

Commit e9c48c5

Browse files
committed
Specialise roundtrip test to hash supplemental datums before testing
1 parent 42577bd commit e9c48c5

File tree

1 file changed

+8
-5
lines changed
  • cardano-api/test/cardano-api-test/Test/Cardano/Api

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ prop_roundtrip_tx_out_CBOR = H.property $ do
115115
AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound]
116116
x <- H.forAll $ genTx era
117117
txOut <- H.forAll $ Gen.element $ txOuts $ getTxBodyContent $ getTxBody x
118-
txOutRT <- H.evalEither $ rtOnce era txOut -- We do this because some information gets lost on serialisation
119-
shelleyBasedEraConstraints era $ H.trippingCbor (proxyToAsType Proxy) txOutRT
118+
let fixedTxOut = hashDatum txOut
119+
shelleyBasedEraConstraints era $ H.trippingCbor (proxyToAsType Proxy) fixedTxOut
120120
where
121-
rtOnce
122-
:: ShelleyBasedEra era -> TxOut CtxTx era -> Either CBOR.DecoderError (TxOut CtxTx era)
123-
rtOnce sbe t = shelleyBasedEraConstraints sbe $ deserialiseFromCBOR (proxyToAsType Proxy) (serialiseToCBOR t)
121+
hashDatum :: TxOut CtxTx era -> TxOut CtxTx era
122+
hashDatum txOut@(TxOut aie val datum rs) =
123+
case datum of
124+
(TxOutSupplementalDatum aeo d) ->
125+
(TxOut aie val (TxOutDatumHash aeo (hashScriptDataBytes d)) rs)
126+
_ -> txOut
124127

125128
prop_roundtrip_witness_CBOR :: Property
126129
prop_roundtrip_witness_CBOR = H.property $ do

0 commit comments

Comments
 (0)