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

Test.Cleveland.Michelson.Import

Description

Functions to import contracts to be used in tests.

Synopsis

Read, parse, typecheck

readContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => MichelsonSource -> Text -> Either ContractReadError (Contract cp st) #

readUntypedContract :: MichelsonSource -> Text -> Either ContractReadError Contract #

readSomeContract :: MichelsonSource -> Text -> Either ContractReadError SomeContract #

importContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => FilePath -> IO (Contract cp st) #

importSomeContract :: FilePath -> IO SomeContract #

embedContract :: forall cp st. (SingI cp, SingI st) => FilePath -> Code Q (Contract cp st) Source #

Import a contract at compile time assuming its expected type is known.

Use it like:

myContract :: Contract (ToT Parameter) (ToT Storage)
myContract = $$(embedContract "my_contract.tz")

or

let myContract = $$(embedContract @(ToT Parameter) @(ToT Storage) "my_contract.tz")

embedContractM :: forall cp st. (SingI cp, SingI st) => IO FilePath -> Code Q (Contract cp st) Source #

Version of embedContract that accepts a filepath constructor in IO.

Useful when the path should depend on environmental variables or other user input.

Read, parse, typecheck value

readValue :: forall (t :: T). SingI t => MichelsonSource -> Text -> Either ValueReadError (Value t) #

importValue :: forall (t :: T). SingI t => FilePath -> IO (Value t) #

importSomeValue :: Ty -> FilePath -> IO SomeValue #

Tasty helpers

testTreesWithContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree] Source #

Import contract and use to create test trees. Both versions of contract are passed to the callback function (untyped and typed).

If contract's import fails, a tree with single failing test will be generated (so test tree will likely be generated unexceptionally, but a failing result will notify about problem).

testTreesWithTypedContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree] Source #

Like testTreesWithContract but supplies only typed contract.

testTreesWithUntypedContract :: HasCallStack => FilePath -> (Contract -> IO [TestTree]) -> IO [TestTree] Source #

Like testTreesWithContract but supplies only untyped contract.

Helpers

embedTextFile :: FilePath -> Q Text Source #

Read a file with textual content at compile time.

Unlike embedFile from the library, returns typed content.