Skip to content

Commit

Permalink
cardano-api:test: Make CBOR tests simpler and more future-proof
Browse files Browse the repository at this point in the history
using exhaustive era enumeration
  • Loading branch information
cblp committed Oct 15, 2021
1 parent a5dec5d commit a78791d
Showing 1 changed file with 20 additions and 45 deletions.
65 changes: 20 additions & 45 deletions cardano-api/test/Test/Cardano/Api/Typed/CBOR.hs
Expand Up @@ -5,61 +5,36 @@ module Test.Cardano.Api.Typed.CBOR
( tests
) where

import Cardano.Api

import Gen.Cardano.Api.Typed
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR)
import Cardano.Prelude

import Hedgehog (Property)
import Test.Cardano.Api.Typed.Orphans ()
import Test.Tasty (TestTree)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Api

import Test.Cardano.Api.Typed.Orphans ()
import Gen.Cardano.Api.Typed
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR)

{- HLINT ignore "Use camelCase" -}

-- TODO: Need to add PaymentExtendedKey roundtrip tests however
-- we can't derive an Eq instance for Crypto.HD.XPrv

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

prop_roundtrip_txbody_shelley_CBOR :: Property
prop_roundtrip_txbody_shelley_CBOR =
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_txbody_alonzo_CBOR :: Property
prop_roundtrip_txbody_alonzo_CBOR =
roundtrip_CBOR (AsTxBody AsAlonzoEra) (genTxBody AlonzoEra)

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

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

prop_roundtrip_tx_allegra_CBOR :: Property
prop_roundtrip_tx_allegra_CBOR =
roundtrip_CBOR (AsTx AsAllegraEra) (genTx AllegraEra)

prop_roundtrip_tx_mary_CBOR :: Property
prop_roundtrip_tx_mary_CBOR =
roundtrip_CBOR (AsTx AsMaryEra) (genTx MaryEra)

prop_roundtrip_tx_alonzo_CBOR :: Property
prop_roundtrip_tx_alonzo_CBOR =
roundtrip_CBOR (AsTx AsAlonzoEra) (genTx AlonzoEra)
test_roundtrip_txbody_CBOR :: [TestTree]
test_roundtrip_txbody_CBOR =
[ testProperty (show era) $
roundtrip_CBOR (proxyToAsType Proxy) (genTxBody era)
| AnyCardanoEra era <- [minBound..]
]

test_roundtrip_tx_CBOR :: [TestTree]
test_roundtrip_tx_CBOR =
[ testProperty (show era) $ roundtrip_CBOR (proxyToAsType Proxy) (genTx era)
| AnyCardanoEra era <- [minBound..]
]

prop_roundtrip_witness_byron_CBOR :: Property
prop_roundtrip_witness_byron_CBOR =
Expand Down

0 comments on commit a78791d

Please sign in to comment.