Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Abstract cleveland interface not bound to a particular implementation.
The interface may look a bit untyped and unsafe in some places. For example, in order to call a contract one should supply a simple address rather than a contract ref, so it is easy to pass a value of wrong type. Also it is easy to call a non-existing entrypoint.
Subjectively, it makes writing test scenarios easier because you have to prove less to the compiler. It also makes implementation of cleveland engine a bit easier. Of course, it also makes it easier to make certain mistakes. However, we expect users of this interface to also use the functionality of the Test.Cleveland.Internal.Pure module and convert cleveland scenarios to purely testable scenarios for integrational testing engine. In this case errors should be detected almost as quickly as they would reported by the compiler, at least before trying to run scenario on a live network.
Also this interface uses Address
rather than EpAddress
.
I (@gromak) concluded that EpAddress
can not be passed to octez-client
.
For key addresses it just does not make sense and for contract addresses
I get such errors:
bad contract notation Invalid contract notation "KT1VrFpBPwBTm3hsK7DB7SPmY8fTHJ3vY6sJ%mint"
Synopsis
- type LogsInfo = [ScenarioLogs]
- data ScenarioLogs = ScenarioLogs {
- _slAddr :: Address
- _slLog :: MorleyLogs
- data NetworkEnv = NetworkEnv {
- neMorleyClientEnv :: MorleyClientEnv
- neSecretKey :: Maybe SecretKey
- neMoneybagAlias :: ImplicitAlias
- neExplicitDataDir :: Bool
- neVerbosity :: Word
- data EmulatedImpl m = EmulatedImpl {
- eiBranchout :: [(Text, m ())] -> m ()
- eiGetStorage :: forall st addr. (HasCallStack, ToStorageType st addr) => addr -> m st
- eiGetMorleyLogs :: forall a. m a -> m (LogsInfo, a)
- eiSetVotingPowers :: VotingPowers -> m ()
- data RunCode cp st vd = RunCode {
- rcContract :: Contract cp st vd
- rcParameter :: Value
- rcStorage :: Value
- rcAmount :: Mutez
- rcLevel :: Maybe Natural
- rcNow :: Maybe Timestamp
- rcBalance :: Mutez
- rcSource :: Maybe ImplicitAddress
- data SomeTicket where
- SomeTicket :: SingI t => Ticket (Value t) -> SomeTicket
- data ClevelandMiscImpl m = ClevelandMiscImpl {
- cmiRunIO :: forall res. HasCallStack => IO res -> m res
- cmiResolveAddress :: forall kind. HasCallStack => AddressOrAlias kind -> m (AddressWithAlias kind)
- cmiGenKey :: HasCallStack => SpecificOrDefaultAlias -> m ImplicitAddressWithAlias
- cmiImportKey :: HasCallStack => SecretKey -> SpecificOrDefaultAlias -> m ImplicitAddressWithAlias
- cmiGenFreshKey :: HasCallStack => SpecificOrDefaultAlias -> m ImplicitAddressWithAlias
- cmiSignBytes :: HasCallStack => ByteString -> ImplicitAddressWithAlias -> m Signature
- cmiOriginateLargeUntyped :: forall oty. HasCallStack => Sender -> OriginateData oty 'IsLarge -> m ContractAddress
- cmiComment :: HasCallStack => Text -> m ()
- cmiGetBalance :: HasCallStack => L1Address -> m Mutez
- cmiGetSomeStorage :: HasCallStack => ContractAddress -> m SomeAnnotatedValue
- cmiGetBigMapValueMaybe :: forall k v. (HasCallStack, NiceComparable k, NicePackedValue k, NiceUnpackedValue v) => BigMapId k v -> k -> m (Maybe v)
- cmiGetAllBigMapValuesMaybe :: forall k v. (HasCallStack, NiceComparable k, NiceUnpackedValue v) => BigMapId k v -> m (Maybe [v])
- cmiGetPublicKey :: HasCallStack => ImplicitAddressWithAlias -> m PublicKey
- cmiGetDelegate :: HasCallStack => L1Address -> m (Maybe KeyHash)
- cmiGetChainId :: HasCallStack => m ChainId
- cmiAdvanceTime :: forall unit. (HasCallStack, KnownDivRat unit Second) => Time unit -> m ()
- cmiAdvanceToLevel :: HasCallStack => (Natural -> Natural) -> m ()
- cmiGetNow :: HasCallStack => m Timestamp
- cmiGetLevel :: HasCallStack => m Natural
- cmiFailure :: forall a. HasCallStack => Doc -> m a
- cmiThrow :: forall a. HasCallStack => SomeException -> m a
- cmiGetApproximateBlockInterval :: HasCallStack => m (Time Second)
- cmiAttempt :: forall a e. (Exception e, HasCallStack) => m a -> m (Either e a)
- cmiMarkAddressRefillable :: ImplicitAddress -> m ()
- cmiUnderlyingImpl :: m (Either (EmulatedImpl m) NetworkEnv)
- cmiRunCode :: forall cp st vd. (HasCallStack, HasRPCRepr st, IsoValue (AsRPC st)) => Sender -> RunCode cp st vd -> m (AsRPC st)
- cmiTicketBalance :: forall t. (ForbidOp t, Comparable t) => L1Address -> ContractAddress -> Value t -> m Natural
- cmiAllTicketBalances :: ContractAddress -> m [SomeTicket]
- data ClevelandOpsImpl m = ClevelandOpsImpl {
- coiRunOperationBatch :: HasCallStack => [OperationInfo ClevelandInput] -> m [OperationInfo ClevelandResult]
- newtype DefaultAliasCounter = DefaultAliasCounter {}
- data SpecificOrDefaultAlias
- newtype Moneybag = Moneybag {}
- newtype Sender = Sender {}
- data BatchResultMismatch = BatchResultMismatch Text
- data ClevelandResult
- data ContractEvent = ContractEvent {}
- data ClevelandInput
- data SomeOriginateData large where
- SomeOriginateData :: OriginateData oty large -> SomeOriginateData large
- newtype TypedContract cp st vd = TypedContract (Contract (ToT cp) (ToT st))
- data TransferTicketData = forall t addr.(WellTyped t, ToL1Address addr) => TransferTicketData {
- ttdTo :: addr
- ttdEntrypoint :: EpName
- ttdParameter :: Value ('TTicket t)
- data TransferData = forall v addr.(NiceParameter v, ToL1Address addr) => TransferData {
- tdTo :: addr
- tdAmount :: Mutez
- tdEntrypoint :: EpName
- tdParameter :: v
- data ODContractAndStorage oty where
- ODContractAndStorageLorentz :: {..} -> ODContractAndStorage ('OTTypedLorentz param st vd)
- ODContractAndStorageUntyped :: {..} -> ODContractAndStorage 'OTUntyped
- ODContractAndStorageTyped :: (NiceStorage st, NiceViewsDescriptor vd, NiceParameter cp) => {..} -> ODContractAndStorage ('OTTypedMorley cp st vd)
- data OriginateData oty large = OriginateData {
- odName :: ContractAlias
- odBalance :: Mutez
- odDelegate :: Maybe KeyHash
- odContractAndStorage :: ODContractAndStorage oty
- data OriginationType where
- OTTypedLorentz :: Type -> Type -> Type -> OriginationType
- OTTypedMorley :: Type -> Type -> Type -> OriginationType
- OTUntyped :: OriginationType
- data LargeOrigination
- mkDefaultAlias :: Natural -> ImplicitAlias
- auto :: SpecificOrDefaultAlias
- slAddr :: Lens' ScenarioLogs Address
- slLog :: Lens' ScenarioLogs MorleyLogs
- data NetworkCaps m = NetworkCaps {}
- data EmulatedCaps m = EmulatedCaps {}
- data ClevelandCaps m = ClevelandCaps {
- ccSender :: Sender
- ccMoneybag :: Moneybag
- ccMiscCap :: ClevelandMiscImpl m
- ccOpsCap :: Sender -> ClevelandOpsImpl m
- class NiceEntrypointName epName => EntrypointNameConstructor (epName :: Symbol) a where
- ep :: a
- data GenericTestError = UnexpectedSuccess
- data TransferFailureReason
- = FailedWith ExpressionOrTypedValue (Maybe ErrorSrcPos)
- | EmptyTransaction
- | BadParameter
- | MutezArithError MutezArithErrorType
- | ShiftOverflow
- | GasExhaustion
- type ToCallSeqM k = State [(k, [CallSequenceOp])]
- data CallSequenceOp = forall a.(Buildable a, Show a) => CallSequenceOp {
- csoData :: a
- csoSubCalls :: CallSequence
- newtype CallSequence = CallSequence [CallSequenceOp]
- data TransferFailure = TransferFailure {}
- data AddressAndAlias = forall kind. AddressAndAlias (KindedAddress kind) (Maybe (Alias kind))
- data ExpressionOrTypedValue where
- EOTVExpression :: Expression -> ExpressionOrTypedValue
- EOTVTypedValue :: (SingI t, ConstantScope t) => Value t -> ExpressionOrTypedValue
- newtype ClevelandOpsBatch a = ClevelandOpsBatch {
- unClevelandOpsBatch :: BatchingM (OperationInfo ClevelandInput) (OperationInfo ClevelandResult) Void a
- neExplicitDataDirL :: Lens' NetworkEnv Bool
- neMoneybagAliasL :: Lens' NetworkEnv ImplicitAlias
- neMorleyClientEnvL :: Lens' NetworkEnv MorleyClientEnv
- neSecretKeyL :: Lens' NetworkEnv (Maybe SecretKey)
- neVerbosityL :: Lens' NetworkEnv Word
- logsL :: Lens' ScenarioLogs MorleyLogs
- filterLogsByAddrL :: (ToAddress addr, Applicative f) => addr -> (MorleyLogs -> f MorleyLogs) -> ScenarioLogs -> f ScenarioLogs
- logsForAddress :: (Each s s ScenarioLogs ScenarioLogs, ToAddress addr) => addr -> s -> [MorleyLogs]
- collectLogs :: LogsInfo -> MorleyLogs
- runBatched :: (HasCallStack, Functor m) => ClevelandOpsImpl m -> ClevelandOpsBatch a -> m a
- batchedOpsImpl :: ClevelandOpsImpl ClevelandOpsBatch
- runOperationBatchM :: (HasCallStack, Buildable e, Functor m) => Proxy e -> ClevelandOpsImpl m -> BatchingM (OperationInfo ClevelandInput) (OperationInfo ClevelandResult) e a -> m a
- runSingleOperation :: (HasCallStack, Functor m) => ClevelandOpsImpl m -> Text -> OperationInfo ClevelandInput -> (OperationInfo ClevelandResult -> Maybe a) -> m a
- buildLastBranchLinear :: CallSequence -> Doc
- toCallSeq :: Eq k => (a -> ToCallSeqM k (Maybe (k, CallSequenceOp))) -> [a] -> CallSequence
- popToCallSeq :: Eq k => k -> ToCallSeqM k [CallSequenceOp]
- mapClevelandOpsImplExceptions :: (forall a. HasCallStack => m a -> m a) -> ClevelandOpsImpl m -> ClevelandOpsImpl m
- mapClevelandMiscImplExceptions :: (forall a. HasCallStack => m a -> m a) -> ClevelandMiscImpl m -> ClevelandMiscImpl m
- ccMoneybagL :: forall m. Lens' (ClevelandCaps m) Moneybag
- ccSenderL :: forall m. Lens' (ClevelandCaps m) Sender
- ecClevelandCapsL :: forall m. Lens' (EmulatedCaps m) (ClevelandCaps m)
- type NetworkT m = ReaderT (NetworkCaps m) m
- type EmulatedT m = ReaderT (EmulatedCaps m) m
- type ClevelandT m = ReaderT (ClevelandCaps m) m
- type MonadNetwork caps m = (MonadCleveland caps m, HasNetworkCaps caps)
- type MonadEmulated caps m = (MonadCleveland caps m, HasEmulatedCaps caps)
- type MonadCleveland caps m = (m ~ ReaderT caps (ClevelandBaseMonad caps), HasClevelandCaps caps)
- class HasClevelandCaps caps => HasNetworkCaps caps where
- getNetworkEnvCap :: caps -> NetworkEnv
- class HasClevelandCaps caps => HasEmulatedCaps caps where
- getEmulatedCap :: caps -> EmulatedImpl (ClevelandBaseMonad caps)
- class Monad (ClevelandBaseMonad caps) => HasClevelandCaps caps where
- type ClevelandBaseMonad caps :: Type -> Type
- clevelandCapsL :: Lens' caps (ClevelandCaps (ClevelandBaseMonad caps))
- ncClevelandCapsL :: forall m m. Lens (NetworkCaps m) (NetworkCaps m) (ClevelandCaps m) (ClevelandCaps m)
- senderL :: HasClevelandCaps caps => Lens' caps Sender
- moneybagL :: HasClevelandCaps caps => Lens' caps Moneybag
- getMiscCap :: HasClevelandCaps caps => caps -> ClevelandMiscImpl (ClevelandBaseMonad caps)
- getOpsCap :: HasClevelandCaps caps => caps -> ClevelandOpsImpl (ClevelandBaseMonad caps)
Documentation
type LogsInfo = [ScenarioLogs] Source #
data ScenarioLogs Source #
ScenarioLogs | |
|
Instances
Show ScenarioLogs Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> ScenarioLogs -> ShowS # show :: ScenarioLogs -> String # showList :: [ScenarioLogs] -> ShowS # | |
Eq ScenarioLogs Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: ScenarioLogs -> ScenarioLogs -> Bool # (/=) :: ScenarioLogs -> ScenarioLogs -> Bool # | |
MonadWriter LogsInfo PureM Source # | |
data NetworkEnv Source #
NetworkEnv | |
|
data EmulatedImpl m Source #
A record data type with all base methods one can use during cleveland, but which are available only when running on an emulated environment (e.g. Morley.Michelson.Runtime) and not on a real network.
EmulatedImpl | |
|
data RunCode cp st vd Source #
The data needed to call the /run_code
RPC endpoint.
RunCode | |
|
data SomeTicket where Source #
SomeTicket :: SingI t => Ticket (Value t) -> SomeTicket |
Instances
Eq SomeTicket Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: SomeTicket -> SomeTicket -> Bool # (/=) :: SomeTicket -> SomeTicket -> Bool # | |
Buildable SomeTicket Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: SomeTicket -> Doc buildList :: [SomeTicket] -> Doc |
data ClevelandMiscImpl m Source #
A record data type with all base methods one can use during a cleveland test.
ClevelandMiscImpl | |
|
data ClevelandOpsImpl m Source #
A record data type with operations creating primitives.
ClevelandOpsImpl | |
|
newtype DefaultAliasCounter Source #
Counter which is used to provide different default aliases.
Instances
Show DefaultAliasCounter Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> DefaultAliasCounter -> ShowS # show :: DefaultAliasCounter -> String # showList :: [DefaultAliasCounter] -> ShowS # | |
Eq DefaultAliasCounter Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: DefaultAliasCounter -> DefaultAliasCounter -> Bool # (/=) :: DefaultAliasCounter -> DefaultAliasCounter -> Bool # |
data SpecificOrDefaultAlias Source #
An alias with default value that can be used to define unique alias automatically.
Instances
IsString SpecificOrDefaultAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
Show SpecificOrDefaultAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> SpecificOrDefaultAlias -> ShowS # show :: SpecificOrDefaultAlias -> String # showList :: [SpecificOrDefaultAlias] -> ShowS # | |
Default SpecificOrDefaultAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract |
Designates the address that gifts money to new addresses.
Once a new address is allocated in a test scenario, we have to transfer some
money to it so that it is able to serve as transactions sender. Moneybag
serves as a source of that money.
We do not use Sender
for this purpose because in most situations changing
moneybag is not necessary. If a user wraps a large piece of their script with
withSender
call and that changes the moneybag - this behaviour may be
undesired and unexpected to the user.
Designates the special sender address.
Transfers and some other operations will occur on behalf of this address.
This is initialized to moneybag
address and then can be locally modified.
Operations in ClevelandOpsImpl
are affected by this address.
data BatchResultMismatch Source #
A batch returned invalid output, e.g. origination address when transaction was supplied.
BatchResultMismatch Text | Carries expected operation type in lowercase |
Instances
Buildable BatchResultMismatch Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: BatchResultMismatch -> Doc buildList :: [BatchResultMismatch] -> Doc |
data ClevelandResult Source #
Designates an operation result.
Instances
OperationInfoDescriptor ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract type TransferInfo ClevelandResult type TransferTicketInfo ClevelandResult type OriginationInfo ClevelandResult type RevealInfo ClevelandResult type DelegationInfo ClevelandResult | |
type DelegationInfo ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract type DelegationInfo ClevelandResult = DelegationInfo Result | |
type OriginationInfo ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract type OriginationInfo ClevelandResult = OriginationInfo Result | |
type RevealInfo ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract type RevealInfo ClevelandResult = RevealInfo Result | |
type TransferInfo ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
type TransferTicketInfo ClevelandResult Source # | |
Defined in Test.Cleveland.Internal.Abstract |
data ClevelandInput Source #
Designates an operation input.
Instances
OperationInfoDescriptor ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract type TransferInfo ClevelandInput type TransferTicketInfo ClevelandInput type OriginationInfo ClevelandInput type RevealInfo ClevelandInput type DelegationInfo ClevelandInput | |
type DelegationInfo ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
type OriginationInfo ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
type RevealInfo ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract type RevealInfo ClevelandInput = PublicKey | |
type TransferInfo ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
type TransferTicketInfo ClevelandInput Source # | |
Defined in Test.Cleveland.Internal.Abstract |
data SomeOriginateData large where Source #
OriginateData
existential over OriginationType
.
SomeOriginateData :: OriginateData oty large -> SomeOriginateData large |
newtype TypedContract cp st vd Source #
A wrapper around Contract
to reduce awkwardness
TypedContract (Contract (ToT cp) (ToT st)) |
Instances
(NiceStorage st, NiceViewsDescriptor vd, NiceParameter cp) => ContractClass (TypedContract cp st vd) Source # | |
Defined in Test.Cleveland.Internal.Actions.Originate type ContractOriginateType (TypedContract cp st vd) :: OriginationType Source # initialStorageAndContract :: ContractStorage (TypedContract cp st vd) -> TypedContract cp st vd -> ODContractAndStorage (ContractOriginateType (TypedContract cp st vd)) Source # | |
type ContractOriginateType (TypedContract cp st vd) Source # | |
Defined in Test.Cleveland.Internal.Actions.Originate |
data TransferTicketData Source #
Information about transfer operation.
forall t addr.(WellTyped t, ToL1Address addr) => TransferTicketData | |
|
data TransferData Source #
Information about transfer operation.
forall v addr.(NiceParameter v, ToL1Address addr) => TransferData | |
|
data ODContractAndStorage oty where Source #
ODContractAndStorageLorentz | Lorentz contract and storage. |
| |
ODContractAndStorageUntyped | Untyped contract and storage. |
| |
ODContractAndStorageTyped | Typed Morley contract and storage. |
|
data OriginateData oty large Source #
Data common for all origination types.
OriginateData | |
|
data OriginationType where Source #
OTTypedLorentz :: Type -> Type -> Type -> OriginationType | |
OTTypedMorley :: Type -> Type -> Type -> OriginationType | |
OTUntyped :: OriginationType |
data LargeOrigination Source #
Whether this contract should be originated in a single origination operation or, if it goes over the origination size limit, in multiple operations.
auto :: SpecificOrDefaultAlias Source #
Helper to use automatically determined unique alias.
slAddr :: Lens' ScenarioLogs Address Source #
data NetworkCaps m Source #
A record with all the capabilities available to a cleveland test on the network.
Instances
Monad m => HasClevelandCaps (NetworkCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (NetworkCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (NetworkCaps m) (ClevelandCaps (ClevelandBaseMonad (NetworkCaps m))) Source # | |
Monad m => HasNetworkCaps (NetworkCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract getNetworkEnvCap :: NetworkCaps m -> NetworkEnv Source # | |
type ClevelandBaseMonad (NetworkCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract |
data EmulatedCaps m Source #
A record with all the capabilities available to a cleveland test on the emulator.
Instances
Monad m => HasClevelandCaps (EmulatedCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (EmulatedCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (EmulatedCaps m) (ClevelandCaps (ClevelandBaseMonad (EmulatedCaps m))) Source # | |
Monad m => HasEmulatedCaps (EmulatedCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract getEmulatedCap :: EmulatedCaps m -> EmulatedImpl (ClevelandBaseMonad (EmulatedCaps m)) Source # | |
type ClevelandBaseMonad (EmulatedCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract |
data ClevelandCaps m Source #
A record with all the capabilities available to any cleveland test.
ClevelandCaps | |
|
Instances
Monad m => HasClevelandCaps (ClevelandCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (ClevelandCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (ClevelandCaps m) (ClevelandCaps (ClevelandBaseMonad (ClevelandCaps m))) Source # | |
type ClevelandBaseMonad (ClevelandCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract |
class NiceEntrypointName epName => EntrypointNameConstructor (epName :: Symbol) a where 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"
Instances
NiceEntrypointName epName => EntrypointNameConstructor epName EpName Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
(NiceEntrypointName epName, mname ~ 'Just epName) => EntrypointNameConstructor epName (EntrypointRef mname) Source # | |
Defined in Test.Cleveland.Internal.Abstract ep :: EntrypointRef mname Source # | |
(any ~ "", t ~ Text) => EntrypointNameConstructor any (t -> EpName) Source # | |
Defined in Test.Cleveland.Internal.Abstract |
data GenericTestError Source #
Instances
Exception GenericTestError Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
Show GenericTestError Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> GenericTestError -> ShowS # show :: GenericTestError -> String # showList :: [GenericTestError] -> ShowS # | |
Buildable GenericTestError Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: GenericTestError -> Doc buildList :: [GenericTestError] -> Doc |
data TransferFailureReason Source #
FailedWith ExpressionOrTypedValue (Maybe ErrorSrcPos) | Expect that interpretation of contract with the given address ended
with |
EmptyTransaction | Expect failure due to an attempt to transfer 0tz towards a simple address. |
BadParameter | Expect failure due to an attempt to call a contract with an invalid parameter. |
MutezArithError MutezArithErrorType | Expect failure due to an arithmetic over-/underflow |
ShiftOverflow | Expect that interpretation of contract with the given address ended with an overflow error. |
GasExhaustion |
Instances
Show TransferFailureReason Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> TransferFailureReason -> ShowS # show :: TransferFailureReason -> String # showList :: [TransferFailureReason] -> ShowS # | |
Eq TransferFailureReason Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: TransferFailureReason -> TransferFailureReason -> Bool # (/=) :: TransferFailureReason -> TransferFailureReason -> Bool # | |
Buildable TransferFailureReason Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: TransferFailureReason -> Doc buildList :: [TransferFailureReason] -> Doc |
type ToCallSeqM k = State [(k, [CallSequenceOp])] Source #
Helper synonym for toCallSeq
data CallSequenceOp Source #
forall a.(Buildable a, Show a) => CallSequenceOp | |
|
Instances
Show CallSequenceOp Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> CallSequenceOp -> ShowS # show :: CallSequenceOp -> String # showList :: [CallSequenceOp] -> ShowS # | |
Buildable CallSequenceOp Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: CallSequenceOp -> Doc buildList :: [CallSequenceOp] -> Doc |
newtype CallSequence Source #
Instances
data TransferFailure Source #
Failures that could be expected in the execution of a transfer.
These can be caught and handled with attempt
.
Instances
Exception TransferFailure Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
Show TransferFailure Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> TransferFailure -> ShowS # show :: TransferFailure -> String # showList :: [TransferFailure] -> ShowS # | |
Eq TransferFailure Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: TransferFailure -> TransferFailure -> Bool # (/=) :: TransferFailure -> TransferFailure -> Bool # | |
Buildable TransferFailure Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: TransferFailure -> Doc buildList :: [TransferFailure] -> Doc |
data AddressAndAlias Source #
forall kind. AddressAndAlias (KindedAddress kind) (Maybe (Alias kind)) |
Instances
Show AddressAndAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> AddressAndAlias -> ShowS # show :: AddressAndAlias -> String # showList :: [AddressAndAlias] -> ShowS # | |
Eq AddressAndAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract (==) :: AddressAndAlias -> AddressAndAlias -> Bool # (/=) :: AddressAndAlias -> AddressAndAlias -> Bool # | |
ToAddress AddressAndAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract toAddress :: AddressAndAlias -> Address # | |
Buildable AddressAndAlias Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: AddressAndAlias -> Doc buildList :: [AddressAndAlias] -> Doc |
data ExpressionOrTypedValue where Source #
Representation of Expression we got from the RPC or a typed value we got from the emulator.
EOTVExpression :: Expression -> ExpressionOrTypedValue | |
EOTVTypedValue :: (SingI t, ConstantScope t) => Value t -> ExpressionOrTypedValue |
Instances
Show ExpressionOrTypedValue Source # | |
Defined in Test.Cleveland.Internal.Abstract showsPrec :: Int -> ExpressionOrTypedValue -> ShowS # show :: ExpressionOrTypedValue -> String # showList :: [ExpressionOrTypedValue] -> ShowS # | |
Eq ExpressionOrTypedValue Source # | |
Defined in Test.Cleveland.Internal.Abstract | |
Buildable ExpressionOrTypedValue Source # | |
Defined in Test.Cleveland.Internal.Abstract build :: ExpressionOrTypedValue -> Doc buildList :: [ExpressionOrTypedValue] -> Doc |
newtype ClevelandOpsBatch a Source #
Where the batched operations occur.
Note that this is not a Monad
, rather an Applicative
- use
-XApplicativeDo
extension for nicer experience.
ClevelandOpsBatch | |
|
Instances
neSecretKeyL :: Lens' NetworkEnv (Maybe SecretKey) Source #
logsL :: Lens' ScenarioLogs MorleyLogs Source #
An alias for slLog
with a clearer name
filterLogsByAddrL :: (ToAddress addr, Applicative f) => addr -> (MorleyLogs -> f MorleyLogs) -> ScenarioLogs -> f ScenarioLogs Source #
Lens combinator specified for filtering logs by address from LogsInfo
logsForAddress :: (Each s s ScenarioLogs ScenarioLogs, ToAddress addr) => addr -> s -> [MorleyLogs] Source #
Get logs for a given address from LogsInfo
collectLogs :: LogsInfo -> MorleyLogs Source #
Collect logs produced by all contracts into the single list
runBatched :: (HasCallStack, Functor m) => ClevelandOpsImpl m -> ClevelandOpsBatch a -> m a Source #
Run a series of operations within a batch.
Example:
contract <- runBatched impl $ do
-- this block is executed within ClevelandOpsBatch
contract <- runSingleOperation batchedOpsImpl "origination" ...
for_ [1..3] i ->
runSingleOperation batchedOpsImpl "transfer" ...
return contract
See ClevelandOpsBatch
for some precautions.
batchedOpsImpl :: ClevelandOpsImpl ClevelandOpsBatch Source #
ClevelandOpsImpl
suitable for methods executed within a batch.
runOperationBatchM :: (HasCallStack, Buildable e, Functor m) => Proxy e -> ClevelandOpsImpl m -> BatchingM (OperationInfo ClevelandInput) (OperationInfo ClevelandResult) e a -> m a Source #
Version of coiRunOperationBatch
that uses BatchingM
.
This is an internal function.
Invariant: all errors described by e
must be internal and should not occur
in practice (we require e
type to be specified explicitly to hinder
incorrect usage).
runSingleOperation :: (HasCallStack, Functor m) => ClevelandOpsImpl m -> Text -> OperationInfo ClevelandInput -> (OperationInfo ClevelandResult -> Maybe a) -> m a Source #
Helper that runs a single operation using ClevelandOpsImpl
.
buildLastBranchLinear :: CallSequence -> Doc Source #
Build only the last branch of CallSequence
as a linear array.
toCallSeq :: Eq k => (a -> ToCallSeqM k (Maybe (k, CallSequenceOp))) -> [a] -> CallSequence Source #
Given a linear list of operations, reconstruct the "call sequence tree".
The function is polymorphic to support both emulated and network operations.
Uses a rather straightforward stack-based algorithm for reconstruction in $O(n)$. However, bear in mind perfect reconstruction is not always possible, so this is merely best-effort.
In the following example Int
substitutes for Address
for simplicity.
>>>
import Morley.Util.Interpolate (i)
>>>
:{
aux :: (Int, Int) -> ToCallSeqM Int (Maybe (Int, CallSequenceOp)) aux (caller, callee) = Just . (caller,) . CallSequenceOp [i|#{caller} calling #{callee}|] . CallSequence <$> popToCallSeq callee :}
>>>
:{
Fmt.pretty $ toCallSeq aux [(1, 2), (2, 3), (2, 3), (2, 4), (4, 2), (2, 5), (5, 1), (5, 3), (2, 3), (7, 1)] :} - 1 calling 2 - 2 calling 3 - 2 calling 3 - 2 calling 4 - 4 calling 2 - 2 calling 5 - 5 calling 1 - 5 calling 3 - 2 calling 3 - 7 calling 1
Note that in this call sequence, it is ambiguous whether the last 2 calling 3
happens from 1
or 4
. The algorithm used here will always assume deepest
nesting in such cases.
popToCallSeq :: Eq k => k -> ToCallSeqM k [CallSequenceOp] Source #
Helper function for toCallSeq
. Pops the top of the stack if key matches
the supplied argument.
mapClevelandOpsImplExceptions :: (forall a. HasCallStack => m a -> m a) -> ClevelandOpsImpl m -> ClevelandOpsImpl m Source #
Runs a handler over every action.
mapClevelandMiscImplExceptions :: (forall a. HasCallStack => m a -> m a) -> ClevelandMiscImpl m -> ClevelandMiscImpl m Source #
Runs a handler over every action (except cmiAttempt
and cmiThrow
),
possibly transforming exceptions thrown by those actions.
ccMoneybagL :: forall m. Lens' (ClevelandCaps m) Moneybag Source #
ecClevelandCapsL :: forall m. Lens' (EmulatedCaps m) (ClevelandCaps m) Source #
type NetworkT m = ReaderT (NetworkCaps m) m Source #
Monad transformer that adds both ClevelandCaps
and NetworkCaps
capabilities.
type EmulatedT m = ReaderT (EmulatedCaps m) m Source #
Monad transformer that adds both ClevelandCaps
and EmulatedCaps
capabilities.
type ClevelandT m = ReaderT (ClevelandCaps m) m Source #
Monad transformer that adds only the ClevelandCaps
capabilities.
type MonadNetwork caps m = (MonadCleveland caps m, HasNetworkCaps caps) Source #
Constraint for a monad in which we can do cleveland actions that can only
be run on a real network. It requires the NetworkCaps
capability.
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 MonadCleveland caps m = (m ~ ReaderT caps (ClevelandBaseMonad caps), HasClevelandCaps caps) Source #
Constraint for a monad in which we can do cleveland actions.
class HasClevelandCaps caps => HasNetworkCaps caps where Source #
A proof that the given caps
record contains
the basic cleveland capabilities + the network capabilities.
getNetworkEnvCap :: caps -> NetworkEnv Source #
Instances
Monad m => HasNetworkCaps (NetworkCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract getNetworkEnvCap :: NetworkCaps m -> NetworkEnv Source # |
class HasClevelandCaps caps => HasEmulatedCaps caps where Source #
A proof that the given caps
record contains
the basic cleveland capabilities + the emulator capabilities.
getEmulatedCap :: caps -> EmulatedImpl (ClevelandBaseMonad caps) Source #
Instances
Monad m => HasEmulatedCaps (EmulatedCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract getEmulatedCap :: EmulatedCaps m -> EmulatedImpl (ClevelandBaseMonad (EmulatedCaps m)) Source # |
class Monad (ClevelandBaseMonad caps) => HasClevelandCaps caps where Source #
A proof that the given caps
record contains
the basic cleveland capabilities.
type ClevelandBaseMonad caps :: Type -> Type Source #
This will be either PureM
or ClientM
.
clevelandCapsL :: Lens' caps (ClevelandCaps (ClevelandBaseMonad caps)) Source #
Instances
Monad m => HasClevelandCaps (ClevelandCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (ClevelandCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (ClevelandCaps m) (ClevelandCaps (ClevelandBaseMonad (ClevelandCaps m))) Source # | |
Monad m => HasClevelandCaps (EmulatedCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (EmulatedCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (EmulatedCaps m) (ClevelandCaps (ClevelandBaseMonad (EmulatedCaps m))) Source # | |
Monad m => HasClevelandCaps (NetworkCaps m) Source # | |
Defined in Test.Cleveland.Internal.Abstract type ClevelandBaseMonad (NetworkCaps m) :: Type -> Type Source # clevelandCapsL :: Lens' (NetworkCaps m) (ClevelandCaps (ClevelandBaseMonad (NetworkCaps m))) Source # |
ncClevelandCapsL :: forall m m. Lens (NetworkCaps m) (NetworkCaps m) (ClevelandCaps m) (ClevelandCaps m) Source #
getMiscCap :: HasClevelandCaps caps => caps -> ClevelandMiscImpl (ClevelandBaseMonad caps) Source #
getOpsCap :: HasClevelandCaps caps => caps -> ClevelandOpsImpl (ClevelandBaseMonad caps) Source #