Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ModelState state = ModelState {
- _currentSlot :: SlotNo
- _balanceChanges :: Map (AddressInEra Era) SymValue
- _minted :: SymValue
- _symbolics :: SymCollectionIndex
- _assertions :: [(String, Bool)]
- _assertionsOk :: Bool
- _contractState :: state
- newtype Spec state a = Spec {
- unSpec :: WriterT SymCreationIndex (ReaderT (Var SymIndex) (State (ModelState state))) a
- coerceSpec :: forall s s' a. Coercible s s' => Spec s a -> Spec s' a
- contractState :: forall state state. Lens (ModelState state) (ModelState state) state state
- currentSlotL :: forall state. Lens' (ModelState state) SlotNo
- balanceChangesL :: forall state. Lens' (ModelState state) (Map (AddressInEra Era) SymValue)
- mintedL :: forall state. Lens' (ModelState state) SymValue
- assertions :: forall state. Lens' (ModelState state) [(String, Bool)]
- assertionsOk :: forall state. Lens' (ModelState state) Bool
- symbolics :: forall state. Lens' (ModelState state) SymCollectionIndex
- currentSlot :: Getter (ModelState state) SlotNo
- balanceChanges :: Getter (ModelState state) (Map (AddressInEra Era) SymValue)
- balanceChange :: Ord (AddressInEra Era) => AddressInEra Era -> Getter (ModelState state) SymValue
- minted :: Getter (ModelState state) SymValue
- lockedValue :: ModelState s -> SymValue
- modState :: forall state a. Setter' (ModelState state) a -> (a -> a) -> Spec state ()
- class Monad m => GetModelState m where
- type StateType m :: *
- getModelState :: m (ModelState (StateType m))
- getContractState :: GetModelState m => m (StateType m)
- askModelState :: GetModelState m => (ModelState (StateType m) -> a) -> m a
- askContractState :: GetModelState m => (StateType m -> a) -> m a
- viewModelState :: GetModelState m => Getting a (ModelState (StateType m)) a -> m a
- viewContractState :: GetModelState m => Getting a (StateType m) a -> m a
- runSpec :: Spec state () -> Var SymIndex -> ModelState state -> ModelState state
- symbolicsCreatedBy :: Spec state () -> Var SymIndex -> ModelState state -> SymCreationIndex
- createSymbolic :: forall t state. HasSymbolicRep t => String -> Spec state (Symbolic t)
- createToken :: String -> Spec state SymToken
- createTxOut :: String -> Spec state SymTxOut
- createTxIn :: String -> Spec state SymTxIn
- mint :: SymValueLike v => v -> Spec state ()
- burn :: SymValueLike v => v -> Spec state ()
- deposit :: SymValueLike v => AddressInEra Era -> v -> Spec state ()
- withdraw :: SymValueLike v => AddressInEra Era -> v -> Spec state ()
- transfer :: SymValueLike v => AddressInEra Era -> AddressInEra Era -> v -> Spec state ()
- assertSpec :: String -> Bool -> Spec state ()
Documentation
data ModelState state Source #
The ModelState
models the state of the blockchain. It contains,
- the contract-specific state (
contractState
) - the current slot (
currentSlot
) - the wallet balances (
balances
) - the amount that has been minted (
minted
)
ModelState | |
|
Instances
The Spec
monad is a state monad over the ModelState
with reader and writer components to keep track
of newly created symbolic tokens. It is used exclusively by the nextState
function to model the effects
of an action on the blockchain.
Spec | |
|
Instances
MonadState state (Spec state) Source # | |
Monad (Spec state) Source # | |
Functor (Spec state) Source # | |
Applicative (Spec state) Source # | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec pure :: a -> Spec state a Source # (<*>) :: Spec state (a -> b) -> Spec state a -> Spec state b Source # liftA2 :: (a -> b -> c) -> Spec state a -> Spec state b -> Spec state c Source # (*>) :: Spec state a -> Spec state b -> Spec state b Source # (<*) :: Spec state a -> Spec state b -> Spec state a Source # | |
GetModelState (Spec state) Source # | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec getModelState :: Spec state (ModelState (StateType (Spec state))) Source # | |
type StateType (Spec state) Source # | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec |
contractState :: forall state state. Lens (ModelState state) (ModelState state) state state Source #
Lens for the contract-specific part of the model state.
currentSlotL :: forall state. Lens' (ModelState state) SlotNo Source #
balanceChangesL :: forall state. Lens' (ModelState state) (Map (AddressInEra Era) SymValue) Source #
mintedL :: forall state. Lens' (ModelState state) SymValue Source #
assertions :: forall state. Lens' (ModelState state) [(String, Bool)] Source #
assertionsOk :: forall state. Lens' (ModelState state) Bool Source #
symbolics :: forall state. Lens' (ModelState state) SymCollectionIndex Source #
currentSlot :: Getter (ModelState state) SlotNo Source #
Get the current slot.
Spec
monad update functions: wait
and waitUntil
.
balanceChanges :: Getter (ModelState state) (Map (AddressInEra Era) SymValue) Source #
balanceChange :: Ord (AddressInEra Era) => AddressInEra Era -> Getter (ModelState state) SymValue Source #
minted :: Getter (ModelState state) SymValue Source #
Get the amount of tokens minted so far. This is used to compute lockedValue
.
lockedValue :: ModelState s -> SymValue Source #
How much value is currently locked by contracts. This computed by subtracting the wallet
balances
from the minted
value.
modState :: forall state a. Setter' (ModelState state) a -> (a -> a) -> Spec state () Source #
Modify a field in the ModelState
class Monad m => GetModelState m where Source #
Monads with read access to the model state: the Spec
monad used in nextState
, and the DL
monad used to construct test scenarios.
type StateType m :: * Source #
The contract state type of the monad. For both Spec
and DL
this is simply the state
parameter of the respective monad.
getModelState :: m (ModelState (StateType m)) Source #
Get the current model state.
Instances
GetModelState (Spec state) Source # | |
Defined in Test.QuickCheck.ContractModel.Internal.Spec getModelState :: Spec state (ModelState (StateType (Spec state))) Source # | |
GetModelState (DL state) Source # | |
Defined in Test.QuickCheck.ContractModel.DL getModelState :: DL state (ModelState (StateType (DL state))) Source # |
getContractState :: GetModelState m => m (StateType m) Source #
Get the contract state part of the model state.
askModelState :: GetModelState m => (ModelState (StateType m) -> a) -> m a Source #
Get a component of the model state.
askContractState :: GetModelState m => (StateType m -> a) -> m a Source #
Get a component of the contract state.
viewModelState :: GetModelState m => Getting a (ModelState (StateType m)) a -> m a Source #
Get a component of the model state using a lens.
viewContractState :: GetModelState m => Getting a (StateType m) a -> m a Source #
Get a component of the contract state using a lens.
runSpec :: Spec state () -> Var SymIndex -> ModelState state -> ModelState state Source #
symbolicsCreatedBy :: Spec state () -> Var SymIndex -> ModelState state -> SymCreationIndex Source #
createSymbolic :: forall t state. HasSymbolicRep t => String -> Spec state (Symbolic t) Source #
createToken :: String -> Spec state SymToken Source #
Create a new symbolic token in nextState
- must have a
corresponding registerToken
call in perform
createTxOut :: String -> Spec state SymTxOut Source #
Create a new symbolic TxOut in nextState
- must have a
corresponding registerTxOut
call in perform
createTxIn :: String -> Spec state SymTxIn Source #
Create a new symbolic TxIn in nextState
- must have a
corresponding registerTxIn
call in perform
mint :: SymValueLike v => v -> Spec state () Source #
Mint tokens. Minted tokens start out as lockedValue
(i.e. owned by the contract) and can be
transferred to wallets using deposit
.
deposit :: SymValueLike v => AddressInEra Era -> v -> Spec state () Source #
Add tokens to the balanceChange
of an address. The added tokens are subtracted from the
lockedValue
of tokens held by contracts.
withdraw :: SymValueLike v => AddressInEra Era -> v -> Spec state () Source #
Withdraw tokens from an address. The withdrawn tokens are added to the lockedValue
of tokens
held by contracts.
:: SymValueLike v | |
=> AddressInEra Era | Transfer from this address |
-> AddressInEra Era | to this address |
-> v | this much value |
-> Spec state () |
Transfer tokens between wallets, updating their balances
.