{-# LANGUAGE TemplateHaskell #-}

module Test.Cardano.Crypto.Json (
  tests,
)
where

import Cardano.Prelude
import GetDataFileName ((<:<))
import Hedgehog (Property)
import qualified Hedgehog as H
import Test.Cardano.Crypto.Example (
  exampleProtocolMagic3,
  exampleProtocolMagic4,
 )
import Test.Cardano.Prelude

--------------------------------------------------------------------------------
-- ProtocolMagic
--------------------------------------------------------------------------------

-- Legacy JSON encoding where requiresNetworkMagic was
-- encoded as "NMMustBeNothing" or "NMMustBeJust"

goldenProtocolMagic3AesonDec_NMMustBeJust :: Property
goldenProtocolMagic3AesonDec_NMMustBeJust :: Property
goldenProtocolMagic3AesonDec_NMMustBeJust =
  forall a.
(Eq a, FromJSON a, HasCallStack, Show a) =>
a -> FilePath -> Property
goldenTestJSONDec
    ProtocolMagic
exampleProtocolMagic3
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/json/ProtocolMagic_Legacy_NMMustBeJust"

goldenProtocolMagic4AesonDec_NMMustBeNothing :: Property
goldenProtocolMagic4AesonDec_NMMustBeNothing :: Property
goldenProtocolMagic4AesonDec_NMMustBeNothing =
  forall a.
(Eq a, FromJSON a, HasCallStack, Show a) =>
a -> FilePath -> Property
goldenTestJSONDec
    ProtocolMagic
exampleProtocolMagic4
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/json/ProtocolMagic_Legacy_NMMustBeNothing"

tests :: IO Bool
tests :: IO Bool
tests = forall (m :: * -> *). MonadIO m => Group -> m Bool
H.checkSequential $$FilePath
[(PropertyName, Property)]
Property
FilePath -> PropertyName
FilePath -> GroupName
GroupName -> [(PropertyName, Property)] -> Group
goldenProtocolMagic4AesonDec_NMMustBeNothing :: Property
goldenProtocolMagic3AesonDec_NMMustBeJust :: Property
discoverGolden