Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
:: 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 #
:: 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 #
BalanceChangeOptions Bool FeeCalculation ProtocolParameters (AddressInEra Era -> String) |
class (DefaultRealized m, HasChainIndex m, Monad m) => IsRunnable (m :: Type -> Type) #
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) #
perform
data RunMonad (m :: Type -> Type) a #
Instances
data ChainIndex #
ChainIndex | |
|
Instances
Semigroup ChainIndex | |
Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex (<>) :: ChainIndex -> ChainIndex -> ChainIndex Source # sconcat :: NonEmpty ChainIndex -> ChainIndex Source # stimes :: Integral b => b -> ChainIndex -> ChainIndex Source # |
data ChainState #
class HasChainIndex (m :: Type -> Type) #
getChainIndex, getChainState
Instances
HasChainIndex EmulatorM Source # | |
(Monad m, HasChainIndex m) => HasChainIndex (RunMonad m) | |
Defined in Test.QuickCheck.ContractModel.Internal | |
(Monad m, HasChainIndex m) => HasChainIndex (ReaderT r m) | |
Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex getChainIndex :: ReaderT r m ChainIndex getChainState :: ReaderT r m ChainState | |
(Monad m, HasChainIndex m) => HasChainIndex (StateT s m) | |
Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex getChainIndex :: StateT s m ChainIndex getChainState :: StateT s m ChainState | |
(Monad m, Monoid w, HasChainIndex m) => HasChainIndex (WriterT w m) | |
Defined in Test.QuickCheck.ContractModel.Internal.ChainIndex getChainIndex :: WriterT w m ChainIndex getChainState :: WriterT w m ChainState |
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 #
arbitraryAction, initialState, nextState
data ModelState state #