cardano-node-emulator-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Cardano.Node.Emulator.Test

Description

Test facility for MonadEmulator

Synopsis

Basic testing

hasValidatedTransactionCountOfTotal :: Int -> Int -> EmulatorLogs -> Maybe String Source #

Test the number of validated transactions and the total number of transactions. Returns a failure message if the numbers don't match up.

renderLogs :: EmulatorLogs -> Text Source #

Render the logs in a format useful for debugging why a test failed.

Testing with `quickcheck-contractmodel`

propSanityCheckModel :: forall state. ContractModel state => Property Source #

Sanity check a ContractModel. Ensures that wallet balances are not always unchanged.

propSanityCheckAssertions :: forall state. ContractModel state => Actions state -> Property Source #

Sanity check a ContractModel. Ensures that all assertions in the property generation succeed.

propRunActions_ Source #

Arguments

:: forall state. RunModel state EmulatorM 
=> Actions state

The actions to run

-> Property 

Run Actions in the emulator and check that the model and the emulator agree on the final wallet balance changes. Starts with 100.000.000 Ada for each wallet and the default parameters.

propRunActions Source #

Arguments

:: forall state. RunModel state EmulatorM 
=> (ModelState state -> EmulatorLogs -> Maybe String)

Predicate to check at the end of execution

-> Actions state

The actions to run

-> Property 

propRunActionsWithOptions Source #

Arguments

:: forall state. RunModel state EmulatorM 
=> Map CardanoAddress Value

Initial distribution of funds

-> Params

Node parameters

-> (ModelState state -> EmulatorLogs -> Maybe String)

Predicate to check at the end of execution

-> Actions state

The actions to run

-> Property 

Other exports

Re-export quickcheck-contractmodel

assertBalanceChangesMatch :: BalanceChangeOptions -> ContractModelResult state -> Property #

runContractModel :: forall state (m :: Type -> Type). (ContractModel state, RunModel state m, HasChainIndex m) => Actions state -> PropertyM (RunMonad m) (ContractModelResult state) #

signerPaysFees :: FeeCalculation #

asserts :: ModelState state -> Property #

stateAfter :: ContractModel state => Actions state -> ModelState state #

balanceChanges :: Getter (ModelState state) (Map (AddressInEra Era) SymValue) #

symIsZero :: SymValue -> Bool #

data BalanceChangeOptions #

Constructors

BalanceChangeOptions Bool FeeCalculation ProtocolParameters (AddressInEra Era -> String) 

class (DefaultRealized m, HasChainIndex m, Monad m) => IsRunnable (m :: Type -> Type) #

Minimal complete definition

awaitSlot

Instances

Instances details
IsRunnable EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

Methods

awaitSlot :: SlotNo -> EmulatorM ()

