{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

module Test.Cardano.Chain.Ssc.CBOR (
  tests,
)
where

import Cardano.Chain.Ssc (
  SscPayload (..),
  SscProof (..),
  dropCommitment,
  dropCommitmentsMap,
  dropInnerSharesMap,
  dropOpeningsMap,
  dropSharesMap,
  dropSignedCommitment,
  dropSscPayload,
  dropSscProof,
  dropVssCertificate,
  dropVssCertificatesMap,
 )
import Cardano.Ledger.Binary (dropBytes)
import Cardano.Prelude
import GetDataFileName ((<:<))
import Hedgehog (Group (..), Property)
import Test.Cardano.Ledger.Binary.Vintage.Helpers.GoldenRoundTrip (
  deprecatedGoldenDecode,
  roundTripsCBORShow,
 )
import Test.Cardano.Prelude
import Test.Options (concatGroups)

--------------------------------------------------------------------------------
-- Commitment
--------------------------------------------------------------------------------

goldenDeprecatedCommitment :: Property
goldenDeprecatedCommitment :: Property
goldenDeprecatedCommitment =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"Commitment"
    forall s. Decoder s ()
dropCommitment
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/Commitment"

--------------------------------------------------------------------------------
-- CommitmentsMap
--------------------------------------------------------------------------------

goldenDeprecatedCommitmentsMap :: Property
goldenDeprecatedCommitmentsMap :: Property
goldenDeprecatedCommitmentsMap =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"CommitmentsMap"
    forall s. Decoder s ()
dropCommitmentsMap
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/CommitmentsMap"

--------------------------------------------------------------------------------
-- InnerSharesMap
--------------------------------------------------------------------------------

goldenDeprecatedInnerSharesMap :: Property
goldenDeprecatedInnerSharesMap :: Property
goldenDeprecatedInnerSharesMap =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"InnerSharesMap"
    forall s. Decoder s ()
dropInnerSharesMap
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/InnerSharesMap"

--------------------------------------------------------------------------------
-- Opening
--------------------------------------------------------------------------------

goldenDeprecatedOpening :: Property
goldenDeprecatedOpening :: Property
goldenDeprecatedOpening =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode Text
"Opening" forall s. Decoder s ()
dropBytes (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/Opening"

--------------------------------------------------------------------------------
-- OpeningsMap
--------------------------------------------------------------------------------

goldenDeprecatedOpeningsMap :: Property
goldenDeprecatedOpeningsMap :: Property
goldenDeprecatedOpeningsMap =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"OpeningsMap"
    forall s. Decoder s ()
dropOpeningsMap
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/OpeningsMap"

--------------------------------------------------------------------------------
-- SignedCommitment
--------------------------------------------------------------------------------

goldenDeprecatedSignedCommitment :: Property
goldenDeprecatedSignedCommitment :: Property
goldenDeprecatedSignedCommitment =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SignedCommitment"
    forall s. Decoder s ()
dropSignedCommitment
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SignedCommitment"

--------------------------------------------------------------------------------
-- SharesMap
--------------------------------------------------------------------------------

goldenDeprecatedSharesMap :: Property
goldenDeprecatedSharesMap :: Property
goldenDeprecatedSharesMap =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SharesMap"
    forall s. Decoder s ()
dropSharesMap
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SharesMap"

--------------------------------------------------------------------------------
-- SscPayload
--------------------------------------------------------------------------------

goldenDeprecatedSscPayload_CommitmentsPayload :: Property
goldenDeprecatedSscPayload_CommitmentsPayload :: Property
goldenDeprecatedSscPayload_CommitmentsPayload =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscPayload_CommitmentsPayload"
    forall s. Decoder s ()
dropSscPayload
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscPayload_CommitmentsPayload"

goldenDeprecatedSscPayload_OpeningsPayload :: Property
goldenDeprecatedSscPayload_OpeningsPayload :: Property
goldenDeprecatedSscPayload_OpeningsPayload =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscPayload_OpeningsPayload"
    forall s. Decoder s ()
dropSscPayload
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscPayload_OpeningsPayload"

goldenDeprecatedSscPayload_SharesPayload :: Property
goldenDeprecatedSscPayload_SharesPayload :: Property
goldenDeprecatedSscPayload_SharesPayload =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscPayload_SharesPayload"
    forall s. Decoder s ()
dropSscPayload
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscPayload_SharesPayload"

goldenDeprecatedSscPayload_CertificatesPayload :: Property
goldenDeprecatedSscPayload_CertificatesPayload :: Property
goldenDeprecatedSscPayload_CertificatesPayload =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscPayload_CertificatesPayload"
    forall s. Decoder s ()
dropSscPayload
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscPayload_CertificatesPayload"

roundTripSscPayload :: Property
roundTripSscPayload :: Property
roundTripSscPayload = forall a.
(Show a, HasCallStack) =>
TestLimit -> Gen a -> (a -> PropertyT IO ()) -> Property
eachOf TestLimit
1 (forall (f :: * -> *) a. Applicative f => a -> f a
pure SscPayload
SscPayload) forall a (m :: * -> *).
(DecCBOR a, EncCBOR a, Eq a, MonadTest m, Show a, HasCallStack) =>
a -> m ()
roundTripsCBORShow

--------------------------------------------------------------------------------
-- SscProof
--------------------------------------------------------------------------------

goldenDeprecatedSscProof_CommitmentsProof :: Property
goldenDeprecatedSscProof_CommitmentsProof :: Property
goldenDeprecatedSscProof_CommitmentsProof =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscProof_CommitmentsProof"
    forall s. Decoder s ()
dropSscProof
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscProof_CommitmentsProof"

goldenDeprecatedSscProof_OpeningsProof :: Property
goldenDeprecatedSscProof_OpeningsProof :: Property
goldenDeprecatedSscProof_OpeningsProof =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscProof_OpeningsProof"
    forall s. Decoder s ()
dropSscProof
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscProof_OpeningsProof"

goldenDeprecatedSscProof_SharesProof :: Property
goldenDeprecatedSscProof_SharesProof :: Property
goldenDeprecatedSscProof_SharesProof =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscProof_SharesProof"
    forall s. Decoder s ()
dropSscProof
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscProof_SharesProof"

goldenDeprecatedSscProof_CertificatesProof :: Property
goldenDeprecatedSscProof_CertificatesProof :: Property
goldenDeprecatedSscProof_CertificatesProof =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"SscProof_CertificatesProof"
    forall s. Decoder s ()
dropSscProof
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/SscProof_CertificatesProof"

roundTripSscProof :: Property
roundTripSscProof :: Property
roundTripSscProof = forall a.
(Show a, HasCallStack) =>
TestLimit -> Gen a -> (a -> PropertyT IO ()) -> Property
eachOf TestLimit
1 (forall (f :: * -> *) a. Applicative f => a -> f a
pure SscProof
SscProof) forall a (m :: * -> *).
(DecCBOR a, EncCBOR a, Eq a, MonadTest m, Show a, HasCallStack) =>
a -> m ()
roundTripsCBORShow

--------------------------------------------------------------------------------
-- VssCertificate
--------------------------------------------------------------------------------

goldenDeprecatedVssCertificate :: Property
goldenDeprecatedVssCertificate :: Property
goldenDeprecatedVssCertificate =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"VssCertificate"
    forall s. Decoder s ()
dropVssCertificate
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/VssCertificate"

--------------------------------------------------------------------------------
-- VssCertificatesHash
--------------------------------------------------------------------------------

goldenDeprecatedVssCertificatesHash :: Property
goldenDeprecatedVssCertificatesHash :: Property
goldenDeprecatedVssCertificatesHash =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"VssCertiificatesHash"
    forall s. Decoder s ()
dropBytes
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/VssCertificatesHash"

--------------------------------------------------------------------------------
-- VssCertificatesMap
--------------------------------------------------------------------------------

goldenDeprecatedVssCertificatesMap :: Property
goldenDeprecatedVssCertificatesMap :: Property
goldenDeprecatedVssCertificatesMap =
  HasCallStack =>
Text -> (forall s. Decoder s ()) -> FilePath -> Property
deprecatedGoldenDecode
    Text
"VssCertificatesMap"
    forall s. Decoder s ()
dropVssCertificatesMap
    (FilePath -> Property) -> FilePath -> Property
<:< FilePath
"golden/cbor/ssc/VssCertificatesMap"

--------------------------------------------------------------------------------
-- Main test export
--------------------------------------------------------------------------------

tests :: Group
tests :: Group
tests = [Group] -> Group
concatGroups [$$FilePath
[(PropertyName, Property)]
Property
FilePath -> PropertyName
FilePath -> GroupName
GroupName -> [(PropertyName, Property)] -> Group
goldenDeprecatedVssCertificatesMap :: Property
goldenDeprecatedVssCertificatesHash :: Property
goldenDeprecatedVssCertificate :: Property
goldenDeprecatedSscProof_CertificatesProof :: Property
goldenDeprecatedSscProof_SharesProof :: Property
goldenDeprecatedSscProof_OpeningsProof :: Property
goldenDeprecatedSscProof_CommitmentsProof :: Property
goldenDeprecatedSscPayload_CertificatesPayload :: Property
goldenDeprecatedSscPayload_SharesPayload :: Property
goldenDeprecatedSscPayload_OpeningsPayload :: Property
goldenDeprecatedSscPayload_CommitmentsPayload :: Property
goldenDeprecatedSharesMap :: Property
goldenDeprecatedSignedCommitment :: Property
goldenDeprecatedOpeningsMap :: Property
goldenDeprecatedOpening :: Property
goldenDeprecatedInnerSharesMap :: Property
goldenDeprecatedCommitmentsMap :: Property
goldenDeprecatedCommitment :: Property
discoverGolden, $$FilePath
[(PropertyName, Property)]
Property
FilePath -> PropertyName
FilePath -> GroupName
GroupName -> [(PropertyName, Property)] -> Group
roundTripSscProof :: Property
roundTripSscPayload :: Property
discoverRoundTrip]