module Test.Hedgehog.Roundtrip.Bech32
  ( roundtrip_Bech32
  )
where

import           Cardano.Api

import           Hedgehog (Gen, Property)
import qualified Hedgehog as H

roundtrip_Bech32
  :: (SerialiseAsBech32 a, Eq a, Show a)
  => AsType a -> Gen a -> Property
roundtrip_Bech32 :: forall a.
(SerialiseAsBech32 a, Eq a, Show a) =>
AsType a -> Gen a -> Property
roundtrip_Bech32 AsType a
typeProxy Gen a
gen =
  HasCallStack => PropertyT IO () -> Property
PropertyT IO () -> Property
H.property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
forall a b. (a -> b) -> a -> b
$ do
    a
val <- Gen a -> PropertyT IO a
forall (m :: * -> *) a.
(Monad m, Show a, HasCallStack) =>
Gen a -> PropertyT m a
H.forAll Gen a
gen
    a
-> (a -> Text)
-> (Text -> Either Bech32DecodeError a)
-> PropertyT IO ()
forall (m :: * -> *) (f :: * -> *) b a.
(MonadTest m, Applicative f, Show b, Show (f a), Eq (f a),
 HasCallStack) =>
a -> (a -> b) -> (b -> f a) -> m ()
H.tripping a
val a -> Text
forall a. SerialiseAsBech32 a => a -> Text
serialiseToBech32 (AsType a -> Text -> Either Bech32DecodeError a
forall a.
SerialiseAsBech32 a =>
AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 AsType a
typeProxy)