Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data IMap (key :: i -> j -> k -> l -> *) (val :: i -> j -> k -> *) where
- imAppend :: IMap key val -> IMap key val -> IMap key val
- imLookup :: (Typeable i, Typeable j, Typeable k, Typeable l, Typeable key, Typeable val, Eq (key i j k l)) => key i j k l -> IMap key val -> Maybe (val i j k)
- imMap :: (forall i j k l. key i j k l -> key' i j k l) -> (forall i j k. val i j k -> val' i j k) -> IMap key val -> IMap key' val'
- type SchemaConstraints w schema err = (Typeable w, Monoid w, ToJSON w, Typeable schema, ContractConstraints schema, Show err, Typeable err, ToJSON err, FromJSON err, ToJSON w, FromJSON w)
- data WalletContractHandle w s e = WalletContractHandle Wallet (ContractHandle w s e)
- type Handles state = IMap (ContractInstanceKey state) WalletContractHandle
- handlesAppend :: Handles state -> Handles state -> Handles state
- data StartContract state where
- StartContract :: (SchemaConstraints w s e, Typeable p) => ContractInstanceKey state w s e p -> p -> StartContract state
- class (ContractModel state, forall w s e p. Eq (ContractInstanceKey state w s e p), forall w s e p. Show (ContractInstanceKey state w s e p)) => ContractInstanceModel state where
- data ContractInstanceKey state :: * -> Row * -> * -> * -> *
- instanceWallet :: ContractInstanceKey state w s e p -> Wallet
- instanceTag :: forall w s e p. SchemaConstraints w s e => ContractInstanceKey state w s e p -> ContractInstanceTag
- initialInstances :: [StartContract state]
- startInstances :: ModelState state -> Action state -> [StartContract state]
- instanceContract :: (forall t. HasSymbolicRep t => Symbolic t -> t) -> ContractInstanceKey state w s e p -> p -> Contract w s e ()
Documentation
data IMap (key :: i -> j -> k -> l -> *) (val :: i -> j -> k -> *) where Source #
Key-value map where keys and values have three indices that can vary between different elements
of the map. Used to store ContractHandle
s, which are indexed over observable state, schema,
and error type.
IMNil :: IMap key val | |
IMCons :: (Typeable i, Typeable j, Typeable k, Typeable l) => key i j k l -> val i j k -> IMap key val -> IMap key val |
Instances
CheckableContractModel state => RunModel (WithInstances state) (EmulatorTraceWithInstances state) | |
Defined in Plutus.Contract.Test.ContractModel.Internal perform :: ModelState (WithInstances state) -> Action (WithInstances state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> RunMonad (EmulatorTraceWithInstances state) () monitoring :: (ModelState (WithInstances state), ModelState (WithInstances state)) -> Action (WithInstances state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> SymIndex -> Property -> Property | |
ContractModel state => RunModel (WrappedState state) (SpecificationEmulatorTrace (WrappedState state)) | |
Defined in Plutus.Contract.Test.ContractModel.Interface perform :: ModelState (WrappedState state) -> Action (WrappedState state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> RunMonad (SpecificationEmulatorTrace (WrappedState state)) () monitoring :: (ModelState (WrappedState state), ModelState (WrappedState state)) -> Action (WrappedState state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> SymIndex -> Property -> Property |
imLookup :: (Typeable i, Typeable j, Typeable k, Typeable l, Typeable key, Typeable val, Eq (key i j k l)) => key i j k l -> IMap key val -> Maybe (val i j k) Source #
Look up a value in an indexed map. First checks that the indices agree, using cast
. Once the
type checker is convinced that the indices match we can check the key for equality.
imMap :: (forall i j k l. key i j k l -> key' i j k l) -> (forall i j k. val i j k -> val' i j k) -> IMap key val -> IMap key' val' Source #
In order to call contract endpoints using callEndpoint
, a ContractHandle
is required. Contract handles are managed behind the scenes by the propRunActions
functions,
based on a given a list of associations of ContractInstanceKey
s with Wallet
s and
Contract
s. Before testing starts, activateContractWallet
is called for all entries in the
list and the mapping from ContractInstanceKey
to ContractHandle
is provided in the HandleFun
argument
to perform
.
type SchemaConstraints w schema err = (Typeable w, Monoid w, ToJSON w, Typeable schema, ContractConstraints schema, Show err, Typeable err, ToJSON err, FromJSON err, ToJSON w, FromJSON w) Source #
The constraints required on contract schemas and error types to enable calling contract
endpoints (callEndpoint
).
data WalletContractHandle w s e Source #
WalletContractHandle Wallet (ContractHandle w s e) |
Instances
CheckableContractModel state => RunModel (WithInstances state) (EmulatorTraceWithInstances state) | |
Defined in Plutus.Contract.Test.ContractModel.Internal perform :: ModelState (WithInstances state) -> Action (WithInstances state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> RunMonad (EmulatorTraceWithInstances state) () monitoring :: (ModelState (WithInstances state), ModelState (WithInstances state)) -> Action (WithInstances state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> SymIndex -> Property -> Property | |
ContractModel state => RunModel (WrappedState state) (SpecificationEmulatorTrace (WrappedState state)) | |
Defined in Plutus.Contract.Test.ContractModel.Interface perform :: ModelState (WrappedState state) -> Action (WrappedState state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> RunMonad (SpecificationEmulatorTrace (WrappedState state)) () monitoring :: (ModelState (WrappedState state), ModelState (WrappedState state)) -> Action (WrappedState state) -> (forall t. HasSymbolicRep t => Symbolic t -> t) -> SymIndex -> Property -> Property |
type Handles state = IMap (ContractInstanceKey state) WalletContractHandle Source #
data StartContract state where Source #
StartContract :: (SchemaConstraints w s e, Typeable p) => ContractInstanceKey state w s e p -> p -> StartContract state |
class (ContractModel state, forall w s e p. Eq (ContractInstanceKey state w s e p), forall w s e p. Show (ContractInstanceKey state w s e p)) => ContractInstanceModel state where Source #
data ContractInstanceKey state :: * -> Row * -> * -> * -> * Source #
To be able to call a contract endpoint from a wallet a ContractHandle
is required. These
are managed by the test framework and all the user needs to do is provide this contract
instance key type representing the different contract instances that a test needs to work
with, and when creating a property (see propRunActions_
) provide a list of contract
instance keys together with their wallets and contracts.
Contract instance keys are indexed by the observable state, schema, and error type of the
contract and should be defined as a GADT. For example, a handle type for a contract with
one seller and multiple buyers could look like this.
data ContractInstanceKey MyModel w s e where Buyer :: Wallet -> ContractInstanceKey MyModel MyObsState MySchema MyError MyParams Seller :: ContractInstanceKey MyModel MyObsState MySchema MyError MyParams
instanceWallet :: ContractInstanceKey state w s e p -> Wallet Source #
Get the wallet that the contract running at a specific ContractInstanceKey
should run
in
instanceTag :: forall w s e p. SchemaConstraints w s e => ContractInstanceKey state w s e p -> ContractInstanceTag Source #
The ContractInstanceTag
of an instance key for a wallet. Defaults to walletInstanceTag
.
You must override this if you have multiple instances per wallet.
initialInstances :: [StartContract state] Source #
The initial handles
startInstances :: ModelState state -> Action state -> [StartContract state] Source #
Start new contract instances
instanceContract :: (forall t. HasSymbolicRep t => Symbolic t -> t) -> ContractInstanceKey state w s e p -> p -> Contract w s e () Source #
Map a ContractInstanceKey
k
to the Contract
that is started when we start
k
in a given ModelState
with a given semantics of SymToken
s
Instances
ContractModel state => ContractInstanceModel (WrappedState state) Source # | |
Defined in Plutus.Contract.Test.ContractModel.Interface data ContractInstanceKey (WrappedState state) :: Type -> Row Type -> Type -> Type -> Type Source # instanceWallet :: forall w (s :: Row Type) e p. ContractInstanceKey (WrappedState state) w s e p -> Wallet Source # instanceTag :: forall w (s :: Row Type) e p. SchemaConstraints w s e => ContractInstanceKey (WrappedState state) w s e p -> ContractInstanceTag Source # initialInstances :: [StartContract (WrappedState state)] Source # startInstances :: ModelState (WrappedState state) -> Action (WrappedState state) -> [StartContract (WrappedState state)] Source # instanceContract :: forall w (s :: Row Type) e p. (forall t. HasSymbolicRep t => Symbolic t -> t) -> ContractInstanceKey (WrappedState state) w s e p -> p -> Contract w s e () Source # |