|
13 | 13 | import Cardano.Api |
14 | 14 | import Cardano.Api.Internal.Script |
15 | 15 | import Cardano.Api.Internal.SerialiseLedgerCddl (cddlTypeToEra) |
| 16 | +import Cardano.Api.Internal.SerialiseTextEnvelope (TextEnvelopeDescr (TextEnvelopeDescr)) |
16 | 17 | import Cardano.Api.Shelley (AsType (..)) |
17 | 18 |
|
18 | 19 | import qualified Data.ByteString.Base16 as Base16 |
@@ -40,6 +41,30 @@ import Test.Tasty.Hedgehog (testProperty) |
40 | 41 | -- TODO: Need to add PaymentExtendedKey roundtrip tests however |
41 | 42 | -- we can't derive an Eq instance for Crypto.HD.XPrv |
42 | 43 |
|
| 44 | +prop_text_envelope_roundtrip_txbody_CBOR :: Property |
| 45 | +prop_text_envelope_roundtrip_txbody_CBOR = H.property $ do |
| 46 | + AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound] |
| 47 | + x <- H.forAll $ makeSignedTransaction [] . fst <$> genValidTxBody era |
| 48 | + shelleyBasedEraConstraints |
| 49 | + era |
| 50 | + ( H.tripping |
| 51 | + x |
| 52 | + (serialiseToTextEnvelope (Just (TextEnvelopeDescr "Ledger Cddl Format"))) |
| 53 | + (deserialiseFromTextEnvelope (shelleyBasedEraConstraints era $ proxyToAsType Proxy)) |
| 54 | + ) |
| 55 | + |
| 56 | +prop_text_envelope_roundtrip_tx_CBOR :: Property |
| 57 | +prop_text_envelope_roundtrip_tx_CBOR = H.property $ do |
| 58 | + AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound] |
| 59 | + x <- H.forAll $ genTx era |
| 60 | + shelleyBasedEraConstraints |
| 61 | + era |
| 62 | + ( H.tripping |
| 63 | + x |
| 64 | + (serialiseToTextEnvelope (Just (TextEnvelopeDescr "Ledger Cddl Format"))) |
| 65 | + (deserialiseFromTextEnvelope (shelleyBasedEraConstraints era $ proxyToAsType Proxy)) |
| 66 | + ) |
| 67 | + |
43 | 68 | prop_roundtrip_tx_CBOR :: Property |
44 | 69 | prop_roundtrip_tx_CBOR = H.property $ do |
45 | 70 | AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound] |
@@ -286,7 +311,9 @@ tests :: TestTree |
286 | 311 | tests = |
287 | 312 | testGroup |
288 | 313 | "Test.Cardano.Api.Typed.CBOR" |
289 | | - [ testProperty "roundtrip witness CBOR" prop_roundtrip_witness_CBOR |
| 314 | + [ testProperty "rountrip txbody text envelope" prop_text_envelope_roundtrip_txbody_CBOR |
| 315 | + , testProperty "rountrip tx text envelope" prop_text_envelope_roundtrip_tx_CBOR |
| 316 | + , testProperty "roundtrip witness CBOR" prop_roundtrip_witness_CBOR |
290 | 317 | , testProperty |
291 | 318 | "roundtrip operational certificate CBOR" |
292 | 319 | prop_roundtrip_operational_certificate_CBOR |
|
0 commit comments