{-# LANGUAGE TypeApplications #-}

module Test.Consensus.Shelley.SupportedNetworkProtocolVersion (tests) where

import           Data.Proxy
import           Data.SOP.BasicFunctors
import           Data.SOP.Constraint
import           Data.SOP.Strict
import           Data.Typeable (Typeable)
import           Ouroboros.Consensus.Cardano.Block
import           Ouroboros.Consensus.Node.NetworkProtocolVersion
                     (SupportedNetworkProtocolVersion)
import           Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
import           Test.Tasty
import           Test.Tasty.HUnit
import           Test.Util.SupportedNetworkProtocolVersion

tests :: TestTree
tests :: TestTree
tests =
      TestName -> Assertion -> TestTree
testCase TestName
"Shelley exhaustive network protocol versions"
    (Assertion -> TestTree)
-> (NP Proxy (CardanoShelleyEras StandardCrypto) -> Assertion)
-> NP Proxy (CardanoShelleyEras StandardCrypto)
-> TestTree
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Assertion] -> Assertion
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
    ([Assertion] -> Assertion)
-> (NP Proxy (CardanoShelleyEras StandardCrypto) -> [Assertion])
-> NP Proxy (CardanoShelleyEras StandardCrypto)
-> Assertion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NP (K Assertion) (CardanoShelleyEras StandardCrypto) -> [Assertion]
NP (K Assertion) (CardanoShelleyEras StandardCrypto)
-> CollapseTo NP Assertion
forall (xs :: [*]) a.
SListIN NP xs =>
NP (K a) xs -> CollapseTo NP a
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
    (NP (K Assertion) (CardanoShelleyEras StandardCrypto)
 -> [Assertion])
-> (NP Proxy (CardanoShelleyEras StandardCrypto)
    -> NP (K Assertion) (CardanoShelleyEras StandardCrypto))
-> NP Proxy (CardanoShelleyEras StandardCrypto)
-> [Assertion]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy (And Typeable SupportedNetworkProtocolVersion)
-> (forall a.
    And Typeable SupportedNetworkProtocolVersion a =>
    Proxy a -> K Assertion a)
-> NP Proxy (CardanoShelleyEras StandardCrypto)
-> NP (K Assertion) (CardanoShelleyEras StandardCrypto)
forall {k} {l} (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap
        (forall {k} (t :: k). Proxy t
forall (t :: * -> Constraint). Proxy t
Proxy @(And Typeable SupportedNetworkProtocolVersion))
        (Assertion -> K Assertion a
forall k a (b :: k). a -> K a b
K (Assertion -> K Assertion a)
-> (Proxy a -> Assertion) -> Proxy a -> K Assertion a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> Assertion
forall blk.
(Typeable blk, SupportedNetworkProtocolVersion blk) =>
Proxy blk -> Assertion
exhaustiveSupportedNetworkProtocolVersions)
    (NP Proxy (CardanoShelleyEras StandardCrypto) -> TestTree)
-> NP Proxy (CardanoShelleyEras StandardCrypto) -> TestTree
forall a b. (a -> b) -> a -> b
$ NP Proxy (CardanoShelleyEras StandardCrypto)
shelleyBlocks
  where
    shelleyBlocks :: NP Proxy (CardanoShelleyEras StandardCrypto)
    shelleyBlocks :: NP Proxy (CardanoShelleyEras StandardCrypto)
shelleyBlocks = (forall a. Proxy a) -> NP Proxy (CardanoShelleyEras StandardCrypto)
forall (xs :: [*]) (f :: * -> *).
SListIN NP xs =>
(forall a. f a) -> NP f xs
forall k l (h :: (k -> *) -> l -> *) (xs :: l) (f :: k -> *).
(HPure h, SListIN h xs) =>
(forall (a :: k). f a) -> h f xs
hpure Proxy a
forall a. Proxy a
forall {k} (t :: k). Proxy t
Proxy