Skip to content

Commit

Permalink
Remove tasty-th because it generated deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy authored and Jimbo4350 committed Sep 28, 2022
1 parent b87fb77 commit 4441c0f
Show file tree
Hide file tree
Showing 21 changed files with 244 additions and 201 deletions.
5 changes: 4 additions & 1 deletion bench/locli/src/Cardano/Analysis/Chain.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{-# LANGUAGE GeneralizedNewtypeDeriving#-}
{-# OPTIONS_GHC -Wno-deprecations -Wno-orphans #-}

{-# OPTIONS_GHC -Wno-orphans #-}

{- HLINT ignore "Use head" -}

module Cardano.Analysis.Chain (module Cardano.Analysis.Chain) where

import Cardano.Prelude hiding (head)
Expand Down
3 changes: 2 additions & 1 deletion bench/locli/src/Cardano/Analysis/ChainFilter.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StrictData #-}
{-# OPTIONS_GHC -Wno-deprecations -Wno-orphans #-}

{- HLINT ignore "Use head" -}

module Cardano.Analysis.ChainFilter (module Cardano.Analysis.ChainFilter) where

import Cardano.Prelude hiding (head)
Expand Down
1 change: 0 additions & 1 deletion cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ test-suite cardano-api-test
, tasty
, tasty-hedgehog
, tasty-quickcheck
, tasty-th
, time

other-modules: Test.Cardano.Api.Crypto
Expand Down
31 changes: 17 additions & 14 deletions cardano-api/test/Test/Cardano/Api/Json.hs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Json
( tests
) where

import Cardano.Api.Orphans ()
import Cardano.Api.Shelley
import Cardano.Prelude

import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), eitherDecode, encode)
import Data.Aeson.Types (Parser, parseEither)
import Hedgehog (Property, forAll, tripping)
import qualified Hedgehog as H
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Api
import Cardano.Api.Orphans ()
import Cardano.Api.Shelley
import Gen.Cardano.Api (genAlonzoGenesis)
import Gen.Cardano.Api.Typed
import Hedgehog (Property, forAll, tripping)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

import qualified Hedgehog as H

{- HLINT ignore "Use camelCase" -}

Expand Down Expand Up @@ -89,4 +83,13 @@ prop_json_roundtrip_scriptdata_detailed_json = H.property $ do
tripping sData scriptDataToJsonDetailedSchema scriptDataFromJsonDetailedSchema

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Json"
[ testPropertyNamed "json roundtrip alonzo genesis" "json roundtrip alonzo genesis" prop_json_roundtrip_alonzo_genesis
, testPropertyNamed "json roundtrip utxo" "json roundtrip utxo" prop_json_roundtrip_utxo
, testPropertyNamed "json roundtrip reference scripts" "json roundtrip reference scripts" prop_json_roundtrip_reference_scripts
, testPropertyNamed "json roundtrip txoutvalue" "json roundtrip txoutvalue" prop_json_roundtrip_txoutvalue
, testPropertyNamed "json roundtrip txout tx context" "json roundtrip txout tx context" prop_json_roundtrip_txout_tx_context
, testPropertyNamed "json roundtrip txout utxo context" "json roundtrip txout utxo context" prop_json_roundtrip_txout_utxo_context
, testPropertyNamed "json roundtrip eraInMode" "json roundtrip eraInMode" prop_json_roundtrip_eraInMode
, testPropertyNamed "json roundtrip scriptdata detailed json" "json roundtrip scriptdata detailed json" prop_json_roundtrip_scriptdata_detailed_json
]
19 changes: 8 additions & 11 deletions cardano-api/test/Test/Cardano/Api/KeysByron.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.KeysByron
( tests
) where

import Cardano.Prelude

import Cardano.Api (AsType(AsByronKey, AsSigningKey), Key(deterministicSigningKey))
import Cardano.Prelude ((<$>))
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR)
import Hedgehog (Property)
import Test.Cardano.Api.Typed.Orphans ()
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

import Cardano.Api
import qualified Gen.Cardano.Crypto.Seed as Gen
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR)

{- HLINT ignore "Use camelCase" -}

Expand All @@ -26,4 +21,6 @@ prop_roundtrip_byron_key_CBOR =
roundtrip_CBOR (AsSigningKey AsByronKey) (deterministicSigningKey AsByronKey <$> Gen.genSeedForKey AsByronKey)

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.KeysByron"
[ testPropertyNamed "roundtrip byron key CBOR" "roundtrip byron key CBOR" prop_roundtrip_byron_key_CBOR
]
27 changes: 12 additions & 15 deletions cardano-api/test/Test/Cardano/Api/Ledger.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Ledger
( tests
) where

