Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Node.Emulator.Test
Description
Test facility for MonadEmulator
Synopsis
- hasValidatedTransactionCountOfTotal :: Int -> Int -> EmulatorLogs -> Maybe String
- renderLogs :: EmulatorLogs -> Text
- propSanityCheckModel :: forall state. ContractModel state => Property
- propSanityCheckAssertions :: forall state. ContractModel state => Actions state -> Property
- propRunActions_ :: forall state. RunModel state EmulatorM => Actions state -> Property
- propRunActions :: forall state. RunModel state EmulatorM => (ModelState state -> EmulatorLogs -> Maybe String) -> Actions state -> Property
- propRunActionsWithOptions :: forall state. RunModel state EmulatorM => Map CardanoAddress Value -> Params -> (ModelState state -> EmulatorLogs -> Maybe String) -> Actions state -> Property
- chainStateToChainIndex :: NetworkId -> ChainState -> ChainIndex
- chainStateToContractModelChainState :: ChainState -> ChainState
- 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 = BalanceChangeOptions Bool FeeCalculation ProtocolParameters (AddressInEra Era -> String)
- class (DefaultRealized m, HasChainIndex m, Monad m) => IsRunnable (m :: Type -> Type)
- class (ContractModel state, IsRunnable m) => RunModel state (m :: Type -> Type)
- data RunMonad (m :: Type -> Type) a
- data ChainIndex = ChainIndex {
- transactions :: [TxInState]
- networkId :: NetworkId
- data ChainState = ChainState {}
- class HasChainIndex (m :: Type -> Type)
- data TxInState = TxInState (Tx Era) ChainState Bool
- data Actions s
- class (Typeable state, Show state, HasActions state) => ContractModel state
- data ModelState state
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.
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.
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
chainStateToChainIndex :: NetworkId -> ChainState -> ChainIndex Source #
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) #
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
IsRunnable EmulatorM Source # | |
Defined in Cardano.Node.Emulator.Test | |
IsRunnable m => IsRunnable (RunMonad m) | |
Defined in Test.QuickCheck.ContractModel.Internal | |
(DefaultRealized m, IsRunnable m) => IsRunnable (ReaderT r m) | |
Defined in Test.QuickCheck.ContractModel.Internal | |
(DefaultRealized m, IsRunnable m) => IsRunnable (StateT s m) | |
Defined in Test.QuickCheck.ContractModel.Internal | |
(Monoid w, DefaultRealized m, IsRunnable m) => IsRunnable (WriterT w m) | |
Defined in Test.QuickCheck.ContractModel.Internal |
class (ContractModel state, IsRunnable m) => RunModel state (m :: Type -> Type) #
Minimal complete definition
perform
data RunMonad (m :: Type -> Type) a #
Instances
data ChainIndex #
Constructors
ChainIndex | |
Fields
|
Instances
Semigroup ChainIndex | |
Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex Methods (<>) :: ChainIndex -> ChainIndex -> ChainIndex Source # sconcat :: NonEmpty ChainIndex -> ChainIndex Source # stimes :: Integral b => b -> ChainIndex -> ChainIndex Source # |
data ChainState #
Constructors
ChainState | |
class HasChainIndex (m :: Type -> Type) #
Minimal complete definition
getChainIndex, getChainState
Instances
HasChainIndex EmulatorM Source # | |
Defined in Cardano.Node.Emulator.Test | |
(Monad m, HasChainIndex m) => HasChainIndex (RunMonad m) | |
Defined in Test.QuickCheck.ContractModel.Internal | |
(Monad m, HasChainIndex m) => HasChainIndex (ReaderT r m) | |
(Monad m, HasChainIndex m) => HasChainIndex (StateT s m) | |
(Monad m, Monoid w, HasChainIndex m) => HasChainIndex (WriterT w m) | |
Constructors
TxInState (Tx Era) ChainState Bool |
Instances
ContractModel state => Show (Actions state) | |
ContractModel s => Arbitrary (Actions s) | |
class (Typeable state, Show state, HasActions state) => ContractModel state #
Minimal complete definition
arbitraryAction, initialState, nextState
data ModelState state #
Instances
Functor ModelState | |
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) | |
Defined in Test.QuickCheck.ContractModel.DL Methods action :: Action (ModelState state) a -> DL state () | |
Show state => Show (ModelState state) | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec | |
Generic (ModelState state) | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec 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) | |
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) | |
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) | |
Defined in Test.QuickCheck.ContractModel.DL type StateType (DL state) = state | |
data Action (ModelState state) a | |
Defined in Test.QuickCheck.ContractModel.Internal.Model data Action (ModelState state) a where
|