{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Slotting.Arbitrary () where

import Cardano.Slotting.Slot
import Test.QuickCheck

instance Arbitrary SlotNo where
  arbitrary :: Gen SlotNo
arbitrary =
    Word64 -> SlotNo
SlotNo
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ( (forall a. Positive a -> a
getPositive forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary)
              forall a. Gen a -> (a -> Bool) -> Gen a
`suchThat` (\Word64
n -> Word64
n forall a. Ord a => a -> a -> Bool
< forall a. Bounded a => a
maxBound forall a. Num a => a -> a -> a
- Word64
2 forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
32 :: Int))
          )

  -- need some room, we're assuming we'll never wrap around 64bits

  shrink :: SlotNo -> [SlotNo]
shrink (SlotNo Word64
n) = [Word64 -> SlotNo
SlotNo Word64
n' | Word64
n' <- forall a. Arbitrary a => a -> [a]
shrink Word64
n, Word64
n' forall a. Ord a => a -> a -> Bool
> Word64
0]

deriving newtype instance Arbitrary EpochNo