2

If I wanted to validate that a contract is active, I could simply fetch it in a Scenario:

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

How do I assert the opposite?

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
dtanabe
  • 1,611
  • 9
  • 18

1 Answers1

2

This code shows that you can chain the cid into an appropriate scope to allow a submitMustFail to operate in the way intended:

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
Fil
  • 1,766
  • 1
  • 15
  • 15