{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.Cardano.Ledger.Alonzo.ChainTrace (
tests,
) where
import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.Plutus.Evaluate (
collectPlutusScriptsWithContext,
evalPlutusScripts,
)
import Cardano.Ledger.Alonzo.Rules (AlonzoBBODY, AlonzoLEDGER)
import Cardano.Ledger.Alonzo.Scripts (AlonzoScript (..), ExUnits (..), mkPlutusScript)
import Cardano.Ledger.Alonzo.Tx (AlonzoEraTx (..), IsValid (..), totExUnits)
import Cardano.Ledger.Core
import Cardano.Ledger.Plutus.Evaluate (PlutusWithContext (..), ScriptResult (..))
import Cardano.Ledger.Plutus.Language (plutusFromRunnable)
import Cardano.Ledger.Shelley.LedgerState hiding (circulation)
import Cardano.Ledger.Slot (EpochSize (..))
import Cardano.Slotting.EpochInfo (fixedEpochInfo)
import Cardano.Slotting.Time (SystemStart (..), mkSlotLength)
import Control.State.Transition
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Data.Word (Word64)
import Lens.Micro
import Lens.Micro.Extras (view)
import Test.Cardano.Ledger.Alonzo.AlonzoEraGen (sumCollateral)
import Test.Cardano.Ledger.Alonzo.EraMapping ()
import Test.Cardano.Ledger.Alonzo.Trace ()
import Test.Cardano.Ledger.Shelley.Constants (defaultConstants)
import Test.Cardano.Ledger.Shelley.Rules.Chain (
CHAIN,
ChainEvent (..),
ChainState (..),
TestChainPredicateFailure (..),
)
import Test.Cardano.Ledger.Shelley.Rules.TestChain (
forAllChainTrace,
ledgerTraceFromBlock,
)
import Test.Control.State.Transition.Trace (SourceSignalTarget (..), sourceSignalTargets)
import Test.QuickCheck (
Property,
conjoin,
counterexample,
(.&&.),
(===),
)
import Test.Tasty
import qualified Test.Tasty.QuickCheck as TQC
instance Embed (AlonzoBBODY AlonzoEra) (CHAIN AlonzoEra) where
wrapFailed :: PredicateFailure (AlonzoBBODY AlonzoEra)
-> PredicateFailure (CHAIN AlonzoEra)
wrapFailed = PredicateFailure (EraRule "BBODY" AlonzoEra)
-> TestChainPredicateFailure AlonzoEra
PredicateFailure (AlonzoBBODY AlonzoEra)
-> PredicateFailure (CHAIN AlonzoEra)
forall era.
PredicateFailure (EraRule "BBODY" era)
-> TestChainPredicateFailure era
BbodyFailure
wrapEvent :: Event (AlonzoBBODY AlonzoEra) -> Event (CHAIN AlonzoEra)
wrapEvent = Event (EraRule "BBODY" AlonzoEra) -> ChainEvent AlonzoEra
Event (AlonzoBBODY AlonzoEra) -> Event (CHAIN AlonzoEra)
forall era. Event (EraRule "BBODY" era) -> ChainEvent era
BbodyEvent
traceLen :: Word64
traceLen :: Word64
traceLen = Word64
100
data HasPlutus = HasPlutus | NoPlutus
deriving (Int -> HasPlutus -> ShowS
[HasPlutus] -> ShowS
HasPlutus -> [Char]
(Int -> HasPlutus -> ShowS)
-> (HasPlutus -> [Char])
-> ([HasPlutus] -> ShowS)
-> Show HasPlutus
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HasPlutus -> ShowS
showsPrec :: Int -> HasPlutus -> ShowS
$cshow :: HasPlutus -> [Char]
show :: HasPlutus -> [Char]
$cshowList :: [HasPlutus] -> ShowS
showList :: [HasPlutus] -> ShowS
Show)
tests :: TestTree
tests :: TestTree
tests =
[Char] -> Property -> TestTree
forall a. Testable a => [Char] -> a -> TestTree
TQC.testProperty [Char]
"alonzo specific" (Property -> TestTree) -> Property -> TestTree
forall a b. (a -> b) -> a -> b
$
forall era prop.
(EraGen era, EraGov era, EraStake era, Testable prop,
HasTrace (CHAIN era) (GenEnv MockCrypto era)) =>
Word64 -> Constants -> (Trace (CHAIN era) -> prop) -> Property
forAllChainTrace @AlonzoEra Word64
traceLen Constants
defaultConstants ((Trace (CHAIN AlonzoEra) -> Property) -> Property)
-> (Trace (CHAIN AlonzoEra) -> Property) -> Property
forall a b. (a -> b) -> a -> b
$ \Trace (CHAIN AlonzoEra)
tr ->
[Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin ([Property] -> Property) -> [Property] -> Property
forall a b. (a -> b) -> a -> b
$ (SourceSignalTarget (CHAIN AlonzoEra) -> Property)
-> [SourceSignalTarget (CHAIN AlonzoEra)] -> [Property]
forall a b. (a -> b) -> [a] -> [b]
map SourceSignalTarget (CHAIN AlonzoEra) -> Property
alonzoSpecificProps (Trace (CHAIN AlonzoEra) -> [SourceSignalTarget (CHAIN AlonzoEra)]
forall a. Trace a -> [SourceSignalTarget a]
sourceSignalTargets Trace (CHAIN AlonzoEra)
tr)
alonzoSpecificProps ::
SourceSignalTarget (CHAIN AlonzoEra) ->
Property
alonzoSpecificProps :: SourceSignalTarget (CHAIN AlonzoEra) -> Property
alonzoSpecificProps SourceSignalTarget {source :: forall a. SourceSignalTarget a -> State a
source = State (CHAIN AlonzoEra)
chainSt, signal :: forall a. SourceSignalTarget a -> Signal a
signal = Signal (CHAIN AlonzoEra)
block} =
[Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin ([Property] -> Property) -> [Property] -> Property
forall a b. (a -> b) -> a -> b
$
(SourceSignalTarget (AlonzoLEDGER AlonzoEra) -> Property)
-> [SourceSignalTarget (AlonzoLEDGER AlonzoEra)] -> [Property]
forall a b. (a -> b) -> [a] -> [b]
map SourceSignalTarget (AlonzoLEDGER AlonzoEra) -> Property
alonzoSpecificPropsLEDGER ([SourceSignalTarget (AlonzoLEDGER AlonzoEra)] -> [Property])
-> [SourceSignalTarget (AlonzoLEDGER AlonzoEra)] -> [Property]
forall a b. (a -> b) -> a -> b
$
Trace (AlonzoLEDGER AlonzoEra)
-> [SourceSignalTarget (AlonzoLEDGER AlonzoEra)]
forall a. Trace a -> [SourceSignalTarget a]
sourceSignalTargets Trace (AlonzoLEDGER AlonzoEra)
ledgerTr
where
(ChainState AlonzoEra
tickedChainSt, Trace (AlonzoLEDGER AlonzoEra)
ledgerTr) = ChainState AlonzoEra
-> Block (BHeader MockCrypto) AlonzoEra
-> (ChainState AlonzoEra, Trace (AlonzoLEDGER AlonzoEra))
forall era ledger.
(ChainProperty era, TestingLedger era ledger) =>
ChainState era
-> Block (BHeader MockCrypto) era -> (ChainState era, Trace ledger)
ledgerTraceFromBlock State (CHAIN AlonzoEra)
ChainState AlonzoEra
chainSt Block (BHeader MockCrypto) AlonzoEra
Signal (CHAIN AlonzoEra)
block
pp :: PParams AlonzoEra
pp = (Getting
(PParams AlonzoEra) (EpochState AlonzoEra) (PParams AlonzoEra)
-> EpochState AlonzoEra -> PParams AlonzoEra
forall a s. Getting a s a -> s -> a
view Getting
(PParams AlonzoEra) (EpochState AlonzoEra) (PParams AlonzoEra)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState AlonzoEra) (PParams AlonzoEra)
curPParamsEpochStateL (EpochState AlonzoEra -> PParams AlonzoEra)
-> (ChainState AlonzoEra -> EpochState AlonzoEra)
-> ChainState AlonzoEra
-> PParams AlonzoEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NewEpochState AlonzoEra -> EpochState AlonzoEra
forall era. NewEpochState era -> EpochState era
nesEs (NewEpochState AlonzoEra -> EpochState AlonzoEra)
-> (ChainState AlonzoEra -> NewEpochState AlonzoEra)
-> ChainState AlonzoEra
-> EpochState AlonzoEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainState AlonzoEra -> NewEpochState AlonzoEra
forall era. ChainState era -> NewEpochState era
chainNes) ChainState AlonzoEra
tickedChainSt
alonzoSpecificPropsLEDGER :: SourceSignalTarget (AlonzoLEDGER AlonzoEra) -> Property
alonzoSpecificPropsLEDGER :: SourceSignalTarget (AlonzoLEDGER AlonzoEra) -> Property
alonzoSpecificPropsLEDGER
SourceSignalTarget
{ source :: forall a. SourceSignalTarget a -> State a
source = LedgerState UTxOState {utxosUtxo :: forall era. UTxOState era -> UTxO era
utxosUtxo = UTxO Map TxIn (TxOut AlonzoEra)
u, utxosDeposited :: forall era. UTxOState era -> Coin
utxosDeposited = Coin
dp, utxosFees :: forall era. UTxOState era -> Coin
utxosFees = Coin
f} CertState AlonzoEra
ds
, signal :: forall a. SourceSignalTarget a -> Signal a
signal = Signal (AlonzoLEDGER AlonzoEra)
tx
, target :: forall a. SourceSignalTarget a -> State a
target = LedgerState UTxOState {utxosUtxo :: forall era. UTxOState era -> UTxO era
utxosUtxo = UTxO Map TxIn (TxOut AlonzoEra)
u', utxosDeposited :: forall era. UTxOState era -> Coin
utxosDeposited = Coin
dp', utxosFees :: forall era. UTxOState era -> Coin
utxosFees = Coin
f'} CertState AlonzoEra
ds'
} =
let isValid' :: IsValid
isValid' = AlonzoTx AlonzoEra
Signal (AlonzoLEDGER AlonzoEra)
tx AlonzoTx AlonzoEra
-> Getting IsValid (AlonzoTx AlonzoEra) IsValid -> IsValid
forall s a. s -> Getting a s a -> a
^. (IsValid -> Const IsValid IsValid)
-> Tx AlonzoEra -> Const IsValid (Tx AlonzoEra)
Getting IsValid (AlonzoTx AlonzoEra) IsValid
forall era. AlonzoEraTx era => Lens' (Tx era) IsValid
Lens' (Tx AlonzoEra) IsValid
isValidTxL
noNewUTxO :: Bool
noNewUTxO = Map TxIn (TxOut AlonzoEra)
Map TxIn (AlonzoTxOut AlonzoEra)
u' Map TxIn (AlonzoTxOut AlonzoEra)
-> Map TxIn (AlonzoTxOut AlonzoEra) -> Bool
forall k a. (Ord k, Eq a) => Map k a -> Map k a -> Bool
`Map.isSubmapOf` Map TxIn (TxOut AlonzoEra)
Map TxIn (AlonzoTxOut AlonzoEra)
u
collateralInFees :: Bool
collateralInFees = Coin
f Coin -> Coin -> Coin
forall a. Semigroup a => a -> a -> a
<> Tx AlonzoEra -> UTxO AlonzoEra -> Coin
forall era.
(EraTx era, AlonzoEraTxBody era) =>
Tx era -> UTxO era -> Coin
sumCollateral Tx AlonzoEra
Signal (AlonzoLEDGER AlonzoEra)
tx (Map TxIn (TxOut AlonzoEra) -> UTxO AlonzoEra
forall era. Map TxIn (TxOut era) -> UTxO era
UTxO Map TxIn (TxOut AlonzoEra)
u) Coin -> Coin -> Bool
forall a. Eq a => a -> a -> Bool
== Coin
f'
utxoConsumed :: Bool
utxoConsumed = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Map TxIn (TxOut AlonzoEra)
Map TxIn (AlonzoTxOut AlonzoEra)
u Map TxIn (AlonzoTxOut AlonzoEra)
-> Map TxIn (AlonzoTxOut AlonzoEra) -> Bool
forall k a. (Ord k, Eq a) => Map k a -> Map k a -> Bool
`Map.isSubmapOf` Map TxIn (TxOut AlonzoEra)
Map TxIn (AlonzoTxOut AlonzoEra)
u'
allScripts :: Map ScriptHash (AlonzoScript AlonzoEra)
allScripts = AlonzoTx AlonzoEra
Signal (AlonzoLEDGER AlonzoEra)
tx AlonzoTx AlonzoEra
-> Getting
(Map ScriptHash (AlonzoScript AlonzoEra))
(AlonzoTx AlonzoEra)
(Map ScriptHash (AlonzoScript AlonzoEra))
-> Map ScriptHash (AlonzoScript AlonzoEra)
forall s a. s -> Getting a s a -> a
^. (TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra))
-> Tx AlonzoEra
-> Const (Map ScriptHash (AlonzoScript AlonzoEra)) (Tx AlonzoEra)
(TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra))
-> AlonzoTx AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (AlonzoTx AlonzoEra)
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx AlonzoEra) (TxWits AlonzoEra)
witsTxL ((TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra))
-> AlonzoTx AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (AlonzoTx AlonzoEra))
-> ((Map ScriptHash (AlonzoScript AlonzoEra)
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra))
(Map ScriptHash (AlonzoScript AlonzoEra)))
-> TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra))
-> Getting
(Map ScriptHash (AlonzoScript AlonzoEra))
(AlonzoTx AlonzoEra)
(Map ScriptHash (AlonzoScript AlonzoEra))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map ScriptHash (Script AlonzoEra)
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra))
(Map ScriptHash (Script AlonzoEra)))
-> TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra)
(Map ScriptHash (AlonzoScript AlonzoEra)
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra))
(Map ScriptHash (AlonzoScript AlonzoEra)))
-> TxWits AlonzoEra
-> Const
(Map ScriptHash (AlonzoScript AlonzoEra)) (TxWits AlonzoEra)
forall era.
EraTxWits era =>
Lens' (TxWits era) (Map ScriptHash (Script era))
Lens' (TxWits AlonzoEra) (Map ScriptHash (Script AlonzoEra))
scriptTxWitsL
hasPlutus :: HasPlutus
hasPlutus = if (AlonzoScript AlonzoEra -> Bool)
-> Map ScriptHash (AlonzoScript AlonzoEra) -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall era. EraScript era => Script era -> Bool
isNativeScript @AlonzoEra) Map ScriptHash (AlonzoScript AlonzoEra)
allScripts then HasPlutus
NoPlutus else HasPlutus
HasPlutus
totEU :: ExUnits
totEU = Tx AlonzoEra -> ExUnits
forall era. (EraTx era, AlonzoEraTxWits era) => Tx era -> ExUnits
totExUnits Tx AlonzoEra
Signal (AlonzoLEDGER AlonzoEra)
tx
nonTrivialExU :: Bool
nonTrivialExU = ExUnits -> Natural
exUnitsMem ExUnits
totEU Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0 Bool -> Bool -> Bool
&& ExUnits -> Natural
exUnitsSteps ExUnits
totEU Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
> Natural
0
collected :: [PlutusWithContext]
collected =
case EpochInfo (Either Text)
-> SystemStart
-> PParams AlonzoEra
-> Tx AlonzoEra
-> UTxO AlonzoEra
-> Either [CollectError AlonzoEra] [PlutusWithContext]
forall era.
(AlonzoEraTxBody era, AlonzoEraTxWits era, AlonzoEraUTxO era,
ScriptsNeeded era ~ AlonzoScriptsNeeded era,
EraPlutusContext era) =>
EpochInfo (Either Text)
-> SystemStart
-> PParams era
-> Tx era
-> UTxO era
-> Either [CollectError era] [PlutusWithContext]
collectPlutusScriptsWithContext
(EpochSize -> SlotLength -> EpochInfo (Either Text)
forall (m :: * -> *).
Monad m =>
EpochSize -> SlotLength -> EpochInfo m
fixedEpochInfo (Word64 -> EpochSize
EpochSize Word64
100) (NominalDiffTime -> SlotLength
mkSlotLength NominalDiffTime
1))
(UTCTime -> SystemStart
SystemStart (UTCTime -> SystemStart) -> UTCTime -> SystemStart
forall a b. (a -> b) -> a -> b
$ NominalDiffTime -> UTCTime
posixSecondsToUTCTime NominalDiffTime
0)
PParams AlonzoEra
pp
Tx AlonzoEra
Signal (AlonzoLEDGER AlonzoEra)
tx
(Map TxIn (TxOut AlonzoEra) -> UTxO AlonzoEra
forall era. Map TxIn (TxOut era) -> UTxO era
UTxO Map TxIn (TxOut AlonzoEra)
u) of
Left [CollectError AlonzoEra]
e -> [Char] -> [PlutusWithContext]
forall a. HasCallStack => [Char] -> a
error ([Char] -> [PlutusWithContext]) -> [Char] -> [PlutusWithContext]
forall a b. (a -> b) -> a -> b
$ [Char]
"Plutus script collection error: " [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> [CollectError AlonzoEra] -> [Char]
forall a. Show a => a -> [Char]
show [CollectError AlonzoEra]
e
Right [PlutusWithContext]
c -> [PlutusWithContext]
c
collectedScripts :: Set (PlutusScript AlonzoEra)
collectedScripts =
[PlutusScript AlonzoEra] -> Set (PlutusScript AlonzoEra)
forall a. Ord a => [a] -> Set a
Set.fromList
[ PlutusScript AlonzoEra
plutus
| PlutusWithContext {Either (Plutus l) (PlutusRunnable l)
pwcScript :: Either (Plutus l) (PlutusRunnable l)
pwcScript :: ()
pwcScript} <- [PlutusWithContext]
collected
, Just PlutusScript AlonzoEra
plutus <- [Plutus l -> Maybe (PlutusScript AlonzoEra)
forall era (l :: Language).
(AlonzoEraScript era, PlutusLanguage l) =>
Plutus l -> Maybe (PlutusScript era)
forall (l :: Language).
PlutusLanguage l =>
Plutus l -> Maybe (PlutusScript AlonzoEra)
mkPlutusScript (Plutus l -> Maybe (PlutusScript AlonzoEra))
-> Plutus l -> Maybe (PlutusScript AlonzoEra)
forall a b. (a -> b) -> a -> b
$ (Plutus l -> Plutus l)
-> (PlutusRunnable l -> Plutus l)
-> Either (Plutus l) (PlutusRunnable l)
-> Plutus l
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either Plutus l -> Plutus l
forall a. a -> a
id PlutusRunnable l -> Plutus l
forall (l :: Language). PlutusRunnable l -> Plutus l
plutusFromRunnable Either (Plutus l) (PlutusRunnable l)
pwcScript]
]
suppliedPScrpts :: Set (PlutusScript AlonzoEra)
suppliedPScrpts = [PlutusScript AlonzoEra] -> Set (PlutusScript AlonzoEra)
forall a. Ord a => [a] -> Set a
Set.fromList [PlutusScript AlonzoEra
plutus | PlutusScript PlutusScript AlonzoEra
plutus <- Map ScriptHash (AlonzoScript AlonzoEra) -> [AlonzoScript AlonzoEra]
forall k a. Map k a -> [a]
Map.elems Map ScriptHash (AlonzoScript AlonzoEra)
allScripts]
expectedPScripts :: Bool
expectedPScripts = Set (PlutusScript AlonzoEra)
collectedScripts Set (PlutusScript AlonzoEra)
-> Set (PlutusScript AlonzoEra) -> Bool
forall a. Eq a => a -> a -> Bool
== Set (PlutusScript AlonzoEra)
suppliedPScrpts
allPlutusTrue :: Bool
allPlutusTrue = case [PlutusWithContext] -> ScriptResult
evalPlutusScripts [PlutusWithContext]
collected of
Fails [PlutusWithContext]
_ NonEmpty ScriptFailure
_ -> Bool
False
Passes [PlutusWithContext]
_ -> Bool
True
in [Char] -> Property -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample
( [[Char]] -> [Char]
forall a. Monoid a => [a] -> a
mconcat
[ [Char]
"\nHas plutus scripts: "
, HasPlutus -> [Char]
forall a. Show a => a -> [Char]
show HasPlutus
hasPlutus
, [Char]
"\nIs valid: "
, IsValid -> [Char]
forall a. Show a => a -> [Char]
show IsValid
isValid'
, [Char]
"\nAt least one UTxO is consumed: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
utxoConsumed
, [Char]
"\nNon trivial execution units: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
nonTrivialExU
, [Char]
"\nReceived the expected plutus scripts: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
expectedPScripts
, [Char]
"\nPlutus scripts all evaluate to true: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
allPlutusTrue
, [Char]
"\nNo new UTxO: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
noNewUTxO
, [Char]
"\nThe collateral amount was added to the fees: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show Bool
collateralInFees
, [Char]
"\nThe deposit pot is unchanged: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show (Coin
dp Coin -> Coin -> Bool
forall a. Eq a => a -> a -> Bool
== Coin
dp')
, [Char]
"\nThe delegation state is unchanged: "
, Bool -> [Char]
forall a. Show a => a -> [Char]
show (CertState AlonzoEra
ShelleyCertState AlonzoEra
ds ShelleyCertState AlonzoEra -> ShelleyCertState AlonzoEra -> Bool
forall a. Eq a => a -> a -> Bool
== CertState AlonzoEra
ShelleyCertState AlonzoEra
ds')
]
)
( [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"At least one UTxO is consumed" Bool
utxoConsumed
Property -> Property -> Property
forall prop1 prop2.
(Testable prop1, Testable prop2) =>
prop1 -> prop2 -> Property
.&&. ( case (HasPlutus
hasPlutus, IsValid
isValid') of
(HasPlutus
NoPlutus, IsValid Bool
True) -> ExUnits
totEU ExUnits -> ExUnits -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== Natural -> Natural -> ExUnits
ExUnits Natural
0 Natural
0
(HasPlutus
NoPlutus, IsValid Bool
False) -> [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"No Plutus scripts, but isValid == False" Bool
False
(HasPlutus
HasPlutus, IsValid Bool
True) ->
[Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin
[ [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"Non trivial execution units" Bool
nonTrivialExU
, [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"Received the expected plutus scripts" Bool
expectedPScripts
, [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"Plutus scripts all evaluate to true" Bool
allPlutusTrue
]
(HasPlutus
HasPlutus, IsValid Bool
False) ->
[Property] -> Property
forall prop. Testable prop => [prop] -> Property
conjoin
[ [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"No new UTxO" Bool
noNewUTxO
, [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"The collateral amount was added to the fees" Bool
collateralInFees
, Coin
dp Coin -> Coin -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== Coin
dp'
, CertState AlonzoEra
ShelleyCertState AlonzoEra
ds ShelleyCertState AlonzoEra
-> ShelleyCertState AlonzoEra -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== CertState AlonzoEra
ShelleyCertState AlonzoEra
ds'
, [Char] -> Bool -> Property
forall prop. Testable prop => [Char] -> prop -> Property
counterexample [Char]
"No failing Plutus scripts" (Bool -> Property) -> Bool -> Property
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not Bool
allPlutusTrue
]
)
)