IsRunnable m => IsRunnable (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

awaitSlot :: SlotNo -> RunMonad m ()

(DefaultRealized m, IsRunnable m) => IsRunnable (ReaderT r m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

awaitSlot :: SlotNo -> ReaderT r m ()

(DefaultRealized m, IsRunnable m) => IsRunnable (StateT s m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

awaitSlot :: SlotNo -> StateT s m ()

(Monoid w, DefaultRealized m, IsRunnable m) => IsRunnable (WriterT w m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

awaitSlot :: SlotNo -> WriterT w m ()

class (ContractModel state, IsRunnable m) => RunModel state (m :: Type -> Type) #

Minimal complete definition

perform

data RunMonad (m :: Type -> Type) a #

Instances

Instances details
MonadTrans RunMonad 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

lift :: Monad m => m a -> RunMonad m a

MonadError e m => MonadError e (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

throwError :: e -> RunMonad m a

catchError :: RunMonad m a -> (e -> RunMonad m a) -> RunMonad m a

MonadState s m => MonadState s (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

get :: RunMonad m s

put :: s -> RunMonad m ()

state :: (s -> (a, s)) -> RunMonad m a

Monad m => MonadWriter SymIndex (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

writer :: (a, SymIndex) -> RunMonad m a

tell :: SymIndex -> RunMonad m ()

listen :: RunMonad m a -> RunMonad m (a, SymIndex)

pass :: RunMonad m (a, SymIndex -> SymIndex) -> RunMonad m a

Monad m => Monad (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

(>>=) :: RunMonad m a -> (a -> RunMonad m b) -> RunMonad m b Source #

(>>) :: RunMonad m a -> RunMonad m b -> RunMonad m b Source #

return :: a -> RunMonad m a Source #

Functor m => Functor (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

fmap :: (a -> b) -> RunMonad m a -> RunMonad m b Source #

(<$) :: a -> RunMonad m b -> RunMonad m a Source #

Monad m => MonadFail (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

fail :: String -> RunMonad m a Source #

Applicative m => Applicative (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

pure :: a -> RunMonad m a Source #

(<*>) :: RunMonad m (a -> b) -> RunMonad m a -> RunMonad m b Source #

liftA2 :: (a -> b -> c) -> RunMonad m a -> RunMonad m b -> RunMonad m c Source #

(*>) :: RunMonad m a -> RunMonad m b -> RunMonad m b Source #

(<*) :: RunMonad m a -> RunMonad m b -> RunMonad m a Source #

IsRunnable m => IsRunnable (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

awaitSlot :: SlotNo -> RunMonad m ()

(Monad m, HasChainIndex m) => HasChainIndex (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

(IsRunnable m, RunModel state m) => RunModel (ModelState state) (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

perform :: Typeable a => ModelState state -> Action (ModelState state) a -> LookUp (RunMonad m) -> RunMonad m (Realized (RunMonad m) a)

postcondition :: (ModelState state, ModelState state) -> Action (ModelState state) a -> LookUp (RunMonad m) -> Realized (RunMonad m) a -> PostconditionM (RunMonad m) Bool

monitoring :: (ModelState state, ModelState state) -> Action (ModelState state) a -> LookUp (RunMonad m) -> Realized (RunMonad m) a -> Property -> Property

type Realized (RunMonad m) a 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

type Realized (RunMonad m) a = Realized m a

data ChainState #

Constructors

ChainState 

Fields

class HasChainIndex (m :: Type -> Type) #

Minimal complete definition

getChainIndex, getChainState

Instances

Instances details
HasChainIndex EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

(Monad m, HasChainIndex m) => HasChainIndex (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

(Monad m, HasChainIndex m) => HasChainIndex (ReaderT r m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex

Methods

getChainIndex :: ReaderT r m ChainIndex

getChainState :: ReaderT r m ChainState

(Monad m, HasChainIndex m) => HasChainIndex (StateT s m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex

Methods

getChainIndex :: StateT s m ChainIndex

getChainState :: StateT s m ChainState

(Monad m, Monoid w, HasChainIndex m) => HasChainIndex (WriterT w m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex

Methods

getChainIndex :: WriterT w m ChainIndex

getChainState :: WriterT w m ChainState

data TxInState #

Constructors

TxInState (Tx Era) ChainState Bool 

data Actions s #

Instances

Instances details
ContractModel state => Show (Actions state) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Model

Methods

showsPrec :: Int -> Actions state -> ShowS Source #

show :: Actions state -> String Source #

showList :: [Actions state] -> ShowS Source #

ContractModel s => Arbitrary (Actions s) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Model

Methods

arbitrary :: Gen (Actions s)

shrink :: Actions s -> [Actions s]

class (Typeable state, Show state, HasActions state) => ContractModel state #

Minimal complete definition

arbitraryAction, initialState, nextState

data ModelState state #

Instances

Instances details
Functor ModelState 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Spec

Methods

fmap :: (a -> b) -> ModelState a -> ModelState b Source #

(<$) :: a -> ModelState b -> ModelState a Source #

(ContractModel state, Typeable a) => ActionLike state (Action (ModelState state) a) 
Instance details

Defined in Test.QuickCheck.ContractModel.DL

Methods

action :: Action (ModelState state) a -> DL state ()

Show state => Show (ModelState state) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Spec

Methods

showsPrec :: Int -> ModelState state -> ShowS Source #

show :: ModelState state -> String Source #

showList :: [ModelState state] -> ShowS Source #

Generic (ModelState state) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Spec

Associated Types

type Rep (ModelState state) :: Type -> Type Source #

Methods

from :: ModelState state -> Rep (ModelState state) x Source #

to :: Rep (ModelState state) x -> ModelState state Source #

(IsRunnable m, RunModel state m) => RunModel (ModelState state) (RunMonad m) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal

Methods

perform :: Typeable a => ModelState state -> Action (ModelState state) a -> LookUp (RunMonad m) -> RunMonad m (Realized (RunMonad m) a)

postcondition :: (ModelState state, ModelState state) -> Action (ModelState state) a -> LookUp (RunMonad m) -> Realized (RunMonad m) a -> PostconditionM (RunMonad m) Bool

monitoring :: (ModelState state, ModelState state) -> Action (ModelState state) a -> LookUp (RunMonad m) -> Realized (RunMonad m) a -> Property -> Property

type Rep (ModelState state) 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Spec

type Rep (ModelState state) = D1 ('MetaData "ModelState" "Test.QuickCheck.ContractModel.Internal.Spec" "quickcheck-contractmodel-0.1.4.1-3bqn4RrQanG11zXTiHDaXF" 'False) (C1 ('MetaCons "ModelState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_currentSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "_balanceChanges") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (AddressInEra Era) SymValue)) :*: S1 ('MetaSel ('Just "_minted") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SymValue))) :*: ((S1 ('MetaSel ('Just "_symbolics") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SymCollectionIndex) :*: S1 ('MetaSel ('Just "_assertions") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(String, Bool)])) :*: (S1 ('MetaSel ('Just "_assertionsOk") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "_contractState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 state)))))
type StateType (DL state) 
Instance details

Defined in Test.QuickCheck.ContractModel.DL

type StateType (DL state) = state
data Action (ModelState state) a 
Instance details

Defined in Test.QuickCheck.ContractModel.Internal.Model

data Action (ModelState state) a where

Orphan instances