Why does only the default “consuming” choice below cause divulgence?
module Main where
import Daml.Script
template Secret
with
p : Party
where
signatory p
template SecretFetcher
with
p : Party
obs : [Party]
where
signatory p
observer obs
choice PublicFetch : Secret
with s : ContractId Secret
controller p
do fetch s
nonconsuming choice NonPublicFetch : Secret
with s : ContractId Secret
controller p
do fetch s
preconsuming choice PreconsumingFetch : Secret
with s : ContractId Secret
controller p
do fetch s
postconsuming choice PostconsumingFetch : Secret
with s : ContractId Secret
controller p
do fetch s
nonconsuming choice CustomPreconsumingFetch : Secret
with s : ContractId Secret
controller p
do
archive self
fetch s
nonconsuming choice CustomPostconsumingFetch : Secret
with s : ContractId Secret
controller p
do
x <- fetch s
archive self
return x
template Fetcher
with
stakeholder : Party
fetcher : Party
where
signatory stakeholder
observer fetcher
nonconsuming choice FetchSecret : Secret
with
cid : ContractId Secret
controller fetcher
do fetch cid
test : Choice SecretFetcher c Secret => Party -> Text -> Bool -> (ContractId Secret -> c) -> Script ()
test p observerName divulged f = do
o <- allocateParty observerName
s <- submit p do createCmd Secret with p
sf <- submit p do createCmd SecretFetcher with p; obs = [o]
submit p do exerciseCmd sf (f s)
f <- submit p do createCmd Fetcher with stakeholder = p; fetcher = o
if divulged then do
submit o do exerciseCmd f $ FetchSecret s
pure ()
else
submitMustFail o do exerciseCmd f $ FetchSecret s
privacyTest : Script ()
privacyTest = do
p <- allocateParty "p"
test p "publicFetcher" True PublicFetch
test p "nonconsumingPublic" False NonPublicFetch
test p "preconsumingFetcher" False PreconsumingFetch
test p "postconsumingFetcher" False PostconsumingFetch
test p "customPreFetcher" False CustomPreconsumingFetch
test p "customPostFetcher" False CustomPostconsumingFetch