import Cardano.Prelude

import Hedgehog (Property)
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Aeson as H
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Ledger.Address (deserialiseAddr, serialiseAddr)
import Cardano.Prelude (($))
import Hedgehog (Property)
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import Test.Cardano.Api.Genesis
import Test.Cardano.Api.Genesis (exampleShelleyGenesis)
import Test.Cardano.Ledger.Shelley.Serialisation.Generators.Genesis (genAddress)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

import qualified Hedgehog as H
import qualified Hedgehog.Extras.Aeson as H

prop_golden_ShelleyGenesis :: Property
prop_golden_ShelleyGenesis = H.goldenTestJsonValuePretty exampleShelleyGenesis "test/Golden/ShelleyGenesis"
Expand All @@ -37,4 +31,7 @@ prop_roundtrip_Address_CBOR = H.property $ do
-- -----------------------------------------------------------------------------

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Ledger"
[ testPropertyNamed "golden ShelleyGenesis" "golden ShelleyGenesis" prop_golden_ShelleyGenesis
, testPropertyNamed "roundtrip Address CBOR" "roundtrip Address CBOR" prop_roundtrip_Address_CBOR
]
29 changes: 18 additions & 11 deletions cardano-api/test/Test/Cardano/Api/Metadata.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Metadata
( tests
, genTxMetadata
, genTxMetadataValue
) where

import Cardano.Api
import Cardano.Prelude
import Gen.Cardano.Api.Metadata
import Hedgehog (Property, property, (===))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

import qualified Data.Aeson as Aeson
import qualified Data.Map.Strict as Map
import Hedgehog (Property, property, (===))
import qualified Hedgehog
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Api
import Gen.Cardano.Api.Metadata

-- ----------------------------------------------------------------------------
-- Golden / unit tests
Expand Down Expand Up @@ -126,4 +121,16 @@ prop_metadata_roundtrip_via_schema_json = Hedgehog.property $ do
--

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Metadata"
[ testPropertyNamed "golden 1" "golden 1" prop_golden_1
, testPropertyNamed "golden 2" "golden 2" prop_golden_2
, testPropertyNamed "golden 3" "golden 3" prop_golden_3
, testPropertyNamed "golden 4" "golden 4" prop_golden_4
, testPropertyNamed "golden 5" "golden 5" prop_golden_5
, testPropertyNamed "golden 6" "golden 6" prop_golden_6
, testPropertyNamed "golden 7" "golden 7" prop_golden_7
, testPropertyNamed "golden 8" "golden 8" prop_golden_8
, testPropertyNamed "noschema json roundtrip via metadata" "noschema json roundtrip via metadata" prop_noschema_json_roundtrip_via_metadata
, testPropertyNamed "schema json roundtrip via metadata" "schema json roundtrip via metadata" prop_schema_json_roundtrip_via_metadata
, testPropertyNamed "metadata roundtrip via schema json" "metadata roundtrip via schema json" prop_metadata_roundtrip_via_schema_json
]
24 changes: 11 additions & 13 deletions cardano-api/test/Test/Cardano/Api/Typed/Address.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Typed.Address
( tests
) where

import Cardano.Prelude

import Hedgehog (Property)
import qualified Hedgehog as H
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Api
import Gen.Cardano.Api.Typed
import Cardano.Prelude (($), Eq, Show)
import Gen.Cardano.Api.Typed (genAddressByron, genAddressShelley)
import Hedgehog (Property)
import Test.Cardano.Api.Typed.Orphans ()
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

import qualified Hedgehog as H

{- HLINT ignore "Use camelCase" -}

Expand Down Expand Up @@ -48,4 +43,7 @@ roundtrip_serialise_address asType g =
-- -----------------------------------------------------------------------------

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Typed.Address"
[ testPropertyNamed "roundtrip shelley address" "roundtrip shelley address" prop_roundtrip_shelley_address
, testPropertyNamed "roundtrip byron address" "roundtrip byron address" prop_roundtrip_byron_address
]
21 changes: 9 additions & 12 deletions cardano-api/test/Test/Cardano/Api/Typed/Bech32.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Typed.Bech32
( tests
) where

import Hedgehog (Property)
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.TH (testGroupGenerator)

import Cardano.Api
import Gen.Cardano.Api.Typed
import Cardano.Api (AsType(AsStakeAddress, AsShelleyAddress))
import Gen.Cardano.Api.Typed( genAddressShelley, genStakeAddress)
import Gen.Hedgehog.Roundtrip.Bech32 (roundtrip_Bech32)
import Hedgehog (Property)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

