{-# LANGUAGE CPP #-}

{- FOURMOLU_DISABLE -}
module Main (main) where

import qualified Test.Crypto.DSIGN
import qualified Test.Crypto.Hash
import qualified Test.Crypto.KES
import qualified Test.Crypto.VRF
import qualified Test.Crypto.Regressions
#ifdef SECP256K1_ENABLED
import qualified Test.Crypto.Vector.Secp256k1DSIGN
#endif
import qualified Test.Crypto.EllipticCurve
import Test.Hspec (Spec, describe, hspec)
import Test.Hspec.QuickCheck (modifyMaxSuccess)
import Cardano.Crypto.Libsodium (sodiumInit)
import Test.Crypto.Util (Lock, mkLock)

main :: IO ()
IO ()
main = do
  IO ()
sodiumInit

  -- This lock is used to prevent tests that use mlocking from running
  -- concurrently. Concurrent execution of these tests can cause the testsuite
  -- to exhaust mlock quota; but each individual test on its own should be
  -- fine.
  Lock
mlockLock <- IO Lock
mkLock

  Spec -> IO ()
hspec (Lock -> Spec
tests Lock
mlockLock)

tests :: Lock -> Spec
tests :: Lock -> Spec
tests Lock
mlockLock =
  -- The default QuickCheck test count is 100. This is too few to catch
  -- anything, so we set a minimum of 1000.
  (Int -> Int) -> Spec -> Spec
forall a. (Int -> Int) -> SpecWith a -> SpecWith a
modifyMaxSuccess (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
1000) (Spec -> Spec) -> (Spec -> Spec) -> Spec -> Spec
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"cardano-crypto-class" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
      Lock -> Spec
Test.Crypto.DSIGN.tests Lock
mlockLock
      Lock -> Spec
Test.Crypto.Hash.tests Lock
mlockLock
      Lock -> Spec
Test.Crypto.KES.tests Lock
mlockLock
      Spec
Test.Crypto.VRF.tests
      Spec
Test.Crypto.Regressions.tests
#ifdef SECP256K1_ENABLED
      Spec
Test.Crypto.Vector.Secp256k1DSIGN.tests
#endif
      Spec
Test.Crypto.EllipticCurve.tests