{-# LANGUAGE DataKinds #-} {-# LANGUAGE NumDecimals #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} module Test.Cardano.Chain.Common.Address ( tests, ) where import Cardano.Chain.Common (addrNetworkMagic, isRedeemAddress) import Cardano.Prelude import Hedgehog (cover, forAll, property, (===)) import Test.Cardano.Chain.Common.Gen (genAddress, genAddressWithNM, genNetworkMagic) import Test.Cardano.Prelude import Test.Options (TSGroup, TSProperty, withTestsTS) ts_prop_addressNetworkMagicIdentity :: TSProperty ts_prop_addressNetworkMagicIdentity :: TSProperty ts_prop_addressNetworkMagicIdentity = TestLimit -> Property -> TSProperty withTestsTS TestLimit 1000 forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . HasCallStack => PropertyT IO () -> Property property forall a b. (a -> b) -> a -> b $ do NetworkMagic nm <- forall (m :: * -> *) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a forAll Gen NetworkMagic genNetworkMagic Address addr <- forall (m :: * -> *) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a forAll (NetworkMagic -> Gen Address genAddressWithNM NetworkMagic nm) NetworkMagic nm forall (m :: * -> *) a. (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () === Address -> NetworkMagic addrNetworkMagic Address addr ts_prop_isRedeemAddress :: TSProperty ts_prop_isRedeemAddress :: TSProperty ts_prop_isRedeemAddress = TestLimit -> Property -> TSProperty withTestsTS TestLimit 1000 forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . HasCallStack => PropertyT IO () -> Property property forall a b. (a -> b) -> a -> b $ do Address addr <- forall (m :: * -> *) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a forAll Gen Address genAddress forall (m :: * -> *). (MonadTest m, HasCallStack) => CoverPercentage -> LabelName -> Bool -> m () cover CoverPercentage 30 LabelName "Redeem Address" forall a b. (a -> b) -> a -> b $ Address -> Bool isRedeemAddress Address addr forall (m :: * -> *). (MonadTest m, HasCallStack) => CoverPercentage -> LabelName -> Bool -> m () cover CoverPercentage 30 LabelName "Pubkey Address" forall a b. (a -> b) -> a -> b $ Bool -> Bool not (Address -> Bool isRedeemAddress Address addr) tests :: TSGroup tests :: TSGroup tests = $$discoverPropArg