prop_roundtrip_Address_Shelley :: Property
prop_roundtrip_Address_Shelley = roundtrip_Bech32 AsShelleyAddress genAddressShelley
Expand All @@ -22,4 +16,7 @@ prop_roundtrip_StakeAddress :: Property
prop_roundtrip_StakeAddress = roundtrip_Bech32 AsStakeAddress genStakeAddress

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Typed.Bech32"
[ testPropertyNamed "roundtrip Address Shelley" "roundtrip Address Shelley" prop_roundtrip_Address_Shelley
, testPropertyNamed "roundtrip StakeAddress" "roundtrip StakeAddress" prop_roundtrip_StakeAddress
]
54 changes: 43 additions & 11 deletions cardano-api/test/Test/Cardano/Api/Typed/CBOR.hs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}

{-# OPTIONS_GHC -Wno-deprecations #-} -- TODO Fix deprecations

module Test.Cardano.Api.Typed.CBOR
( tests
) where

import Cardano.Api
import Cardano.Prelude
import Data.String (IsString (..))
import Gen.Cardano.Api.Typed
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR, roundtrip_CDDL_Tx)
import Gen.Hedgehog.Roundtrip.CBOR (roundtrip_CBOR)
import Hedgehog (Property, forAll, property, success, tripping)
import Test.Cardano.Api.Typed.Orphans ()
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testPropertyNamed)

{- HLINT ignore "Use camelCase" -}

Expand All @@ -25,14 +24,14 @@ import Test.Cardano.Api.Typed.Orphans ()
test_roundtrip_txbody_CBOR :: [TestTree]
test_roundtrip_txbody_CBOR =
[ testPropertyNamed (show era) (fromString (show era)) $
roundtrip_CDDL_Tx era (makeSignedTransaction [] <$> genTxBody era)
| AnyCardanoEra era <- [minBound..(AnyCardanoEra BabbageEra)]
roundtrip_CBOR (proxyToAsType Proxy) (genTxBody era)
| AnyCardanoEra era <- [minBound..(AnyCardanoEra AlonzoEra)] -- TODO: Babbage era
]

test_roundtrip_tx_CBOR :: [TestTree]
test_roundtrip_tx_CBOR =
[ testPropertyNamed (show era) (fromString (show era)) $ roundtrip_CBOR (proxyToAsType Proxy) (genTx era)
| AnyCardanoEra era <- [minBound..(AnyCardanoEra BabbageEra)]
| AnyCardanoEra era <- [minBound..(AnyCardanoEra AlonzoEra)] -- TODO: Babbage era
]

prop_roundtrip_witness_byron_CBOR :: Property
Expand Down Expand Up @@ -154,13 +153,13 @@ prop_roundtrip_UpdateProposal_CBOR =

