Skip to content

Commit 2225a37

Browse files
committed
Specialise roundtrip test to hash supplemental datums before testing
1 parent 2d823ea commit 2225a37

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
@@ -113,12 +113,15 @@ prop_roundtrip_tx_out_CBOR = H.property $ do
113113
AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound]
114114
x <- H.forAll $ genTx era
115115
txOut <- H.forAll $ Gen.element $ txOuts $ getTxBodyContent $ getTxBody x
116-
txOutRT <- H.evalEither $ rtOnce era txOut -- We do this because some information gets lost on serialisation
117-
shelleyBasedEraConstraints era $ H.trippingCbor (proxyToAsType Proxy) txOutRT
116+
let fixedTxOut = hashDatum txOut
117+
shelleyBasedEraConstraints era $ H.trippingCbor (proxyToAsType Proxy) fixedTxOut
118118
where
119-
rtOnce
120-
:: ShelleyBasedEra era -> TxOut CtxTx era -> Either CBOR.DecoderError (TxOut CtxTx era)
121-
rtOnce sbe t = shelleyBasedEraConstraints sbe $ deserialiseFromCBOR (proxyToAsType Proxy) (serialiseToCBOR t)
119+
hashDatum :: TxOut CtxTx era -> TxOut CtxTx era
120+
hashDatum txOut@(TxOut aie val datum rs) =
121+
case datum of
122+
(TxOutSupplementalDatum aeo d) ->
123+
TxOut aie val (TxOutDatumHash aeo (hashScriptDataBytes d)) rs
124+
_ -> txOut
122125

123126
prop_roundtrip_witness_CBOR :: Property
124127
prop_roundtrip_witness_CBOR = H.property $ do

0 commit comments

Comments
 (0)