This page gives reference information on scenario syntax, used for testing templates.
Note that for new project, we recommend Daml Script. For an introduction to Daml Script, see 2 Testing templates using Daml Script.
scenariofunction. Introduces a series of transactions to be submitted to the ledger.
- Submits an action (a create or an exercise) to the ledger.
- Takes two arguments, the party submitting followed by the expression, for example:
submit bankOfEngland do create ...
submit, but you’re asserting it should fail.
- Takes two arguments, the party submitting followed by the expression by a party, for example:
submitMustFail bankOfEngland do create ...
In a scenario, you may want time to pass so you can test something properly. You can do this with
Here’s an example of passing time:
timeTravel = scenario do -- Get current ledger effective time t1 <- getTime assert (t1 == datetime 1970 Jan 1 0 0 0) -- Pass 1 day pass (days 1) -- Get new ledger effective time t2 <- getTime assert (t2 == datetime 1970 Jan 2 0 0 0)
As in choices, you can bind to variables. Usually, you’d bind commits to variables in order to get the returned value (usually the contract).