在方案中如何断定合同处于非活动状态(已存档)?

时间:2019-06-26 19:35:41

标签: daml

如果我想验证合同是否有效,我可以在场景中简单提取它:

template Something
  with
    party : Party
  where
    signatory party

    nonconsuming choice DoStuff : ()
      controller party
        do
          return ()


myTest = scenario do
  someone <- getParty "Someone"
  submit someone do
    cid <- create Something with party = someone 
    exercise cid DoStuff
    fetch cid  -- would fail if the DoStuff choice was consuming

我该如何主张相反?

template Something
  with
    party : Party
  where
    signatory party

    choice DoStuff : ()
      controller party
        do
          return ()


myTest = scenario do
  someone <- getParty "Someone"
  submit someone do
    cid <- create Something with party = someone 
    exercise cid DoStuff
    fetch cid  -- fails the scenario, as it should, but that's what I want to check for

1 个答案:

答案 0 :(得分:2)

此代码显示您可以将cid链接到适当的范围,以允许submitMustFail以预期的方式进行操作:

myTest = scenario do
  someone <- getParty "Someone"
  cid <- submit someone do
    create Something with party = someone
  submit someone do
    exercise cid DoStuff
  submitMustFail someone do
    fetch cid  -- would fail if the DoStuff choice was consuming