mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
d2e2c21684
New year, new copyright, new expected unknown issues with various files that won't be covered by the script and/or will be but shouldn't change. I'll do the details on Jan 1, but would appreciate this being preapproved so I can actually get it merged by then. CHANGELOG_BEGIN CHANGELOG_END
39 lines
1.1 KiB
Haskell
39 lines
1.1 KiB
Haskell
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
-- SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
module ReadAs where
|
|
|
|
import DA.Action
|
|
import Daml.Trigger
|
|
|
|
-- There are 3 things we need to test:
|
|
--
|
|
-- 1. The initial ACS query sets the right readAs claims.
|
|
-- 2. We submit commands with the right readAs claims.
|
|
-- 3. We subscribe to transactions for the readAs parties.
|
|
|
|
test : Trigger Int
|
|
test = Trigger
|
|
{ initialize = do
|
|
public <- getReadAs >>= \case
|
|
[public] -> pure public
|
|
readAs -> error $ "Expected exactly one readAs party but got " <> show readAs
|
|
visible <- query @VisibleToPublic
|
|
case visible of
|
|
[(_, visible)] -> unless (visible == VisibleToPublic public) $
|
|
error ("Expected " <> show (VisibleToPublic public) <> " but got " <> show visible)
|
|
_ -> error $ "Expected exactly one contract but got " <> show visible
|
|
pure 1
|
|
, updateState = \_ -> pure ()
|
|
, rule = \_ -> pure ()
|
|
, registeredTemplates = AllInDar
|
|
, heartbeat = None
|
|
}
|
|
|
|
template VisibleToPublic
|
|
with
|
|
public : Party
|
|
where
|
|
signatory public
|