cleveland-0.3.0: Testing framework for Morley.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Cleveland

Description

Michelson contracts testing on a real Tezos network.

See the documentation for usage instructions.

Synopsis

Documentation

data Alias (kind :: AddressKind) #

Instances

Instances details
IsString ContractAlias Source # 
Instance details

Defined in Test.Cleveland.Instances

IsString ImplicitAlias Source # 
Instance details

Defined in Test.Cleveland.Instances

GCompare Alias 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

gcompare :: forall (a :: k) (b :: k). Alias a -> Alias b -> GOrdering a b #

GEq Alias 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

geq :: forall (a :: k) (b :: k). Alias a -> Alias b -> Maybe (a :~: b) #

ArgDict (c :: AddressKind -> Constraint) Alias 
Instance details

Defined in Morley.Tezos.Address.Alias

Associated Types

type ConstraintsFor Alias c #

Methods

argDict :: forall (a :: k). ConstraintsFor Alias c => Alias a -> Dict (c a) #

(SingI kind, L1AddressKind kind) => FromJSON (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

parseJSON :: Value -> Parser (Alias kind) #

parseJSONList :: Value -> Parser [Alias kind] #

ToJSON (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

toJSON :: Alias kind -> Value #

toEncoding :: Alias kind -> Encoding #

toJSONList :: [Alias kind] -> Value #

toEncodingList :: [Alias kind] -> Encoding #

Show (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

showsPrec :: Int -> Alias kind -> ShowS #

show :: Alias kind -> String #

showList :: [Alias kind] -> ShowS #

NFData (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

rnf :: Alias kind -> () #

Buildable (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

build :: Alias kind -> Builder #

Eq (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

(==) :: Alias kind -> Alias kind -> Bool #

(/=) :: Alias kind -> Alias kind -> Bool #

Ord (Alias kind) 
Instance details

Defined in Morley.Tezos.Address.Alias

Methods

compare :: Alias kind -> Alias kind -> Ordering #

(<) :: Alias kind -> Alias kind -> Bool #

(<=) :: Alias kind -> Alias kind -> Bool #

(>) :: Alias kind -> Alias kind -> Bool #

(>=) :: Alias kind -> Alias kind -> Bool #

max :: Alias kind -> Alias kind -> Alias kind #

min :: Alias kind -> Alias kind -> Alias kind #

CmdArg (Alias kind) 
Instance details

Defined in Morley.Client.TezosClient.Types

Methods

toCmdArg :: Alias kind -> String

type ConstraintsFor Alias (c :: AddressKind -> Constraint) 
Instance details

Defined in Morley.Tezos.Address.Alias

type ConstraintsFor Alias (c :: AddressKind -> Constraint) = (c 'AddressKindImplicit, c 'AddressKindContract)

type ContractAlias = Alias 'AddressKindContract #

type ImplicitAlias = Alias 'AddressKindImplicit #

data KindedAddress (kind :: AddressKind) #

Instances

Instances details
FromJSON Address 
Instance details

Defined in Morley.Tezos.Address

Methods

parseJSON :: Value -> Parser Address #

parseJSONList :: Value -> Parser [Address] #

FromJSONKey Address 
Instance details

Defined in Morley.Tezos.Address

ToContractAddress ContractAddress Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

ToL1Address L1Address Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: L1Address -> L1Address Source #

ToAddress Address 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: Address -> Address #

ToAddress L1Address 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: L1Address -> Address #

HasAnnotation Address 
Instance details

Defined in Lorentz.Annotation

Methods

getAnnotation :: FollowEntrypointFlag -> Notes (ToT Address)

annOptions :: AnnOptions

HasRPCRepr Address 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Address #

TypeHasDoc Address 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

Associated Types

type TypeDocFieldDescriptions Address :: FieldDescriptions

Methods

typeDocName :: Proxy Address -> Text

typeDocMdDescription :: Markdown

typeDocMdReference :: Proxy Address -> WithinParens -> Markdown

typeDocDependencies :: Proxy Address -> [SomeDocDefinitionItem]

typeDocHaskellRep :: TypeDocHaskellRep Address

typeDocMichelsonRep :: TypeDocMichelsonRep Address

IsoValue Address 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT Address :: T

Methods

toVal :: Address -> Value (ToT Address)

fromVal :: Value (ToT Address) -> Address

CmdArg Address 
Instance details

Defined in Morley.Client.TezosClient.Types

Methods

toCmdArg :: Address -> String

NiceStorage st => ToStorageType st ContractAddress Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

FromContractRef cp Address 
Instance details

Defined in Lorentz.Address

Methods

fromContractRef :: ContractRef cp -> Address

GCompare KindedAddress 
Instance details

Defined in Morley.Tezos.Address

Methods

gcompare :: forall (a :: k) (b :: k). KindedAddress a -> KindedAddress b -> GOrdering a b #

GEq KindedAddress 
Instance details

Defined in Morley.Tezos.Address

Methods

geq :: forall (a :: k) (b :: k). KindedAddress a -> KindedAddress b -> Maybe (a :~: b) #

ArgDict (c :: AddressKind -> Constraint) KindedAddress 
Instance details

Defined in Morley.Tezos.Address

Associated Types

type ConstraintsFor KindedAddress c #

Methods

argDict :: forall (a :: k). ConstraintsFor KindedAddress c => KindedAddress a -> Dict (c a) #

ToTAddress cp vd Address 
Instance details

Defined in Lorentz.Address

Methods

toTAddress :: Address -> TAddress cp vd

ToTAddress cp vd ContractAddress 
Instance details

Defined in Lorentz.Address

Methods

toTAddress :: ContractAddress -> TAddress cp vd

(cp ~ (), vd ~ ()) => ToTAddress cp vd ImplicitAddress 
Instance details

Defined in Lorentz.Address

Methods

toTAddress :: ImplicitAddress -> TAddress cp vd

ToTAddress cp vd L1Address 
Instance details

Defined in Lorentz.Address

Methods

toTAddress :: L1Address -> TAddress cp vd

Lift (KindedAddress kind :: Type) 
Instance details

Defined in Morley.Tezos.Address

Methods

lift :: Quote m => KindedAddress kind -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => KindedAddress kind -> Code m (KindedAddress kind) #

CanCastTo Address (TAddress p vd :: Type) 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy Address -> Proxy (TAddress p vd) -> ()

SingI kinds => FromJSON (ConstrainedAddress kinds) 
Instance details

Defined in Morley.Tezos.Address

Methods

parseJSON :: Value -> Parser (ConstrainedAddress kinds) #

parseJSONList :: Value -> Parser [ConstrainedAddress kinds] #

SingI kind => FromJSON (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

SingI kind => FromJSONKey (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

ToJSON (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

ToJSONKey (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

(Bottom, TypeError ('Text "There is no instance defined for (IsString Address)" :$$: 'Text "Consider using QuasiQuotes: `[ta|some text...|]`") :: Constraint) => IsString (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

fromString :: String -> KindedAddress kind #

Show (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

showsPrec :: Int -> KindedAddress kind -> ShowS #

show :: KindedAddress kind -> String #

showList :: [KindedAddress kind] -> ShowS #

L1AddressKind kind => ToL1Address (KindedAddress kind) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: KindedAddress kind -> L1Address Source #

NFData (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

rnf :: KindedAddress kind -> () #

Buildable (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

build :: KindedAddress kind -> Builder #

Eq (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

(==) :: KindedAddress kind -> KindedAddress kind -> Bool #

(/=) :: KindedAddress kind -> KindedAddress kind -> Bool #

Ord (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

Methods

compare :: KindedAddress kind -> KindedAddress kind -> Ordering #

(<) :: KindedAddress kind -> KindedAddress kind -> Bool #

(<=) :: KindedAddress kind -> KindedAddress kind -> Bool #

(>) :: KindedAddress kind -> KindedAddress kind -> Bool #

(>=) :: KindedAddress kind -> KindedAddress kind -> Bool #

max :: KindedAddress kind -> KindedAddress kind -> KindedAddress kind #

min :: KindedAddress kind -> KindedAddress kind -> KindedAddress kind #

ToAddress (KindedAddress kind) 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: KindedAddress kind -> Address #

SingI kind => HasCLReader (KindedAddress kind) 
Instance details

Defined in Morley.Tezos.Address

CmdArg (KindedAddress kind) 
Instance details

Defined in Morley.Client.TezosClient.Types

Methods

toCmdArg :: KindedAddress kind -> String

CanCastTo (TAddress p vd :: Type) Address 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (TAddress p vd) -> Proxy Address -> ()

ToJSON (Constrained c KindedAddress) 
Instance details

Defined in Morley.Tezos.Address

Methods

toJSON :: Constrained c KindedAddress -> Value #

toEncoding :: Constrained c KindedAddress -> Encoding #

toJSONList :: [Constrained c KindedAddress] -> Value #

toEncodingList :: [Constrained c KindedAddress] -> Encoding #

ToJSONKey (Constrained c KindedAddress) 
Instance details

Defined in Morley.Tezos.Address

type AsRPC Address 
Instance details

Defined in Morley.AsRPC

type AsRPC Address = Address
type TypeDocFieldDescriptions Address 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type TypeDocFieldDescriptions Address = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT Address 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ToT Address = 'TAddress
type ConstraintsFor KindedAddress (c :: AddressKind -> Constraint) 
Instance details

Defined in Morley.Tezos.Address

type ConstraintsFor KindedAddress (c :: AddressKind -> Constraint) = (c 'AddressKindImplicit, c 'AddressKindContract, c 'AddressKindTxRollup)

type ContractAddress = KindedAddress 'AddressKindContract #

type ImplicitAddress = KindedAddress 'AddressKindImplicit #

data ContractHandle (cp :: Type) (st :: Type) (vd :: Type) Source #

Handle to a contract.

This is what you get when originating a contract and that allows further operations with the contract within the test framework.

Note that this is part of the testing framework and exists solely in Haskell world, so it has no IsoValue and related instances and cannot be used in Lorentz code.

Constructors

(NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd) => ContractHandle 

Instances

Instances details
(cp' ~ cp, vd ~ vd') => ToTAddress cp' vd' (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toTAddress :: ContractHandle cp st vd -> TAddress cp' vd'

st ~ st' => ToStorageType st' (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

ToContractRef arg (TAddress cp vd) => ToContractRef arg (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toContractRef :: ContractHandle cp st vd -> ContractRef arg

Show (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

showsPrec :: Int -> ContractHandle cp st vd -> ShowS #

show :: ContractHandle cp st vd -> String #

showList :: [ContractHandle cp st vd] -> ShowS #

ToContractAddress (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

ToL1Address (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: ContractHandle cp st vd -> L1Address Source #

Buildable (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

build :: ContractHandle cp st vd -> Builder #

ToAddress (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toAddress :: ContractHandle cp st vd -> Address #

data TransferData Source #

Information about transfer operation.

Constructors

forall v addr.(NiceParameter v, ToL1Address addr) => TransferData 

Fields

  • tdTo :: addr

    Receiver address for this transaction.

  • tdAmount :: Mutez

    Amount to be transferred.

  • tdEntrypoint :: EpName

    An entrypoint to be called. Consider using ep in testing scenarios.

  • tdParameter :: v

    Parameter that will be used for a contract call. Set to () for transfers to key addresses.

data TypedContract cp st vd where Source #

A wrapper around Contract to reduce awkwardness

Constructors

TypedContract :: Contract (ToT cp) (ToT st) -> TypedContract cp st vd 

type Scenario m = MonadScenario m => Scenario' m Source #

A convenience type synonym for Scenario` that has MonadScenario constraint baked in.

data PureM a Source #

Instances

Instances details
MonadFail PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

fail :: String -> PureM a #

MonadIO PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

liftIO :: IO a -> PureM a #

Applicative PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

pure :: a -> PureM a #

(<*>) :: PureM (a -> b) -> PureM a -> PureM b #

liftA2 :: (a -> b -> c) -> PureM a -> PureM b -> PureM c #

(*>) :: PureM a -> PureM b -> PureM b #

(<*) :: PureM a -> PureM b -> PureM a #

Functor PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

fmap :: (a -> b) -> PureM a -> PureM b #

(<$) :: a -> PureM b -> PureM a #

Monad PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

(>>=) :: PureM a -> (a -> PureM b) -> PureM b #

(>>) :: PureM a -> PureM b -> PureM b #

return :: a -> PureM a #

MonadScenario PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Scenario

MonadCatch PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

catch :: Exception e => PureM a -> (e -> PureM a) -> PureM a #

MonadThrow PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

throwM :: Exception e => e -> PureM a #

MonadState PureState PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

get :: PureM PureState #

put :: PureState -> PureM () #

state :: (PureState -> (a, PureState)) -> PureM a #

MonadWriter LogsInfo PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

Methods

writer :: (a, LogsInfo) -> PureM a #

tell :: LogsInfo -> PureM () #

listen :: PureM a -> PureM (a, LogsInfo) #

pass :: PureM (a, LogsInfo -> LogsInfo) -> PureM a #

MonadReader (IORef PureState) PureM Source # 
Instance details

Defined in Test.Cleveland.Internal.Pure

data ClientM a Source #

Instances

Instances details
MonadFail ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

fail :: String -> ClientM a #

MonadIO ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

liftIO :: IO a -> ClientM a #

Applicative ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

pure :: a -> ClientM a #

(<*>) :: ClientM (a -> b) -> ClientM a -> ClientM b #

liftA2 :: (a -> b -> c) -> ClientM a -> ClientM b -> ClientM c #

(*>) :: ClientM a -> ClientM b -> ClientM b #

(<*) :: ClientM a -> ClientM b -> ClientM a #

Functor ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

fmap :: (a -> b) -> ClientM a -> ClientM b #

(<$) :: a -> ClientM b -> ClientM a #

Monad ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

(>>=) :: ClientM a -> (a -> ClientM b) -> ClientM b #

(>>) :: ClientM a -> ClientM b -> ClientM b #

return :: a -> ClientM a #

MonadScenario ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Scenario

MonadCatch ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

catch :: Exception e => ClientM a -> (e -> ClientM a) -> ClientM a #

MonadThrow ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Methods

throwM :: Exception e => e -> ClientM a #

MonadReader (IORef ClientState) ClientM Source # 
Instance details

Defined in Test.Cleveland.Internal.Client

Validation

data TransferFailure Source #

Failures that could be expected in the execution of a transfer. These can be caught and handled with attempt.

Real network implementation based on octez-client and RPC.

testScenario :: TestName -> (forall m. Scenario m) -> TestTree Source #

Create a tasty test case from a Scenario.

This will create a test tree with 2 tests: one that runs the Scenario on the Morley.Michelson.Runtime emulator, and another that runs it on a real Tezos network.

The network config is read from the command line/environment variables. Use --help to see the available options.

If a TestTree contains many tests scheduled to run on a real Tezos network, those tests will be run sequentially.

testScenarioOnNetwork :: TestName -> Scenario ClientM -> TestTree Source #

Create a tasty test case from a Scenario.

This will create a test tree with 1 test, which will run the Scenario on real Tezos network.

scenarioNetwork :: NetworkT ClientM () -> Scenario' ClientM Source #

Finalize a scenario that needs network-only features.

class MonadFail m => MonadScenario m where Source #

Typeclass for base monads that can implement a scenario.

Methods

scenario :: ClevelandT m () -> Scenario' m Source #

Finalize a generic cleveland scenario.

getMorleyClientEnv :: MonadNetwork caps m => m MorleyClientEnv Source #

Get a MorleyClientEnv when running a test on network. Useful to run f.ex. octez-client inside a network test.

This is considered a pretty low-level function, so it's better to avoid it in most cases.

Emulation tests

testScenarioOnEmulator :: TestName -> Scenario PureM -> TestTree Source #

Create a tasty test case from an emulated Scenario.

This will create a test tree with 1 test, which will run the Scenario on the Morley.Michelson.Runtime emulator.

scenarioEmulated :: EmulatedT PureM () -> Scenario' PureM Source #

Finalize a scenario that needs emulator-only features.

withInitialNow :: Timestamp -> Scenario' PureM -> Scenario' PureM Source #

Use with an emulated Scenario to configure the initial now value in tests.

Example : > testScenarioOnEmulator Testname $ withInitialNow (Timestamp 10000000) $ scenarioEmulated $ tests > testScenarioOnEmulator Testname $ withInitialNow (Timestamp 10000000) $ scenario $ tests

withInitialLevel :: Natural -> Scenario' PureM -> Scenario' PureM Source #

Similar to withInitialNow but for the initial level

withMinBlockTime :: Natural -> Scenario' PureM -> Scenario' PureM Source #

Similar to withInitialNow but for the MINIMAL_BLOCK_DELAY protocol constant.

withChainId :: ChainId -> Scenario' PureM -> Scenario' PureM Source #

Similar to withInitialNow but for the chain id

collectLogs :: LogsInfo -> MorleyLogs Source #

Collect logs produced by all contracts into the single list

logsForAddress :: (Each s s ScenarioLogs ScenarioLogs, ToAddress addr) => addr -> s -> [MorleyLogs] Source #

Get logs for a given address from LogsInfo

Cleveland actions

type MonadCleveland caps m = (m ~ ReaderT caps (ClevelandBaseMonad caps), HasClevelandCaps caps) Source #

Constraint for a monad in which we can do cleveland actions.

class (MonadTransfer m, MonadOriginate m) => MonadOps m Source #

Synonym typeclass for monads where network operations can occur.

This has instances for MonadCleveland and ClevelandOpsBatch contexts.

Practically, if you want to use transfer or originate in a monad, add a MonadOps constraint on it, f. ex.:

callEp1 :: MonadOps m => ContractHandle MyParam () () -> Integer -> m ()
callEp1 ch = transfer ch . calling (ep @"Entrypoint1")

Instances

Instances details
(MonadTransfer m, MonadOriginate m) => MonadOps m Source # 
Instance details

Defined in Test.Cleveland.Internal.Actions

type MonadEmulated caps m = (MonadCleveland caps m, HasEmulatedCaps caps) Source #

Constraint for a monad in which we can do cleveland actions that can't be run on a real network. It requires the EmulatedCaps capability.

type ClevelandT m = ReaderT (ClevelandCaps m) m Source #

Monad transformer that adds only the ClevelandCaps capabilities.

type EmulatedT m = ReaderT (EmulatedCaps m) m Source #

Monad transformer that adds both ClevelandCaps and EmulatedCaps capabilities.

withSender :: MonadCleveland caps m => ImplicitAddress -> m a -> m a Source #

Update the current sender on whose behalf transfers and originations are invoked.

withMoneybag :: MonadCleveland caps m => ImplicitAddress -> m a -> m a Source #

Update the current moneybag that transfers money on the newly created addresses. For the rare occasions when this is necessary.

runIO :: (HasCallStack, MonadCleveland caps m) => IO res -> m res Source #

Runs an IO action.

resolveAddress :: (HasCallStack, MonadCleveland caps m) => Alias kind -> m (KindedAddress kind) Source #

Get the address of the implicit account / contract associated with the given alias.

refillable :: MonadCleveland caps m => m ImplicitAddress -> m ImplicitAddress Source #

Simple combinator that marks address as "refillable".

If a refillable address lacks funds for the next operation, some funds will automatically be transferred to it.

newAddress :: (HasCallStack, MonadCleveland caps m) => SpecificOrDefaultAlias -> m ImplicitAddress Source #

If the given alias is already associated with an existing address, that address will be reused and returned. Otherwise, generate a new secret key and record it with given alias.

If the account has too low of a balance, a small amount of XTZ will be transferred to it.

Notes:

  • By default, the XTZ is transferred from the account associated with the moneybag alias. This can be overridden with the --cleveland-moneybag-alias command line option, the TASTY_CLEVELAND_MONEYBAG_ALIAS env var, or withMoneybag.

newAddresses :: forall n n' caps m. (HasCallStack, MonadCleveland caps m, IsoNatPeano n n') => SizedList n SpecificOrDefaultAlias -> m (SizedList n ImplicitAddress) Source #

Batched version of newAddress

newFreshAddress :: (HasCallStack, MonadCleveland caps m) => SpecificOrDefaultAlias -> m ImplicitAddress Source #

Generate a new secret key and record it with given alias. If the alias is already known, the key will be overwritten. The address is guaranteed to be fresh, i. e. no operations on it have been made.

enumAliases :: forall n n'. (SingIPeano n, IsoNatPeano n n') => ImplicitAlias -> SizedList n SpecificOrDefaultAlias Source #

Create a list of similarly named SpecificAliases.

For example,

>>> enumAliases @2 "operator" `isEquivalentTo` "operator-0" :< "operator-1" :< Nil
True

signBytes :: (HasCallStack, MonadCleveland caps m) => ByteString -> ImplicitAddress -> m Signature Source #

Get the signature of the preapplied operation.

signBinary :: (HasCallStack, BytesLike bs, MonadCleveland caps m) => bs -> ImplicitAddress -> m (TSignature bs) Source #

Type-safer version of signBytes.

originate :: forall contract r. (HasCallStack, ContractClass contract, OriginateFunc contract '[] r) => ContractAlias -> ContractStorage contract -> contract -> r Source #

Originate a new contract with given data.

Can accept untypted or Lorentz contracts as-is. With typed Michelson contracts, you need to wrap the contract in TypedContract specifying its Haskell-land parameter, storage types and view descriptors, e.g.

originate "typed contract" defaultStorage $ TypedContract @Param @Storage @() michelsonContract

Storage type can be auto-deduced in most cases, so you can skip it with @_.

After the mandatory arguments, you can add Large or a Mutez value, e.g. by using tz quasi-quoter:

originate "contract" initialStorage contract Large
originate "contract" initialStorage contract [tz|123micro|]
originate "contract" initialStorage contract [tz|123micro|] Large

The order is arbitrary, but each can be specified at most once.

data Large Source #

Mark a contract that doesn't fit into the origination size limit. This will execute multiple origination steps.

Such origination cannot be batched (it simply may not fit).

Constructors

Large 

Instances

Instances details
(OFConstraints ct 'PropLarge props r, GetLarge props ~ 'NotLarge) => OriginateFunc ct props (Large -> r) Source #

Set large origination.

Instance details

Defined in Test.Cleveland.Internal.Actions.Originate

transfer :: forall addr r. (HasCallStack, TransferFunc ('Incomplete (InitialTransferMode addr)) 'TransferIgnoreResult 'HasNoAmount r, ToL1Address addr) => addr -> r Source #

Base method for making a transfer.

You can specify additional arguments after the destination address to modify optional transfer arguments. Those can either be Mutez to specify transfer amount (0 by default), or a specially constructed call descriptor. The order is arbitrary, but it is usually more convenient to specify transfer amount first. For example:

transfer addr [tz|123u|] $ calling (ep @"Entrypoint") ()
transfer addr [tz|123u|]

If the call isn't specified, then the default entrypoint will be called with (), i.e.

transfer addr

is functionally the same as

transfer addr $ calling def ()

If the address in the first argument is untyped, the transfer is unchecked. Unchecked transfers must use unsafeCalling for the call specification. You can also use unsafeCalling with typed address to force an unchecked transfer.

See Test.Cleveland.Internal.Actions.Transfer for further explanation of the interface.

By default, the sender is the account associated with the moneybag alias. This can be overridden with the --cleveland-moneybag-alias command line option, the TASTY_CLEVELAND_MONEYBAG_ALIAS env var, or withSender.

In some polymorphic cases, you may need to add HasEntrypointArg constraint:

>>> :{
example
  :: (MonadCleveland caps m, NiceParameter cp)
  => ContractHandle cp st vd -> m ()
example ch = transfer ch (123 :: Mutez)
:}
...
... Can not look up entrypoints in type
...   cp
... The most likely reason it is ambiguous, or you need
...   HasEntrypointArg cp (EntrypointRef 'Nothing) ()
... constraint
...

You can fix this by adding the constraint:

>>> :{
example
  :: ( MonadCleveland caps m, NiceParameter cp
     , HasEntrypointArg cp (EntrypointRef 'Nothing) ())
  => ContractHandle cp st vd -> m ()
example ch = transfer ch (123 :: Mutez)
:}

GHC may not always figure out the type of the entrypoint parameter. In that case, it'll show unbound type variable, usually arg0:

>>> :{
example
  :: (MonadCleveland caps m, NiceParameter cp, NiceParameter arg)
  => ContractHandle cp st vd -> arg -> m ()
example ch x = transfer ch (123 :: Mutez) $ calling def x
:}
...
... Can not look up entrypoints in type
...   cp
... The most likely reason it is ambiguous, or you need
...   HasEntrypointArg cp (EntrypointRef 'Nothing) arg0
... constraint
...

Either specifying a concrete type in the constraint, or leaving it polymorphic, fixes this:

>>> :{
example
  :: ( MonadCleveland caps m, NiceParameter cp, NiceParameter arg
     , HasEntrypointArg cp (EntrypointRef 'Nothing) Integer)
  => ContractHandle cp st vd -> Integer -> m ()
example ch x = transfer ch (123 :: Mutez) $ calling def x
:}
>>> :{
example
  :: ( MonadCleveland caps m, NiceParameter cp, NiceParameter arg
     , HasEntrypointArg cp (EntrypointRef 'Nothing) arg)
  => ContractHandle cp st vd -> arg -> m ()
example ch x = transfer ch (123 :: Mutez) $ calling def x
:}

data WithContractEvents Source #

transfer flag to signal we want contract events emitted by EMIT returned. Passed in the variadic part of transfer, e.g.

transfer addr [tz|123u|] WithContractEvents $ calling (ep @"Entrypoint") ()

Constructors

WithContractEvents 

Instances

Instances details
(TransferFunc mode 'TransferWithEmits am r, NoDuplicateEmit emit, emit ~ 'TransferIgnoreResult) => TransferFunc mode emit am (WithContractEvents -> r) Source # 
Instance details

Defined in Test.Cleveland.Internal.Actions.Transfer

data ContractEvent Source #

Data structure representing a contract event.

Constructors

ContractEvent 

Fields

calling :: forall mname. EntrypointRef mname -> forall epArg param. (NiceParameter epArg, HasEntrypointArg param (EntrypointRef mname) epArg) => epArg -> GenericCall ('Checked param) Source #

Safely call an entrypoint specified by the first argument with the provided parameter.

The first character of the entrypoint name must be capitalized.

This is "safe" in the sense that the contract is checked if it indeed has the specified entrypoint and the entrypoint in question accepts the argument provided, a type error is raised otherwise.

transfer addr $ calling (ep @"Entrypoint") ()

Use CallDefault or def to call the default entrypoint.

transfer addr $ calling def ()

Notice that type variables for entrypoint argument and full parameter are specified after the entrypoint. This is done so more for readability. F. ex.:

transfer addr $ calling def @Integer 123

This does also marginally simplify type inference in the case of partial application.

class Default a where #

A class for types with a default value.

Minimal complete definition

Nothing

Methods

def :: a #

The default value for this type.

Instances

Instances details
Default All 
Instance details

Defined in Data.Default.Class

Methods

def :: All #

Default Any 
Instance details

Defined in Data.Default.Class

Methods

def :: Any #

Default CClock 
Instance details

Defined in Data.Default.Class

Methods

def :: CClock #

Default CDouble 
Instance details

Defined in Data.Default.Class

Methods

def :: CDouble #

Default CFloat 
Instance details

Defined in Data.Default.Class

Methods

def :: CFloat #

Default CInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CInt #

Default CIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntMax #

Default CIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CIntPtr #

Default CLLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLLong #

Default CLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CLong #

Default CPtrdiff 
Instance details

Defined in Data.Default.Class

Methods

def :: CPtrdiff #

Default CSUSeconds 
Instance details

Defined in Data.Default.Class

Methods

def :: CSUSeconds #

Default CShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CShort #

Default CSigAtomic 
Instance details

Defined in Data.Default.Class

Methods

def :: CSigAtomic #

Default CSize 
Instance details

Defined in Data.Default.Class

Methods

def :: CSize #

Default CTime 
Instance details

Defined in Data.Default.Class

Methods

def :: CTime #

Default CUInt 
Instance details

Defined in Data.Default.Class

Methods

def :: CUInt #

Default CUIntMax 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntMax #

Default CUIntPtr 
Instance details

Defined in Data.Default.Class

Methods

def :: CUIntPtr #

Default CULLong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULLong #

Default CULong 
Instance details

Defined in Data.Default.Class

Methods

def :: CULong #

Default CUSeconds 
Instance details

Defined in Data.Default.Class

Methods

def :: CUSeconds #

Default CUShort 
Instance details

Defined in Data.Default.Class

Methods

def :: CUShort #

Default Int16 
Instance details

Defined in Data.Default.Class

Methods

def :: Int16 #

Default Int32 
Instance details

Defined in Data.Default.Class

Methods

def :: Int32 #

Default Int64 
Instance details

Defined in Data.Default.Class

Methods

def :: Int64 #

Default Int8 
Instance details

Defined in Data.Default.Class

Methods

def :: Int8 #

Default Word16 
Instance details

Defined in Data.Default.Class

Methods

def :: Word16 #

Default Word32 
Instance details

Defined in Data.Default.Class

Methods

def :: Word32 #

Default Word64 
Instance details

Defined in Data.Default.Class

Methods

def :: Word64 #

Default SpecificOrDefaultAlias Source # 
Instance details

Defined in Test.Cleveland.Internal.Abstract

Default Ordering 
Instance details

Defined in Data.Default.Class

Methods

def :: Ordering #

Default NewtonParam 
Instance details

Defined in Numeric.RootFinding

Methods

def :: NewtonParam #

Default RiddersParam 
Instance details

Defined in Numeric.RootFinding

Methods

def :: RiddersParam #

Default DeriveRPCOptions 
Instance details

Defined in Morley.AsRPC

Methods

def :: DeriveRPCOptions #

Default ErrorSrcPos 
Instance details

Defined in Morley.Michelson.ErrorPos

Methods

def :: ErrorSrcPos #

Default Pos 
Instance details

Defined in Morley.Michelson.ErrorPos

Methods

def :: Pos #

Default SrcPos 
Instance details

Defined in Morley.Michelson.ErrorPos

Methods

def :: SrcPos #

Default MorleyLogsBuilder 
Instance details

Defined in Morley.Michelson.Interpret

Methods

def :: MorleyLogsBuilder #

Default TypeCheckInstrEnv 
Instance details

Defined in Morley.Michelson.TypeCheck.TypeCheck

Methods

def :: TypeCheckInstrEnv #

Default TypeCheckOptions 
Instance details

Defined in Morley.Michelson.TypeCheck.TypeCheck

Methods

def :: TypeCheckOptions #

Default EntriesOrder 
Instance details

Defined in Morley.Michelson.Untyped.Contract

Methods

def :: EntriesOrder #

Default EpName Source # 
Instance details

Defined in Test.Cleveland.Instances

Methods

def :: EpName #

Default FeeConstants 
Instance details

Defined in Morley.Client.RPC.Types

Methods

def :: FeeConstants #

Default ContParam

We use s as default value which is same as R's default.

Instance details

Defined in Statistics.Quantile

Methods

def :: ContParam #

Default Word8 
Instance details

Defined in Data.Default.Class

Methods

def :: Word8 #

Default Integer 
Instance details

Defined in Data.Default.Class

Methods

def :: Integer #

Default () 
Instance details

Defined in Data.Default.Class

Methods

def :: () #

Default Double 
Instance details

Defined in Data.Default.Class

Methods

def :: Double #

Default Float 
Instance details

Defined in Data.Default.Class

Methods

def :: Float #

Default Int 
Instance details

Defined in Data.Default.Class

Methods

def :: Int #

Default Word 
Instance details

Defined in Data.Default.Class

Methods

def :: Word #

(Default a, RealFloat a) => Default (Complex a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Complex a #

Default (First a) 
Instance details

Defined in Data.Default.Class

Methods

def :: First a #

Default (Last a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Last a #

Default a => Default (Dual a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Dual a #

Default (Endo a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Endo a #

Num a => Default (Product a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Product a #

Num a => Default (Sum a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Sum a #

Integral a => Default (Ratio a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Ratio a #

Default a => Default (IO a) 
Instance details

Defined in Data.Default.Class

Methods

def :: IO a #

Default (Range ExpressionInt) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Default (Range Length) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Methods

def :: Range Length #

Default (Range SmallLength) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Default (Range TicketAmount) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Default (Range TinyLength) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Methods

def :: Range TinyLength #

Default (Range ValueInt) Source # 
Instance details

Defined in Hedgehog.Range.Defaults

Methods

def :: Range ValueInt #

Default (Range Pos) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range Pos #

Default (Range (Value' instr 'TInt)) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range (Value' instr 'TInt) #

Default (Range (Value' instr 'TNat)) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range (Value' instr 'TNat) #

Default (Range StackRef) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range StackRef #

Default (Range Mutez) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range Mutez #

Default (Range Timestamp) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range Timestamp #

mname ~ ('Nothing :: Maybe Symbol) => Default (EntrypointRef mname) Source # 
Instance details

Defined in Test.Cleveland.Instances

Methods

def :: EntrypointRef mname #

(SingI t, Default (Anns xs)) => Default (Anns (Notes t ': xs)) 
Instance details

Defined in Morley.Michelson.Typed.Annotation

Methods

def :: Anns (Notes t ': xs) #

(Typeable tag, Default (Anns xs)) => Default (Anns (Annotation tag ': xs)) 
Instance details

Defined in Morley.Michelson.Typed.Annotation

Methods

def :: Anns (Annotation tag ': xs) #

Default (Anns ('[] :: [Type])) 
Instance details

Defined in Morley.Michelson.Typed.Annotation

Methods

def :: Anns '[] #

Default (Maybe a) 
Instance details

Defined in Data.Default.Class

Methods

def :: Maybe a #

Default [a] 
Instance details

Defined in Data.Default.Class

Methods

def :: [a] #

Default (BigMap k v) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Methods

def :: BigMap k v #

Default (ViewsSet' instr st) 
Instance details

Defined in Morley.Michelson.Typed.View

Methods

def :: ViewsSet' instr st #

Default (Annotation tag) 
Instance details

Defined in Morley.Michelson.Untyped.Annotation

Methods

def :: Annotation tag #

Default r => Default (e -> r) 
Instance details

Defined in Data.Default.Class

Methods

def :: e -> r #

(Default a, Default b) => Default (a, b) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b) #

(Default a, Default b, Default c) => Default (a, b, c) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c) #

(Default a, Default b, Default c, Default d) => Default (a, b, c, d) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d) #

(Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e) #

(Default a, Default b, Default c, Default d, Default e, Default f) => Default (a, b, c, d, e, f) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f) #

(Default a, Default b, Default c, Default d, Default e, Default f, Default g) => Default (a, b, c, d, e, f, g) 
Instance details

Defined in Data.Default.Class

Methods

def :: (a, b, c, d, e, f, g) #

unsafeCalling :: EpName -> forall epArg. NiceParameter epArg => epArg -> GenericCall 'Unchecked Source #

Unsafely call an entrypoint specified by the first argument with the provided parameter.

This is "unsafe" in the sense that there is no check that the contract indeed has the specified entrypoint or that the entrypoint in question accepts the argument provided.

Also, no compile-time checks are performed on the entrypoint name, so it can be malformed.

transfer addr $ unsafeCalling (ep @"Entrypoint") ()

Overloaded labels are supported with unsafeCalling, so you can specify the entrypoint as an overloaded label:

transfer addr $ unsafeCalling #entrypoint ()

Use DefEpName or def to call the default entrypoint.

Notice that the type variable for the entrypoint argument is specified after the entrypoint. This is done so more for readability. F. ex.:

transfer addr $ calling def @Integer 123

This does also marginally simplify type inference in the case of partial application.

importUntypedContract :: (HasCallStack, MonadCleveland caps m) => FilePath -> m Contract Source #

Import an untyped contract from file.

importContract :: (HasCallStack, NiceParameter param, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd, MonadCleveland caps m) => FilePath -> m (Contract param st vd) Source #

Import a contract from file.

The compiler must be able to infer the types of parameter, storage and views. In case there are no views or you don't care, you can use noViews.

noViews :: forall {k1} {k2} contract (cp :: k1) (st :: k2). contract cp st () -> contract cp st () #

comment :: (HasCallStack, MonadCleveland caps m) => Text -> m () Source #

Print the given string verbatim as a comment. At the moment, this is a no-op in emulator tests.

getBalance :: (HasCallStack, MonadCleveland caps m, ToL1Address addr) => addr -> m Mutez Source #

Get the balance of the given address.

getDelegate :: (HasCallStack, MonadCleveland caps m, ToL1Address addr) => addr -> m (Maybe KeyHash) Source #

Get the delegate for the given contract/implicit address.

registerDelegate :: (HasCallStack, MonadCleveland caps m) => ImplicitAddress -> m () Source #

Register the given implicit address as a delegate.

setDelegate :: (HasCallStack, MonadCleveland caps m) => ImplicitAddress -> Maybe KeyHash -> m () Source #

Set/unset delegate

getMorleyLogs :: forall a caps m. MonadEmulated caps m => m a -> m (LogsInfo, a) Source #

Returns the result of the action with the logs it produced. Logs are messages printed by the Lorentz instruction printComment.

This function can be combined either with lens-based accessors or helper functions to get more specific information about logs.

Examples:

(logsInfo, _) <- getMorleyLogs scenario
logsInfo ^.. each . logsL == [MorleyLogs ["log"], MorleyLogs ["log2"]]
logsInfo ^.. each . filterLogsByAddrL addr == [MorleyLogs ["log"]]
(logsInfo, _) <- getMorleyLogs scenario
collectLogs logsInfo == MorleyLogs ["log", "log2"]
logsForAddress logsInfo == [MorleyLogs ["log"]]

getMorleyLogs_ :: MonadEmulated caps m => m () -> m LogsInfo Source #

Version of getMorleyLogs for actions that don't return a result.

getStorage :: forall st addr caps m. (HasCallStack, MonadCleveland caps m, ToStorageType st addr, IsoValue (AsRPC st)) => addr -> m (AsRPC st) Source #

Retrieve a contract's storage in its "RPC representation" (i.e., all its big_maps will be replaced by big_map IDs).

If the storage is of a user-defined type, then deriveRPC / deriveManyRPC should be used to create an RPC representation of the storage type.

data MyStorage = MyStorage { field1 :: Natural, field2 :: BigMap Integer MText }
deriveRPC "MyStorage"

getFullStorage :: forall st addr caps m. (HasCallStack, MonadEmulated caps m, ToStorageType st addr) => addr -> m st Source #

Retrieve a contract's full storage, including the contents of its big_maps.

This function can only be used in emulator-only tests.

getSomeStorage :: forall addr caps m. (HasCallStack, MonadCleveland caps m, ToContractAddress addr) => addr -> m SomeAnnotatedValue Source #

Similar to getStorage, but doesn't require knowing the storage type in advance.

Use the optics in AnnotatedValue to read data from the storage.

getAllBigMapValues :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NiceUnpackedValue v) => BigMapId k v -> m [v] Source #

Like getAllBigMapValuesMaybe, but fails the tests instead of returning Nothing.

getAllBigMapValuesMaybe :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NiceUnpackedValue v) => BigMapId k v -> m (Maybe [v]) Source #

Retrieve all big_map values, given a big_map ID. Returns Nothing when the big_map ID does not exist.

getBigMapSize :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NiceUnpackedValue v) => BigMapId k v -> m Natural Source #

Like getBigMapSizeMaybe, but fails the tests instead of returning Nothing.

getBigMapSizeMaybe :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NiceUnpackedValue v) => BigMapId k v -> m (Maybe Natural) Source #

Retrieve a big_map size, given a big_map ID. Returns Nothing when the big_map ID does not exist.

O(n), because it's implemented with getBigMapValues.

getBigMapValueMaybe :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NicePackedValue k, NiceUnpackedValue v) => BigMapId k v -> k -> m (Maybe v) Source #

Retrieve a big_map value, given a big_map ID and a key. Returns Nothing when the big_map ID does not exist, or it exists but does not contain the given key.

getBigMapValue :: forall k v caps m. (HasCallStack, MonadCleveland caps m, NiceComparable k, NicePackedValue k, NiceUnpackedValue v, Buildable k) => BigMapId k v -> k -> m v Source #

Like getBigMapValueMaybe, but fails the tests instead of returning Nothing.

getPublicKey :: (HasCallStack, MonadCleveland caps m) => ImplicitAddress -> m PublicKey Source #

Get the public key associated with given address. Fail if given address is not an implicit account.

getChainId :: (HasCallStack, MonadCleveland caps m) => m ChainId Source #

Get the chain's ChainId.

advanceTime :: forall unit caps m. (HasCallStack, MonadCleveland caps m, KnownDivRat unit Second) => Time unit -> m () Source #

Advance at least the given amount of time, or until a new block is baked, whichever happens last.

On a real network, this is implemented using threadDelay, so it's advisable to use small amounts of time only.

advanceLevel :: forall caps m. (HasCallStack, MonadCleveland caps m) => Natural -> m () Source #

Wait till the provided number of levels is past.

advanceToLevel :: forall caps m. (HasCallStack, MonadCleveland caps m) => Natural -> m () Source #

Wait till the provided level is reached.

getNow :: (HasCallStack, MonadCleveland caps m) => m Timestamp Source #

Get the timestamp observed by the last block to be baked.

getLevel :: (HasCallStack, MonadCleveland caps m) => m Natural Source #

Get the current level observed by the last block to be baked.

getApproximateBlockInterval :: (HasCallStack, MonadCleveland caps m) => m (Time Second) Source #

Get approximate block interval in seconds. Note, that this value is minimal bound and real intervals can be larger, see http://tezos.gitlab.io/active/consensus.html#minimal-block-delay-function for more information about block delays.

getMinBlockTime :: (HasCallStack, MonadCleveland caps m) => m Natural Source #

Get minimal block delay in seconds. This is essentially the same as getApproximateBlockInterval, but returns a Natural instead of Time Second.

Can be useful when testing code using MIN_BLOCK_TIME instruction.

data RunCode cp st vd Source #

The data needed to call the /run_code RPC endpoint.

Constructors

RunCode 

Fields

  • rcContract :: Contract cp st vd
     
  • rcParameter :: Value

    The parameter value should have the same "structure" as cp, except it _may_ also have big_map IDs. E.g. if the contract's parameter is pair (big_map string string) (big_map string string), then rcParameter may be one of:

    • pair (big_map string string) (big_map string string)
    • pair nat (big_map string string)
    • pair (big_map string string) nat
    • pair nat nat

    ... where nat represents a big_map ID.

  • rcStorage :: Value

    The storage value should have the same "structure" as st, except it _may_ also have big_map IDs. See the documentation of rcParameter.

  • rcAmount :: Mutez

    The value that will be returned by the AMOUNT instruction.

  • rcLevel :: Maybe Natural

    The value that will be returned by the LEVEL instruction.

  • rcNow :: Maybe Timestamp

    The value that will be returned by the NOW instruction.

  • rcBalance :: Mutez

    The balance that will be returned by the BALANCE instruction.

  • rcSource :: Maybe ImplicitAddress

    The value that will be returned by the SOURCE instruction.

runCode :: (HasCallStack, MonadCleveland caps m, HasRPCRepr st, IsoValue (AsRPC st)) => RunCode cp st vd -> m (AsRPC st) Source #

Execute a contract's code without originating it. The chain's state will not be modified.

Notes:

  • If the contract's code emits operations, they will not be executed.
  • The sender's account won't be debited.
  • When running an _originated_ contract, the BALANCE instruction returns the sum of the contract's balance before the transfer operation + the amount of tz being transferred. In other words, this invariant holds: BALANCE >= AMOUNT. However, since runCode allows overriding the BALANCE instruction, then this invariant no longer holds. It's possible that BALANCE < AMOUNT.

branchout :: forall caps m. MonadEmulated caps m => [(Text, m ())] -> m () Source #

Execute multiple testing scenarios independently.

  • Actions performed before branchout will be observed by all branches.
  • Actions performed in branches will _not_ be observed by any actions performed after branchout.
  • Actions performed in one branch will _not_ be observed by another branch.
  • The test succeeds IFF all branches succeed.
  • If any branch fails, the test ends immediately and the remaining branches won't be executed.

The following property holds:

pre >> branchout [a, b, c] = branchout [pre >> a, pre >> b, pre >> c]

The list of branches must be non-empty.

offshoot :: forall caps m. MonadEmulated caps m => Text -> m () -> m () Source #

Execute one or more actions and roll them back afterwards. Actions performed in offshoot will _not_ be observed by any actions performed after offshoot.

Similar to branchout, but accepts one single branch.

setVotingPowers :: MonadEmulated caps m => VotingPowers -> m () Source #

Updates voting power accessible via VOTING_POWER and similar instructions.

whenEmulation :: MonadCleveland caps m => (forall caps1 m1. (EqBaseMonad caps caps1, MonadEmulated caps1 m1) => m1 ()) -> m () Source #

Perform an action if we are currently in emulation mode. See also ifEmulation note on constraints.

whenNetwork :: MonadCleveland caps m => (forall caps1 m1. (EqBaseMonad caps caps1, MonadNetwork caps1 m1) => m1 ()) -> m () Source #

Perform an action if we are currently in network mode. See also ifEmulation note on constraints.

ifEmulation :: forall a caps m. MonadCleveland caps m => (forall caps1 m1. (EqBaseMonad caps caps1, MonadEmulated caps1 m1) => m1 a) -> (forall caps1 m1. (EqBaseMonad caps caps1, MonadNetwork caps1 m1) => m1 a) -> m a Source #

Perform one action if we are currently in emulation mode, another otherwise

Functions passed as the first two arguments are universally quantified over the outer monad, so if additional constraints are required beyond MonadEmulated or MonadCleveland, those constraints have to go on the base monad, e.g.

someFunction :: (MonadCleveland caps m, MonadFail (ClevelandBaseMonad caps)) => m ()
someFunction = whenEmulation do
  Just x <- pure (Just 1 :: Maybe Int) -- this would error without MonadFail
  runIO $ print x

inBatch :: (HasCallStack, MonadCleveland caps m) => ClevelandOpsBatch a -> m a Source #

Run operations in a batch. Best used with the ApplicativeDo GHC extension.

Example:


contract <- inBatch $ do
  contract <- originate ...
  for_ [1..3] i ->
    transfer ...
  return contract

Batched operations should be applied to chain faster, but note that batches have their own limits. For instance, at the moment of writing, the gas limit on a batch is 10x of gas limit applied to a single operation.

A context of a batch is only Applicative, not Monad. This means that:

  • Return values of one function cannot be passed to another function in the same batch, it can only be returned;
  • Sometimes the compiler does not recognize that only Applicative context is required, in case of any issues with that - follow the error messages.

Address conversions

class ToAddress a where #

Methods

toAddress :: a -> Address #

Instances

Instances details
ToAddress AddressAndAlias Source # 
Instance details

Defined in Test.Cleveland.Internal.Abstract

Methods

toAddress :: AddressAndAlias -> Address #

ToAddress EpAddress 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: EpAddress -> Address #

ToAddress Address 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: Address -> Address #

ToAddress L1Address 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: L1Address -> Address #

ToAddress (FutureContract cp) 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: FutureContract cp -> Address #

ToAddress (ContractRef cp) 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: ContractRef cp -> Address #

ToAddress (KindedAddress kind) 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: KindedAddress kind -> Address #

ToAddress (TAddress cp vd) 
Instance details

Defined in Lorentz.Address

Methods

toAddress :: TAddress cp vd -> Address #

ToAddress (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toAddress :: ContractHandle cp st vd -> Address #

class ToL1Address addr where Source #

Methods

toL1Address :: addr -> L1Address Source #

Instances

Instances details
ToL1Address L1Address Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: L1Address -> L1Address Source #

L1AddressKind kind => ToL1Address (KindedAddress kind) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: KindedAddress kind -> L1Address Source #

ToL1Address (ContractHandle cp st vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: ContractHandle cp st vd -> L1Address Source #

ToL1Address (L1TAddress cp vd) Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1Address :: L1TAddress cp vd -> L1Address Source #

class (ToTAddress cp vd addr, ToL1Address addr) => ToL1TAddress cp vd addr where Source #

Counterpart of ToTAddress that converts to L1TAddress rather than TAddress.

Methods

toL1TAddress :: addr -> L1TAddress cp vd Source #

Instances

Instances details
(ToTAddress cp vd addr, ToL1Address addr) => ToL1TAddress cp vd addr Source # 
Instance details

Defined in Test.Cleveland.Lorentz.Types

Methods

toL1TAddress :: addr -> L1TAddress cp vd Source #

Primitives re-exports

data EntrypointRef (mname :: Maybe Symbol) where #

Constructors

CallDefault :: EntrypointRef ('Nothing :: Maybe Symbol) 
Call :: forall (name :: Symbol). NiceEntrypointName name => EntrypointRef ('Just name) 

Instances

Instances details
(CheckStuckEp cp mname arg' arg, GetEntrypointArgCustom cp mname ~ arg', ParameterDeclaresEntrypoints cp) => HasEntrypointArg (cp :: Type) (EntrypointRef mname) arg' 
Instance details

Defined in Lorentz.Entrypoints.Core

Methods

useHasEntrypointArg :: EntrypointRef mname -> (Dict (ParameterScope (ToT arg')), EpName)

mname ~ ('Nothing :: Maybe Symbol) => Default (EntrypointRef mname) Source # 
Instance details

Defined in Test.Cleveland.Instances

Methods

def :: EntrypointRef mname #

data Mutez #

Instances

Instances details
FromJSON Mutez 
Instance details

Defined in Morley.Tezos.Core

ToJSON Mutez 
Instance details

Defined in Morley.Tezos.Core

Bounded Mutez 
Instance details

Defined in Morley.Tezos.Core

Enum Mutez 
Instance details

Defined in Morley.Tezos.Core

Generic Mutez 
Instance details

Defined in Morley.Tezos.Core

Associated Types

type Rep Mutez :: Type -> Type #

Methods

from :: Mutez -> Rep Mutez x #

to :: Rep Mutez x -> Mutez #

Num Mutez Source # 
Instance details

Defined in Test.Cleveland.Instances

Integral Mutez Source # 
Instance details

Defined in Test.Cleveland.Instances

Real Mutez Source # 
Instance details

Defined in Test.Cleveland.Instances

Methods

toRational :: Mutez -> Rational #

Show Mutez 
Instance details

Defined in Morley.Tezos.Core

Methods

showsPrec :: Int -> Mutez -> ShowS #

show :: Mutez -> String #

showList :: [Mutez] -> ShowS #

NFData Mutez 
Instance details

Defined in Morley.Tezos.Core

Methods

rnf :: Mutez -> () #

Buildable Mutez 
Instance details

Defined in Morley.Tezos.Core

Methods

build :: Mutez -> Builder #

Eq Mutez 
Instance details

Defined in Morley.Tezos.Core

Methods

(==) :: Mutez -> Mutez -> Bool #

(/=) :: Mutez -> Mutez -> Bool #

Ord Mutez 
Instance details

Defined in Morley.Tezos.Core

Methods

compare :: Mutez -> Mutez -> Ordering #

(<) :: Mutez -> Mutez -> Bool #

(<=) :: Mutez -> Mutez -> Bool #

(>) :: Mutez -> Mutez -> Bool #

(>=) :: Mutez -> Mutez -> Bool #

max :: Mutez -> Mutez -> Mutez #

min :: Mutez -> Mutez -> Mutez #

HasAnnotation Mutez 
Instance details

Defined in Lorentz.Annotation

Methods

getAnnotation :: FollowEntrypointFlag -> Notes (ToT Mutez)

annOptions :: AnnOptions

HasRPCRepr Mutez 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Mutez #

TypeHasDoc Mutez 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

Associated Types

type TypeDocFieldDescriptions Mutez :: FieldDescriptions

Methods

typeDocName :: Proxy Mutez -> Text

typeDocMdDescription :: Markdown

typeDocMdReference :: Proxy Mutez -> WithinParens -> Markdown

typeDocDependencies :: Proxy Mutez -> [SomeDocDefinitionItem]

typeDocHaskellRep :: TypeDocHaskellRep Mutez

typeDocMichelsonRep :: TypeDocMichelsonRep Mutez

IsoValue Mutez 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT Mutez :: T

Methods

toVal :: Mutez -> Value (ToT Mutez)

fromVal :: Value (ToT Mutez) -> Mutez

HasCLReader Mutez 
Instance details

Defined in Morley.Tezos.Core

CmdArg Mutez 
Instance details

Defined in Morley.Client.TezosClient.Types

Methods

toCmdArg :: Mutez -> String

r ~ Mutez => ArithOpHs Add Mutez Mutez r 
Instance details

Defined in Lorentz.Arith

Methods

evalArithOpHs :: forall (s :: [Type]). (Mutez ': (Mutez ': s)) :-> (r ': s)

r ~ Maybe (Natural, Mutez) => ArithOpHs EDiv Mutez Mutez r 
Instance details

Defined in Lorentz.Arith

Methods

evalArithOpHs :: forall (s :: [Type]). (Mutez ': (Mutez ': s)) :-> (r ': s)

r ~ Maybe (Mutez, Mutez) => ArithOpHs EDiv Mutez Natural r 
Instance details

Defined in Lorentz.Arith

Methods

evalArithOpHs :: forall (s :: [Type]). (Mutez ': (Natural ': s)) :-> (r ': s)

r ~ Mutez => ArithOpHs Mul Mutez Natural r 
Instance details

Defined in Lorentz.Arith

Methods

evalArithOpHs :: forall (s :: [Type]). (Mutez ': (Natural ': s)) :-> (r ': s)

r ~ Mutez => ArithOpHs Mul Natural Mutez r 
Instance details

Defined in Lorentz.Arith

Methods

evalArithOpHs :: forall (s :: [Type]). (Natural ': (Mutez ': s)) :-> (r ': s)

(TransferFunc mode emit 'HasAmount r, NoDuplicateAmount am, am ~ 'HasNoAmount) => TransferFunc mode emit am (Mutez -> r) Source # 
Instance details

Defined in Test.Cleveland.Internal.Actions.Transfer

OFConstraints ct 'PropBalance props r => OriginateFunc ct props (Mutez -> r) Source #

Set balance.

Instance details

Defined in Test.Cleveland.Internal.Actions.Originate

Default (Range Mutez) Source # 
Instance details

Defined in Hedgehog.Range.Defaults.Orphans

Methods

def :: Range Mutez #

type Rep Mutez 
Instance details

Defined in Morley.Tezos.Core

type Rep Mutez = D1 ('MetaData "Mutez" "Morley.Tezos.Core" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "UnsafeMutez" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMutez") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word63)))
type AsRPC Mutez 
Instance details

Defined in Morley.AsRPC

type TypeDocFieldDescriptions Mutez 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type TypeDocFieldDescriptions Mutez = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT Mutez 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ToT Mutez = 'TMutez

Assertions

failure :: forall a caps m. (HasCallStack, MonadCleveland caps m) => Builder -> m a Source #

Fails the test with the given error message.

assert :: (HasCallStack, MonadCleveland caps m) => Bool -> Builder -> m () Source #

Fails the test with the given error message if the given condition is false.

(@==) infix 1 Source #

Arguments

:: (HasCallStack, MonadCleveland caps m, Eq a, Buildable a) 
=> a

The actual value.

-> a

The expected value.

-> m () 

x @== expected fails the test if x is not equal to expected.

(@/=) :: (HasCallStack, MonadCleveland caps m, Eq a, Buildable a) => a -> a -> m () infix 1 Source #

Fails the test if the two given values are equal.

(@@==) infix 1 Source #

Arguments

:: (HasCallStack, MonadCleveland caps m, Eq a, Buildable a) 
=> m a

The actual value.

-> a

The expected value.

-> m () 

Monadic version of @==.

getBalance addr @@== 10

(@@/=) :: (HasCallStack, MonadCleveland caps m, Eq a, Buildable a) => m a -> a -> m () infix 1 Source #

Monadic version of @/=.

getBalance addr @@/= 10

checkCompares :: forall a b caps m. (HasCallStack, MonadCleveland caps m, Buildable a, Buildable b) => a -> (a -> b -> Bool) -> b -> m () Source #

Fails the test if the comparison operator fails when applied to the given arguments. Prints an error message with both arguments.

Example:

checkCompares 2 (>) 1

checkComparesWith :: forall a b caps m. (HasCallStack, MonadCleveland caps m) => (a -> Text) -> a -> (a -> b -> Bool) -> (b -> Text) -> b -> m () Source #

Like checkCompares, but with an explicit show function. This function does not have any constraint on the type parameters a and b.

For example, to print with pretty:

checkComparesWith pretty a (<) pretty b

evalJust :: (HasCallStack, MonadCleveland caps m) => Builder -> Maybe a -> m a Source #

Fails the test if the Maybe is Nothing, otherwise returns the value in the Just.

evalRight :: (HasCallStack, MonadCleveland caps m) => (a -> Builder) -> Either a b -> m b Source #

Fails the test if the Either is Left, otherwise returns the value in the Right.

newtype Showing a Source #

Derive a Buildable instance for a type using show.

Constructors

Showing a 

Instances

Instances details
Show a => Show (Showing a) Source # 
Instance details

Defined in Test.Cleveland.Util

Methods

showsPrec :: Int -> Showing a -> ShowS #

show :: Showing a -> String #

showList :: [Showing a] -> ShowS #

Show a => Buildable (Showing a) Source # 
Instance details

Defined in Test.Cleveland.Util

Methods

build :: Showing a -> Builder #

Eq a => Eq (Showing a) Source # 
Instance details

Defined in Test.Cleveland.Util

Methods

(==) :: Showing a -> Showing a -> Bool #

(/=) :: Showing a -> Showing a -> Bool #

Calling views

callView Source #

Arguments

:: forall name arg ret cp st vd m caps. (MonadCleveland caps m, HasView vd name arg ret, NiceParameter arg, NiceViewable ret, NiceStorage ret, NiceParameter cp, KnownSymbol name, HasRPCRepr ret, IsoValue (AsRPC ret)) 
=> ContractHandle cp st vd

Contract to call.

-> Label name

View name. Use OverloadedLabels syntax.

-> arg

Parameter to pass to the view.

-> m (AsRPC ret) 

Call an on-chain view by name. The existence of the view is checked at compile time. If you don't have compile-time information about views, see unsafeCallView.

Example:

callView contract #sum (123, -321)

unsafeCallView Source #

Arguments

:: forall ret arg name addr m caps. (MonadCleveland caps m, NiceParameter arg, NiceViewable ret, NiceStorage ret, KnownSymbol name, HasRPCRepr ret, IsoValue (AsRPC ret), ToContractAddress addr) 
=> addr

Contract to call.

-> Label name

View name. Use OverloadedLabels syntax.

-> arg

Parameter to pass to the view.

-> m (AsRPC ret) 

Version of callView that doesn't check if the view exists in the type. You'll have to specify the return type. You can use TypeApplications syntax for that.

If the view doesn't exist or has incorrect type, a test failure will be thrown.

Note that first type argument is return type, the second is parameter type. The reason for this inversion is you often only need to specify the return type, while the parameter type can be either inferred or explicitly specified with a type annotation on the parameter argument value.

Examples:

unsafeCallView @() contract #id ()

Calls view id with argument unit and return type unit.

unsafeCallView @(Integer, MText) contract #query [mt|hello|]

Calls view query with argument string and return type pair int string.

unsafeCallView @Integer contract #sum (123 :: Natural, -321 :: Integer)

Calls view sum with argument pair nat int and return type int. Type annotations are required due to polymorphic numeric literals.

This last example could also be written as

unsafeCallView @Integer @(Natural, Integer) contract #sum (123, -321)

Exception handling

attempt :: forall e caps m a. (HasCallStack, MonadCleveland caps m, Exception e) => m a -> m (Either e a) Source #

Attempt to run an action and return its result or, if interpretation fails, an error.

catchTransferFailure :: (HasCallStack, MonadCleveland caps m) => m a -> m TransferFailure Source #

Asserts that a transfer should fail, and returns the exception.

checkTransferFailure :: (HasCallStack, MonadCleveland caps m) => TransferFailure -> TransferFailurePredicate -> m () Source #

Check whether a given predicate holds for a given TransferFailure.

expectTransferFailure :: (HasCallStack, MonadCleveland caps m) => TransferFailurePredicate -> m a -> m () Source #

Asserts that a transfer should fail, and runs some TransferFailurePredicates over the exception.

expectTransferFailure (failedWith (constant @MText "NOT_ADMIN")) $
  call contractAddr (Call @"Ep") arg
call contractAddr (Call @"Ep") arg & expectTransferFailure
  ( failedWith (customError #tag 3) &&
    addressIs contractAddr
  )

expectFailedWith :: forall err a caps m. (HasCallStack, MonadCleveland caps m, NiceConstant err) => err -> m a -> m () Source #

Asserts that interpretation of a contract ended with FAILWITH, returning the given constant value.

expectError :: forall err a caps m. (HasCallStack, MonadCleveland caps m, IsError err) => err -> m a -> m () Source #

Asserts that interpretation of a contract ended with FAILWITH, returning the given lorentz error.

expectCustomError :: forall arg a tag caps m. (HasCallStack, MonadCleveland caps m, IsError (CustomError tag), MustHaveErrorArg tag (MText, arg)) => Label tag -> arg -> m a -> m () Source #

Asserts that interpretation of a contract ended with FAILWITH, returning the given custom lorentz error.

expectCustomError_ :: (HasCallStack, MonadCleveland caps m, IsError (CustomError tag), MustHaveErrorArg tag (MText, ())) => Label tag -> m a -> m () Source #

Version of expectCustomError for error with unit argument.

expectCustomErrorNoArg :: (HasCallStack, MonadCleveland caps m, IsError (CustomError tag), MustHaveErrorArg tag MText) => Label tag -> m a -> m () Source #

Version of expectCustomError specialized for expecting NoErrorArgs.

expectNumericError :: forall err a caps m. (HasCallStack, MonadCleveland caps m, IsError err) => ErrorTagMap -> err -> m a -> m () Source #

Asserts that interpretation of a contract ended with FAILWITH, returning the given lorentz numeric error.

clarifyErrors :: forall caps m a. MonadCleveland caps m => Builder -> m a -> m a Source #

Prefix error messages potentially thrown from the given code block.

The prefix will be put at a separate line before the main text, if text is multiline, otherwise it will be separated from the main text with : .

This affects errors produced by functions like failure, assert, @==, etc. Errors related to events in the chain will not be touched.

Example:

for [1..10] \i -> clarifyErrors ("For i=" +| i |+ "") $
  askContract i @@== i * 2

Exception predicates

data TransferFailurePredicate Source #

A predicate that checks whether a transfer operation failed for the expected reason.

Predicates can be combined using the && and || operators.

shiftOverflow :: TransferFailurePredicate Source #

Asserts that interpretation of a contract failed due to an overflow error.

emptyTransaction :: TransferFailurePredicate Source #

Asserts that an action failed due to an attempt to transfer 0tz towards a simple address.

badParameter :: TransferFailurePredicate Source #

Asserts that an action failed due to an attempt to call a contract with an invalid parameter.

gasExhaustion :: TransferFailurePredicate Source #

Asserts that interpretation of a contract failed due to gas exhaustion.

failedWith :: SomeConstant -> TransferFailurePredicate Source #

Asserts that interpretation of a contract ended with FAILWITH, throwing the given error.

This function should be used together with one of the "FAILWITH constructors" (e.g. constant, customError).

addressIs Source #

Arguments

:: ToAddress addr 
=> addr

The expected address.

-> TransferFailurePredicate 

Asserts that the error occurred while interpreting the contract with the given address.

FAILWITH errors

Convert the many error formats available in morley and lorentz to SomeConstant.

constant :: forall err. NiceConstant err => err -> SomeConstant Source #

A constant michelson value that a contract threw with FAILWITH.

lerror :: forall err. IsError err => err -> SomeConstant Source #

A lorentz error.

customError :: forall arg tag. (IsError (CustomError tag), MustHaveErrorArg tag (MText, arg)) => Label tag -> arg -> SomeConstant Source #

A custom lorentz error.

customError_ :: (IsError (CustomError tag), MustHaveErrorArg tag (MText, ())) => Label tag -> SomeConstant Source #

A custom lorentz error with a unit argument.

customErrorNoArg :: (IsError (CustomError tag), MustHaveErrorArg tag MText) => Label tag -> SomeConstant Source #

A custom lorentz error with no argument.

numericError :: forall err. IsError err => ErrorTagMap -> err -> SomeConstant Source #

A lorentz numeric error.

Helpers

auto :: SpecificOrDefaultAlias Source #

Helper to use automatically determined unique alias.

pattern DefEpName :: EpName #

ep :: EntrypointNameConstructor epName a => a Source #

A short partial constructor for EpName or EntrypointRef. It accepts a type-level string as its type argument. The programmer is responsible for validity. And this code is for tests anyway, so each failure is a programmer mistake.

Note that entrypoint names should be capitalized, e.g.

ep @"Entrypoint"

corresponds to entrypoint, etc.

It is intentionally here and not in some deeper module because the name is really short and more suitable for writing scenarios.

For EpName, an instance is provided accepting a value-level Text instead of a type-level symbol. This is mostly for cases where the type-level symbol doesn't work. Note that value-level string will be used verbatim, hence capitalization is arbitrary.

ep "entrypoint"

(?-) :: Text -> a -> (Text, a) infixr 0 Source #

Make a tuple with name without extra syntactic noise.

type (:!) (name :: Symbol) a = NamedF Identity a name #

Infix notation for the type of a named parameter.

newtype NamedF (f :: Type -> Type) a (name :: Symbol) #

Assign a name to a value of type a wrapped in f.

#verbose True :: NamedF Identity Bool "verbose"

Constructors

ArgF (f a)

Match on an F-argument without specifying its name. See also: argF.

Bundled Patterns

pattern Arg :: a -> name :! a

Match on an argument without specifying its name. See also: arg.

pattern (:?) :: Name name -> Maybe a -> NamedF Maybe a name 
pattern (:!) :: Name name -> a -> NamedF Identity a name 

Instances

Instances details
(name ~ name', a ~ a', InjValue f) => IsLabel name (a -> NamedF f a' name') 
Instance details

Defined in Named.Internal

Methods

fromLabel :: a -> NamedF f a' name' #

CanCastTo (f a) (g b) => CanCastTo (NamedF f a n :: Type) (NamedF g b m :: Type) 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (NamedF f a n) -> Proxy (NamedF g b m) -> ()

(HasAnnotation a, KnownSymbol name) => HasAnnotation (NamedF Identity a name) 
Instance details

Defined in Lorentz.Annotation

Methods

getAnnotation :: FollowEntrypointFlag -> Notes (ToT (NamedF Identity a name))

annOptions :: AnnOptions

(HasAnnotation (Maybe a), KnownSymbol name) => HasAnnotation (NamedF Maybe a name) 
Instance details

Defined in Lorentz.Annotation

Methods

getAnnotation :: FollowEntrypointFlag -> Notes (ToT (NamedF Maybe a name))

annOptions :: AnnOptions

Unwrappable (NamedF Identity a name) 
Instance details

Defined in Lorentz.Wrappable

Associated Types

type Unwrappabled (NamedF Identity a name)

Unwrappable (NamedF Maybe a name) 
Instance details

Defined in Lorentz.Wrappable

Associated Types

type Unwrappabled (NamedF Maybe a name)

Wrappable (NamedF Identity a name) 
Instance details

Defined in Lorentz.Wrappable

Wrappable (NamedF Maybe a name) 
Instance details

Defined in Lorentz.Wrappable

HasRPCRepr a => HasRPCRepr (NamedF Identity a name) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (NamedF Identity a name) #

HasRPCRepr a => HasRPCRepr (NamedF Maybe a name) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (NamedF Maybe a name) #

(TypeHasDoc (ApplyNamedFunctor f a), KnownSymbol n, KnownIsoT (ApplyNamedFunctor f Integer), Typeable f, Typeable a) => TypeHasDoc (NamedF f a n) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

Associated Types

type TypeDocFieldDescriptions (NamedF f a n) :: FieldDescriptions

Methods

typeDocName :: Proxy (NamedF f a n) -> Text

typeDocMdDescription :: Markdown

typeDocMdReference :: Proxy (NamedF f a n) -> WithinParens -> Markdown

typeDocDependencies :: Proxy (NamedF f a n) -> [SomeDocDefinitionItem]

typeDocHaskellRep :: TypeDocHaskellRep (NamedF f a n)

typeDocMichelsonRep :: TypeDocMichelsonRep (NamedF f a n)

IsoValue a => IsoValue (NamedF Identity a name) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT (NamedF Identity a name) :: T

Methods

toVal :: NamedF Identity a name -> Value (ToT (NamedF Identity a name))

fromVal :: Value (ToT (NamedF Identity a name)) -> NamedF Identity a name

IsoValue a => IsoValue (NamedF Maybe a name) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT (NamedF Maybe a name) :: T

Methods

toVal :: NamedF Maybe a name -> Value (ToT (NamedF Maybe a name))

fromVal :: Value (ToT (NamedF Maybe a name)) -> NamedF Maybe a name

type Unwrappabled (NamedF Identity a name) 
Instance details

Defined in Lorentz.Wrappable

type Unwrappabled (NamedF Identity a name) = a
type Unwrappabled (NamedF Maybe a name) 
Instance details

Defined in Lorentz.Wrappable

type Unwrappabled (NamedF Maybe a name) = Maybe a
type AsRPC (NamedF Identity a name) 
Instance details

Defined in Morley.AsRPC

type AsRPC (NamedF Identity a name) = NamedF Identity (AsRPC a) name
type AsRPC (NamedF Maybe a name) 
Instance details

Defined in Morley.AsRPC

type AsRPC (NamedF Maybe a name) = NamedF Maybe (AsRPC a) name
type TypeDocFieldDescriptions (NamedF f a n) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type TypeDocFieldDescriptions (NamedF f a n) = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT (NamedF Identity a name) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ToT (NamedF Identity a name) = ToT (Identity a)
type ToT (NamedF Maybe a name) 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ToT (NamedF Maybe a name) = ToT (Maybe a)

Integration with hedgehog

testScenarioProps :: (HasCallStack, MonadIO m, MonadTest m) => Scenario PureM -> m () Source #

Run an Scenario via the Morley.Michelson.Runtime emulator, inside an hedgehog property.

Config (reexports)

data MorleyClientEnv #

Constructors

MorleyClientEnv 

Fields

Instances

Instances details
HasTezosClientEnv MorleyClientEnv 
Instance details

Defined in Morley.Client.Full

MonadReader MorleyClientEnv MorleyClientM 
Instance details

Defined in Morley.Client.Full

Methods

ask :: MorleyClientM MorleyClientEnv #

local :: (MorleyClientEnv -> MorleyClientEnv) -> MorleyClientM a -> MorleyClientM a #

reader :: (MorleyClientEnv -> a) -> MorleyClientM a #

HasLog MorleyClientEnv Message MorleyClientM 
Instance details

Defined in Morley.Client.Full

data MorleyLogs #

Instances

Instances details
Monoid MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

Semigroup MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

Generic MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep MorleyLogs :: Type -> Type #

Show MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

NFData MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: MorleyLogs -> () #

Buildable MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: MorleyLogs -> Builder #

Eq MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogs 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogs = D1 ('MetaData "MorleyLogs" "Morley.Michelson.Interpret" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "MorleyLogs" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMorleyLogs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))

Config utilities

mkMorleyOnlyRpcEnvNetwork Source #

Arguments

:: NetworkEnv 
-> [SecretKey]

Extra secrets that should be known

-> MorleyOnlyRpcEnv 

Construct MorleyOnlyRpcEnv from NetworkEnv.

AsRPC

class TAsRPC (ToT t) ~ ToT (AsRPC t) => HasRPCRepr t #

Associated Types

type AsRPC t #

Instances

Instances details
HasRPCRepr ByteString 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC ByteString #

HasRPCRepr Never 
Instance details

Defined in Lorentz.Value

Associated Types

type AsRPC Never #

HasRPCRepr MText 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC MText #

HasRPCRepr Operation 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Operation #

HasRPCRepr EpAddress 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC EpAddress #

HasRPCRepr Address 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Address #

HasRPCRepr TxRollupL2Address 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC TxRollupL2Address #

HasRPCRepr ChainId 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC ChainId #

HasRPCRepr Mutez 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Mutez #

HasRPCRepr Timestamp 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Timestamp #

HasRPCRepr KeyHash 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC KeyHash #

HasRPCRepr PublicKey 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC PublicKey #

HasRPCRepr Signature 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Signature #

HasRPCRepr Bls12381Fr 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Bls12381Fr #

HasRPCRepr Bls12381G1 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Bls12381G1 #

HasRPCRepr Bls12381G2 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Bls12381G2 #

HasRPCRepr Chest 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Chest #

HasRPCRepr ChestKey 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC ChestKey #

HasRPCRepr Integer 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Integer #

HasRPCRepr Natural 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Natural #

HasRPCRepr () 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC () #

HasRPCRepr Bool 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Bool #

HasRPCRepr a => HasRPCRepr (Identity a) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Identity a) #

HasRPCRepr (Set a) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Set a) #

HasRPCRepr (FutureContract p) 
Instance details

Defined in Lorentz.Address

Associated Types

type AsRPC (FutureContract p) #

HasRPCRepr (ChestT a) 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (ChestT a) #

HasRPCRepr a => HasRPCRepr (OpenChestT a) 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (OpenChestT a) #

HasRPCRepr (Packed a) 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (Packed a) #

HasRPCRepr (TSignature a) 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (TSignature a) #

HasRPCRepr a => HasRPCRepr (ShouldHaveEntrypoints a) 
Instance details

Defined in Lorentz.Entrypoints.Helpers

Associated Types

type AsRPC (ShouldHaveEntrypoints a) #

HasRPCRepr (UParam entries) 
Instance details

Defined in Lorentz.UParam

Associated Types

type AsRPC (UParam entries) #

HasRPCRepr (Value t) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Value t) #

HasRPCRepr (ContractRef arg) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (ContractRef arg) #

HasRPCRepr a => HasRPCRepr (Maybe a) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Maybe a) #

HasRPCRepr a => HasRPCRepr [a] 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC [a] #

(HasRPCRepr l, HasRPCRepr r) => HasRPCRepr (Either l r) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Either l r) #

HasRPCRepr v => HasRPCRepr (Map k v) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Map k v) #

HasRPCRepr (TAddress cp vd) 
Instance details

Defined in Lorentz.Address

Associated Types

type AsRPC (TAddress cp vd) #

HasRPCRepr (Hash alg a) 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (Hash alg a) #

HasRPCRepr cp => HasRPCRepr (ParameterWrapper deriv cp) 
Instance details

Defined in Lorentz.Entrypoints.Manual

Associated Types

type AsRPC (ParameterWrapper deriv cp) #

HasRPCRepr (WrappedLambda i o) 
Instance details

Defined in Lorentz.Lambda

Associated Types

type AsRPC (WrappedLambda i o) #

HasRPCRepr a => HasRPCRepr (View_ a r) 
Instance details

Defined in Lorentz.Macro

Associated Types

type AsRPC (View_ a r) #

HasRPCRepr a => HasRPCRepr (Void_ a r) 
Instance details

Defined in Lorentz.Macro

Associated Types

type AsRPC (Void_ a r) #

HasRPCRepr (BigMap k v) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (BigMap k v) #

(HasRPCRepr a, HasRPCRepr b) => HasRPCRepr (a, b) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b) #

HasRPCRepr a => HasRPCRepr (NamedF Identity a name) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (NamedF Identity a name) #

HasRPCRepr a => HasRPCRepr (NamedF Maybe a name) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (NamedF Maybe a name) #

Each '[HasRPCRepr] '[a, b, c] => HasRPCRepr (a, b, c) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b, c) #

Each '[HasRPCRepr] '[a, b, c, d] => HasRPCRepr (a, b, c, d) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b, c, d) #

Each '[HasRPCRepr] '[a, b, c, d, e] => HasRPCRepr (a, b, c, d, e) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b, c, d, e) #

Each '[HasRPCRepr] '[a, b, c, d, e, f] => HasRPCRepr (a, b, c, d, e, f) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b, c, d, e, f) #

Each '[HasRPCRepr] '[a, b, c, d, e, f, g] => HasRPCRepr (a, b, c, d, e, f, g) 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (a, b, c, d, e, f, g) #

deriveRPCWithStrategy :: String -> GenericStrategy -> Q [Dec] #

deriveManyRPCWithStrategy :: String -> [String] -> GenericStrategy -> Q [Dec] #

Utilities

mapEach :: (Each s t a b, Applicative m) => (a -> m b) -> s -> m t Source #

Version of mapM generalized with each.

Example:

(addr1, addr2, addr3) <- mapEach newAddress ("test1", "test2", "test3")

This is more type-safe than simple mapM since lists do not remember their length in types.

forEach :: (Each s t a b, Applicative m) => s -> (a -> m b) -> m t Source #

Version of mapEach with arguments flipped.