Skip to content

Commit

Permalink
Add generators and tests for new API tx-related types
Browse files Browse the repository at this point in the history
  • Loading branch information
intricate committed Nov 25, 2020
1 parent e0c493d commit c4494f4
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 68 deletions.
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ module Cardano.API (
-- ** Era-dependent transaction body features
OnlyAdaSupportedInEra(..),
MultiAssetSupportedInEra(..),
TxFeesExplicitInEra (..),
ValidityUpperBoundSupportedInEra(..),
ValidityNoUpperBoundSupportedInEra(..),
ValidityLowerBoundSupportedInEra(..),
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module Cardano.Api.TxBody (
-- * Era-dependent transaction body features
OnlyAdaSupportedInEra(..),
MultiAssetSupportedInEra(..),
TxFeesExplicitInEra (..),
ValidityUpperBoundSupportedInEra(..),
ValidityNoUpperBoundSupportedInEra(..),
ValidityLowerBoundSupportedInEra(..),
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ module Cardano.Api.Typed (
-- ** Era-dependent transaction body features
OnlyAdaSupportedInEra(..),
MultiAssetSupportedInEra(..),
TxFeesExplicitInEra (..),
ValidityUpperBoundSupportedInEra(..),
ValidityNoUpperBoundSupportedInEra(..),
ValidityLowerBoundSupportedInEra(..),
Expand Down Expand Up @@ -801,4 +802,3 @@ submitTxToNodeLocal connctInfo tx = do
pure $ SendMsgSubmitTx tx $ \result -> do
atomically $ putTMVar resultVar result
pure (TxSubmission.SendMsgDone ())

1 change: 1 addition & 0 deletions cardano-api/test/Test/Cardano/Api/MetaData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE TemplateHaskell #-}
module Test.Cardano.Api.MetaData
( tests
, genTxMetadata
) where

import Cardano.Prelude hiding (MetaData)
Expand Down
46 changes: 35 additions & 11 deletions cardano-api/test/Test/Cardano/Api/Typed/CBOR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,43 @@ import qualified Hedgehog as H

prop_roundtrip_txbody_byron_CBOR :: Property
prop_roundtrip_txbody_byron_CBOR =
roundtrip_CBOR AsByronTxBody genTxBodyByron
roundtrip_CBOR (AsTxBody AsByronEra) (genTxBody ByronEra)

prop_roundtrip_txbody_shelley_CBOR :: Property
prop_roundtrip_txbody_shelley_CBOR =
roundtrip_CBOR AsShelleyTxBody genTxBodyShelley
roundtrip_CBOR (AsTxBody AsShelleyEra) (genTxBody ShelleyEra)

prop_roundtrip_txbody_allegra_CBOR :: Property
prop_roundtrip_txbody_allegra_CBOR =
roundtrip_CBOR (AsTxBody AsAllegraEra) (genTxBody AllegraEra)

prop_roundtrip_txbody_mary_CBOR :: Property
prop_roundtrip_txbody_mary_CBOR =
roundtrip_CBOR (AsTxBody AsMaryEra) (genTxBody MaryEra)

prop_roundtrip_tx_byron_CBOR :: Property
prop_roundtrip_tx_byron_CBOR =
roundtrip_CBOR AsByronTx genTxByron
roundtrip_CBOR (AsTx AsByronEra) (genTx ByronEra)

prop_roundtrip_tx_shelley_CBOR :: Property
prop_roundtrip_tx_shelley_CBOR =
roundtrip_CBOR AsShelleyTx genTxShelley
roundtrip_CBOR (AsTx AsShelleyEra) (genTx ShelleyEra)

prop_roundtrip_witness_byron_CBOR :: Property
prop_roundtrip_witness_byron_CBOR =
roundtrip_CBOR (AsWitness AsByronEra) genByronKeyWitness

prop_roundtrip_witness_shelley_CBOR :: Property
prop_roundtrip_witness_shelley_CBOR =
roundtrip_CBOR AsShelleyWitness genShelleyWitness
roundtrip_CBOR (AsWitness AsShelleyEra) (genShelleyWitness ShelleyEra)

prop_roundtrip_witness_byron_CBOR :: Property
prop_roundtrip_witness_byron_CBOR =
roundtrip_CBOR AsByronWitness genByronKeyWitness
prop_roundtrip_witness_allegra_CBOR :: Property
prop_roundtrip_witness_allegra_CBOR =
roundtrip_CBOR (AsWitness AsAllegraEra) (genShelleyWitness AllegraEra)

prop_roundtrip_witness_mary_CBOR :: Property
prop_roundtrip_witness_mary_CBOR =
roundtrip_CBOR (AsWitness AsMaryEra) (genShelleyWitness MaryEra)

prop_roundtrip_operational_certificate_CBOR :: Property
prop_roundtrip_operational_certificate_CBOR =
Expand Down Expand Up @@ -116,9 +132,17 @@ prop_roundtrip_signing_key_kes_CBOR :: Property
prop_roundtrip_signing_key_kes_CBOR =
roundtrip_CBOR (AsSigningKey AsKesKey) (genSigningKey AsKesKey)

prop_roundtrip_script_CBOR :: Property
prop_roundtrip_script_CBOR =
roundtrip_CBOR (AsScript AsShelleyEra) genScript
prop_roundtrip_script_shelley_CBOR :: Property
prop_roundtrip_script_shelley_CBOR =
roundtrip_CBOR (AsScript AsShelleyEra) (genScript ShelleyBasedEraShelley)

prop_roundtrip_script_allegra_CBOR :: Property
prop_roundtrip_script_allegra_CBOR =
roundtrip_CBOR (AsScript AsAllegraEra) (genScript ShelleyBasedEraAllegra)

prop_roundtrip_script_mary_CBOR :: Property
prop_roundtrip_script_mary_CBOR =
roundtrip_CBOR (AsScript AsMaryEra) (genScript ShelleyBasedEraMary)

-- -----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit c4494f4

Please sign in to comment.