mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
* decode key expressions in scala correctly. fixes #177 replaced a `foldRight` with a `foldLeft`, projections were decoded backwards. * remove ContractKeysSimple -- superseded by ContractKeys
This commit is contained in:
parent
8b9f2e5860
commit
eb318756ff
@ -1,9 +1,7 @@
|
||||
-- Check that the compiler bits of contract keys work.
|
||||
-- @TODO (#177): Fix the engine such that this test passes. Remove `ContractKeysSimple.daml` when it does.
|
||||
-- @IGNORE-LF 1.0
|
||||
-- @IGNORE-LF 1.1
|
||||
-- @IGNORE-LF 1.2
|
||||
-- @ERROR CRASH: RecProj on non-record
|
||||
daml 1.2
|
||||
module ContractKeys where
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
-- Check that the compiler bits of contract keys work.
|
||||
-- @TODO (#177): Remove this test when #177 has been fixed.
|
||||
-- @IGNORE-LF 1.0
|
||||
-- @IGNORE-LF 1.1
|
||||
-- @IGNORE-LF 1.2
|
||||
daml 1.2
|
||||
module ContractKeysSimple where
|
||||
|
||||
template AccountInvitation with
|
||||
account : Account
|
||||
where
|
||||
signatory account.bank
|
||||
|
||||
controller account.accountHolder can
|
||||
Accept : ContractId Account
|
||||
do create account
|
||||
|
||||
template Account with
|
||||
bank : Party
|
||||
accountHolder : Party
|
||||
accountCode : Text
|
||||
accountNumber : Int
|
||||
where
|
||||
signatory [bank, accountHolder]
|
||||
|
||||
instance Key Account (Party, Text, Int) where
|
||||
key acc = (acc.bank, acc.accountCode, acc.accountNumber)
|
||||
keyMaintainers Proxy (bank, _, _) = [bank]
|
||||
|
||||
test = scenario do
|
||||
bank <- getParty "Bank"
|
||||
alice <- getParty "Alice"
|
||||
let account = Account with
|
||||
bank
|
||||
accountHolder = alice
|
||||
accountCode = "CH"
|
||||
accountNumber = 123
|
||||
let accountKey = (bank, "CH", 123)
|
||||
invitationCid <- submit bank do
|
||||
create AccountInvitation with account
|
||||
accountCid <- submit alice do
|
||||
exercise invitationCid Accept
|
||||
|
||||
accountCid' <- submit bank do
|
||||
lookupByKey accountKey
|
||||
assert $ accountCid' == Some accountCid
|
||||
|
||||
(accountCid', account') <- submit bank do
|
||||
fetchByKey accountKey
|
||||
assert $ accountCid' == accountCid
|
||||
assert $ account' == account
|
@ -164,8 +164,8 @@ private[lf] class DecodeV1(minor: LanguageMinorVersion) extends Decode.OfPackage
|
||||
|
||||
case PLF.KeyExpr.SumCase.PROJECTIONS =>
|
||||
val lfProjs = expr.getProjections.getProjectionsList.asScala
|
||||
(lfProjs :\ (EVar(tplVar): Expr)) {
|
||||
case (lfProj, acc) =>
|
||||
lfProjs.foldLeft(EVar(tplVar): Expr) {
|
||||
case (acc, lfProj) =>
|
||||
ERecProj(decodeTypeConApp(lfProj.getTycon), lfProj.getField, acc)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user