Skip to content

Commit

Permalink
Merge pull request #362 from input-output-hk/jordan/basic-tx
Browse files Browse the repository at this point in the history
Isolation of Byron era 1/n
  • Loading branch information
Jimbo4350 authored Nov 15, 2023
2 parents 004ade6 + 26114c9 commit afa7d7c
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 171 deletions.
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

0 comments on commit afa7d7c

Please sign in to comment.