plutus-contract-model-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Contract.Test.ContractModel.Internal.ContractInstance

Synopsis

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 ContractHandles, which are indexed over observable state, schema, and error type.

Constructors

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

Instances details
CheckableContractModel state => RunModel (WithInstances state) (EmulatorTraceWithInstances state) 
Instance details

Defined in Plutus.Contract.Test.ContractModel.Internal

Methods

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)) 
Instance details

Defined in Plutus.Contract.Test.ContractModel.Interface

Methods

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

imAppend :: IMap key val -> IMap key val -> IMap key val Source #

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 ContractInstanceKeys with Wallets and Contracts. 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 #

Constructors

WalletContractHandle Wallet (ContractHandle w s e) 

Instances

Instances details
CheckableContractModel state => RunModel (WithInstances state) (EmulatorTraceWithInstances state) 
Instance details

Defined in Plutus.Contract.Test.ContractModel.Internal

Methods

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)) 
Instance details

Defined in Plutus.Contract.Test.ContractModel.Interface

Methods

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

handlesAppend :: Handles state -> Handles state -> Handles state Source #

data StartContract state where Source #

Constructors

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 #

Minimal complete definition

instanceWallet, instanceContract

Associated Types

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

Methods

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 SymTokens

Instances

Instances details
ContractModel state => ContractInstanceModel (WrappedState state) Source # 
Instance details

Defined in Plutus.Contract.Test.ContractModel.Interface

Associated Types

data ContractInstanceKey (WrappedState state) :: Type -> Row Type -> Type -> Type -> Type Source #

Methods

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 #