module Hydra.Chain.Direct.ScriptRegistrySpec where

import Hydra.Prelude
import Test.Hydra.Prelude

import Hydra.Tx.ScriptRegistry (
  newScriptRegistry,
  registryUTxO,
 )
import Test.Hydra.Tx.Gen (genScriptRegistry)
import Test.QuickCheck (forAllBlind, (===))

spec :: Spec
spec :: Spec
spec =
  String -> Property -> Spec
forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"newScriptRegistry (registryUTxO r) === Just r" (Property -> Spec) -> Property -> Spec
forall a b. (a -> b) -> a -> b
$
    Gen ScriptRegistry -> (ScriptRegistry -> Property) -> Property
forall prop a. Testable prop => Gen a -> (a -> prop) -> Property
forAllBlind Gen ScriptRegistry
genScriptRegistry ((ScriptRegistry -> Property) -> Property)
-> (ScriptRegistry -> Property) -> Property
forall a b. (a -> b) -> a -> b
$ \ScriptRegistry
r ->
      UTxO -> Either NewScriptRegistryException ScriptRegistry
newScriptRegistry (ScriptRegistry -> UTxO
registryUTxO ScriptRegistry
r) Either NewScriptRegistryException ScriptRegistry
-> Either NewScriptRegistryException ScriptRegistry -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== ScriptRegistry -> Either NewScriptRegistryException ScriptRegistry
forall a b. b -> Either a b
Right ScriptRegistry
r