test_roundtrip_Tx_Cddl :: [TestTree]
test_roundtrip_Tx_Cddl =
[ testProperty (show era) $ roundtrip_Tx_Cddl anyEra
[ testPropertyNamed (show era) (fromString (show era)) $ roundtrip_Tx_Cddl anyEra
| anyEra@(AnyCardanoEra era) <- [minBound..(AnyCardanoEra AlonzoEra)] --TODO: Babbage era
]

test_roundtrip_TxWitness_Cddl :: [TestTree]
test_roundtrip_TxWitness_Cddl =
[ testProperty (show era) $ roundtrip_TxWitness_Cddl era
[ testPropertyNamed (show era) (fromString (show era)) $ roundtrip_TxWitness_Cddl era
| AnyCardanoEra era <- [minBound..(AnyCardanoEra AlonzoEra)] --TODO: Babbage era
, AnyCardanoEra era /= AnyCardanoEra ByronEra
]
Expand All @@ -187,4 +186,37 @@ roundtrip_Tx_Cddl (AnyCardanoEra era) =
-- -----------------------------------------------------------------------------

tests :: TestTree
tests = $testGroupGenerator
tests = testGroup "Test.Cardano.Api.Typed.CBOR"
[ testPropertyNamed "roundtrip witness byron CBOR" "roundtrip witness byron CBOR" prop_roundtrip_witness_byron_CBOR
, testPropertyNamed "roundtrip witness shelley CBOR" "roundtrip witness shelley CBOR" prop_roundtrip_witness_shelley_CBOR
, testPropertyNamed "roundtrip witness allegra CBOR" "roundtrip witness allegra CBOR" prop_roundtrip_witness_allegra_CBOR
, testPropertyNamed "roundtrip witness mary CBOR" "roundtrip witness mary CBOR" prop_roundtrip_witness_mary_CBOR
, testPropertyNamed "roundtrip witness alonzo CBOR" "roundtrip witness alonzo CBOR" prop_roundtrip_witness_alonzo_CBOR
, testPropertyNamed "roundtrip operational certificate CBOR" "roundtrip operational certificate CBOR" prop_roundtrip_operational_certificate_CBOR
, testPropertyNamed "roundtrip operational certificate issue counter CBOR" "roundtrip operational certificate issue counter CBOR" prop_roundtrip_operational_certificate_issue_counter_CBOR
, testPropertyNamed "roundtrip verification key byron CBOR" "roundtrip verification key byron CBOR" prop_roundtrip_verification_key_byron_CBOR
, testPropertyNamed "roundtrip signing key byron CBOR" "roundtrip signing key byron CBOR" prop_roundtrip_signing_key_byron_CBOR
, testPropertyNamed "roundtrip verification key payment CBOR" "roundtrip verification key payment CBOR" prop_roundtrip_verification_key_payment_CBOR
, testPropertyNamed "roundtrip signing key payment CBOR" "roundtrip signing key payment CBOR" prop_roundtrip_signing_key_payment_CBOR
, testPropertyNamed "roundtrip verification key stake CBOR" "roundtrip verification key stake CBOR" prop_roundtrip_verification_key_stake_CBOR
, testPropertyNamed "roundtrip signing key stake CBOR" "roundtrip signing key stake CBOR" prop_roundtrip_signing_key_stake_CBOR
, testPropertyNamed "roundtrip verification key genesis CBOR" "roundtrip verification key genesis CBOR" prop_roundtrip_verification_key_genesis_CBOR
, testPropertyNamed "roundtrip signing key genesis CBOR" "roundtrip signing key genesis CBOR" prop_roundtrip_signing_key_genesis_CBOR
, testPropertyNamed "roundtrip verification key genesis delegate CBOR" "roundtrip verification key genesis delegate CBOR" prop_roundtrip_verification_key_genesis_delegate_CBOR
, testPropertyNamed "roundtrip signing key genesis delegate CBOR" "roundtrip signing key genesis delegate CBOR" prop_roundtrip_signing_key_genesis_delegate_CBOR
, testPropertyNamed "roundtrip verification key stake pool CBOR" "roundtrip verification key stake pool CBOR" prop_roundtrip_verification_key_stake_pool_CBOR
, testPropertyNamed "roundtrip signing key stake pool CBOR" "roundtrip signing key stake pool CBOR" prop_roundtrip_signing_key_stake_pool_CBOR
, testPropertyNamed "roundtrip verification key vrf CBOR" "roundtrip verification key vrf CBOR" prop_roundtrip_verification_key_vrf_CBOR
, testPropertyNamed "roundtrip signing key vrf CBOR" "roundtrip signing key vrf CBOR" prop_roundtrip_signing_key_vrf_CBOR
, testPropertyNamed "roundtrip verification key kes CBOR" "roundtrip verification key kes CBOR" prop_roundtrip_verification_key_kes_CBOR
, testPropertyNamed "roundtrip signing key kes CBOR" "roundtrip signing key kes CBOR" prop_roundtrip_signing_key_kes_CBOR
, testPropertyNamed "roundtrip script SimpleScriptV1 CBOR" "roundtrip script SimpleScriptV1 CBOR" prop_roundtrip_script_SimpleScriptV1_CBOR
, testPropertyNamed "roundtrip script SimpleScriptV2 CBOR" "roundtrip script SimpleScriptV2 CBOR" prop_roundtrip_script_SimpleScriptV2_CBOR
, testPropertyNamed "roundtrip script PlutusScriptV1 CBOR" "roundtrip script PlutusScriptV1 CBOR" prop_roundtrip_script_PlutusScriptV1_CBOR
, testPropertyNamed "roundtrip script PlutusScriptV2 CBOR" "roundtrip script PlutusScriptV2 CBOR" prop_roundtrip_script_PlutusScriptV2_CBOR
, testPropertyNamed "roundtrip UpdateProposal CBOR" "roundtrip UpdateProposal CBOR" prop_roundtrip_UpdateProposal_CBOR
, testGroup "roundtrip txbody CBOR" test_roundtrip_txbody_CBOR
, testGroup "roundtrip tx CBOR" test_roundtrip_tx_CBOR
, testGroup "roundtrip Tx Cddl" test_roundtrip_Tx_Cddl
, testGroup "roundtrip TxWitness Cddl" test_roundtrip_TxWitness_Cddl
]

0 comments on commit 4441c0f

Please sign in to comment.