forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LF: Check activeness of cached contracts inside FetchInterface (digit…
…al-asset#12698) Missed in digital-asset#12527. CHANGELOG_BEGIN CHANGELOG_END
- Loading branch information
1 parent
aa2494f
commit ed1bf24
Showing
2 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
compiler/damlc/tests/daml-test-files/InterfaceDoubleSpend.daml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
-- TODO https://github.com/digital-asset/daml/issues/12697 | ||
-- This should be tested as part of evaluation order for FetchInterface | ||
-- Drop this test once it is done | ||
|
||
-- @SINCE-LF-FEATURE DAML_INTERFACE | ||
module InterfaceDoubleSpend where | ||
|
||
-- | An interface comment. | ||
interface Token where | ||
getIssuer : Party | ||
getOwner : Party | ||
getAmount : Int | ||
|
||
transferImpl : Party -> Update (ContractId Token) | ||
|
||
ensure (getAmount this >= 0) | ||
|
||
choice Transfer : ContractId Token | ||
with | ||
newOwner : Party | ||
controller getIssuer this | ||
do | ||
transferImpl this newOwner | ||
|
||
template Asset | ||
with | ||
issuer : Party | ||
owner : Party | ||
amount : Int | ||
where | ||
signatory issuer | ||
observer owner | ||
implements Token where | ||
let getOwner = owner | ||
let getIssuer = issuer | ||
let getAmount = amount | ||
let transferImpl = \newOwner -> do | ||
cid <- create this with owner = newOwner | ||
pure (toInterfaceContractId @Token cid) | ||
|
||
main = scenario do | ||
alice <- getParty "Alice" | ||
bob <- getParty "Bob" | ||
charlie <- getParty "Charlie" | ||
cidAsset1 <- alice `submit` do | ||
create Asset with | ||
issuer = alice | ||
owner = alice | ||
amount = 15 | ||
_ <- alice `submitMustFail` do | ||
_ <- exercise (toInterfaceContractId @Token cidAsset1) (Transfer bob) | ||
_ <- exercise (toInterfaceContractId @Token cidAsset1) (Transfer charlie) | ||
pure () | ||
pure () | ||
|
||
-- @ENABLE-SCENARIOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters