{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Test.Cardano.Ledger.Babbage.Serialisation.Tripping where

import Cardano.Ledger.Babbage (Babbage)
import Cardano.Ledger.Babbage.Rules (BabbageUtxoPredFailure)
import Cardano.Ledger.Block (Block)
import Cardano.Ledger.Core
import Cardano.Protocol.TPraos.BHeader (BHeader)
import Test.Cardano.Ledger.Babbage.Arbitrary ()
import Test.Cardano.Ledger.Babbage.Serialisation.Generators ()
import Test.Cardano.Ledger.Binary.RoundTrip
import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes
import Test.Cardano.Ledger.ShelleyMA.Serialisation.Generators ()
import Test.Tasty
import Test.Tasty.QuickCheck

tests :: TestTree
tests :: TestTree
tests =
  TestName -> [TestTree] -> TestTree
testGroup
    TestName
"Babbage CBOR round-trip"
    [ forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"babbage/BabbageUtxoPredFailure" forall a b. (a -> b) -> a -> b
$
        forall t.
(Show t, Eq t, EncCBOR t, DecCBOR t, HasCallStack) =>
Version -> Version -> t -> Expectation
roundTripCborRangeExpectation @(BabbageUtxoPredFailure Babbage)
          (forall era. Era era => Version
eraProtVerLow @Babbage)
          (forall era. Era era => Version
eraProtVerHigh @Babbage)
    , forall a. Testable a => TestName -> a -> TestTree
testProperty TestName
"babbage/Block" forall a b. (a -> b) -> a -> b
$
        forall t.
(Show t, Eq t, ToCBOR t, DecCBOR (Annotator t), HasCallStack) =>
Version -> Version -> t -> Expectation
roundTripAnnRangeExpectation @(Block (BHeader StandardCrypto) Babbage)
          (forall era. Era era => Version
eraProtVerLow @Babbage)
          (forall era. Era era => Version
eraProtVerHigh @Babbage)
    ]