Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolation of Byron era 1/n #362

Merged
merged 8 commits into from
Nov 15, 2023
1 change: 1 addition & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ library gen
hs-source-dirs: gen

exposed-modules: Test.Gen.Cardano.Api
Test.Gen.Cardano.Api.Byron
Test.Gen.Cardano.Api.Era
Test.Gen.Cardano.Api.Metadata
Test.Gen.Cardano.Api.Typed
Expand Down
54 changes: 54 additions & 0 deletions cardano-api/gen/Test/Gen/Cardano/Api/Byron.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}

module Test.Gen.Cardano.Api.Byron
( tests
) where

import Cardano.Api hiding (txIns)

import Data.Proxy

import Test.Gen.Cardano.Api.Typed

import Hedgehog
import Test.Hedgehog.Roundtrip.CBOR
import Test.Tasty
import Test.Tasty.Hedgehog

prop_byron_roundtrip_txbody_CBOR :: Property
prop_byron_roundtrip_txbody_CBOR = property $ do
let byron = ByronEra
x <- forAll $ makeSignedTransaction [] <$> genTxBodyByron
tripping x (serialiseTxLedgerCddl byron) (deserialiseTxLedgerCddl byron)


prop_byron_roundtrip_tx_CBOR :: Property
prop_byron_roundtrip_tx_CBOR = property $ do
let byron = ByronEra
x <- forAll genTxByron
cardanoEraConstraints byron $ trippingCbor (proxyToAsType Proxy) x


prop_byron_roundtrip_witness_CBOR :: Property
prop_byron_roundtrip_witness_CBOR = property $ do
let byron = ByronEra
x <- forAll genByronKeyWitness
cardanoEraConstraints byron $ trippingCbor (AsKeyWitness (proxyToAsType Proxy)) x


prop_byron_roundtrip_Tx_Cddl :: Property
prop_byron_roundtrip_Tx_Cddl = property $ do
let byron = ByronEra
x <- forAll genTxByron
tripping x (serialiseTxLedgerCddl byron) (deserialiseTxLedgerCddl byron)

tests :: TestTree
tests = testGroup "Test.Gen.Cardano.Api.Byron"
[ testProperty "Byron roundtrip txbody CBOR" prop_byron_roundtrip_txbody_CBOR
, testProperty "Byron roundtrip tx certificate CBOR" prop_byron_roundtrip_tx_CBOR
, testProperty "Byron roundtrip witness CBOR" prop_byron_roundtrip_witness_CBOR
, testProperty "Byron roundtrip tx CBOR" prop_byron_roundtrip_Tx_Cddl
]

Loading