From 1bed05fec20099c3d7fce85c5126446e96da1fee Mon Sep 17 00:00:00 2001 From: nickchapman-da <49153372+nickchapman-da@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:51:03 +0100 Subject: [PATCH] Treat KeyWithMaintainers field structurally in all node types. (#10392) CHANGELOG_BEGIN CHANGELOG_END --- .../daml/lf/transaction/Validation.scala | 4 ++-- .../daml/lf/validation/ValidationSpec.scala | 22 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Validation.scala b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Validation.scala index d26157ec4c41..4446fdaf6bc7 100644 --- a/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Validation.scala +++ b/daml-lf/transaction/src/main/scala/com/digitalasset/daml/lf/transaction/Validation.scala @@ -246,7 +246,7 @@ private final class Validation[Nid, Cid](implicit ECid: Equal[Cid]) { actingParties1 == actingParties2 && signatories1 == signatories2 && stakeholders1 == stakeholders2 && - (key1.isEmpty || keyIsReplayedBy(key1, key2)) && + (keyIsReplayedBy(key1, key2)) && byKeyIsReplacedBy(version1, byKey1, byKey2) => loop(rest1, rest2, stack) case ( @@ -294,7 +294,7 @@ private final class Validation[Nid, Cid](implicit ECid: Equal[Cid]) { stakeholders1 == stakeholders2 && signatories1 == signatories2 && choiceObservers1 == choiceObservers2 && - (key1.isEmpty || keyIsReplayedBy(key1, key2)) && + (keyIsReplayedBy(key1, key2)) && byKeyIsReplacedBy(version1, byKey1, byKey2) => loop( children1.iterator.to(LazyList), diff --git a/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/validation/ValidationSpec.scala b/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/validation/ValidationSpec.scala index d9b78f12d835..099a978bef2a 100644 --- a/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/validation/ValidationSpec.scala +++ b/daml-lf/transaction/src/test/scala/com/digitalasset/daml/lf/validation/ValidationSpec.scala @@ -247,14 +247,9 @@ class ValidationSpec extends AnyFreeSpec with Matchers with TableDrivenPropertyC List(samKWM1, samKWM2, samKWM3).filter(y => x != y) } - private val tweakOptKeyMaintainersSome = Tweak[OKWM] { - case None => List() // don't tweak from None - case Some(x) => None :: List(samKWM1, samKWM2, samKWM3).filter(y => x != y).map(Some(_)) - } - - private val tweakOptKeyMaintainersNone = Tweak[OKWM] { // sig only for Create nodes! + private val tweakOptKeyMaintainers = Tweak[OKWM] { case None => List(Some(samKWM1), Some(samKWM2), Some(samKWM3)) - case Some(_) => List() // don't tweak from Some + case Some(x) => None :: List(samKWM1, samKWM2, samKWM3).filter(y => x != y).map(Some(_)) } private val tweakOptContractId = Tweak[Option[V.ContractId]] { case x => @@ -297,8 +292,7 @@ class ValidationSpec extends AnyFreeSpec with Matchers with TableDrivenPropertyC "tweakCreateAgreementText" -> tweakCreateAgreementText, "tweakCreateSignatories" -> tweakCreateSignatories, "tweakCreateStakeholders" -> tweakCreateStakeholders, - "tweakCreateKey(None)" -> tweakCreateKey(tweakOptKeyMaintainersNone), - "tweakCreateKey(Some)" -> tweakCreateKey(tweakOptKeyMaintainersSome), + "tweakCreateKey" -> tweakCreateKey(tweakOptKeyMaintainers), "tweakCreateVersion" -> tweakCreateVersion, ) @@ -338,15 +332,14 @@ class ValidationSpec extends AnyFreeSpec with Matchers with TableDrivenPropertyC "tweakFetchActingParties" -> tweakFetchActingPartiesNonEmpty, "tweakFetchSignatories" -> tweakFetchSignatories, "tweakFetchStakeholders" -> tweakFetchStakeholders, - "tweakFetchKey(Some)" -> tweakFetchKey(tweakOptKeyMaintainersSome), + "tweakFetchKey" -> tweakFetchKey(tweakOptKeyMaintainers), "tweakFetchByKey(New Version)" -> tweakFetchByKey(versionSinceMinByKey), "tweakFetchVersion" -> tweakFetchVersion, ) private val insigFetchTweaks = Map( - "tweakFetchKey(None)" -> tweakFetchKey(tweakOptKeyMaintainersNone), - "tweakFetchByKey(Old Version)" -> tweakFetchByKey(versionBeforeMinByKey), + "tweakFetchByKey(Old Version)" -> tweakFetchByKey(versionBeforeMinByKey) ) //--[LookupByKey node tweaks]-- @@ -436,15 +429,14 @@ class ValidationSpec extends AnyFreeSpec with Matchers with TableDrivenPropertyC "tweakExerciseSignatories" -> tweakExerciseSignatories, "tweakExerciseChoiceObservers" -> tweakExerciseChoiceObservers, "tweakExerciseExerciseResult" -> tweakExerciseExerciseResult, - "tweakExerciseKey(Some)" -> tweakExerciseKey(tweakOptKeyMaintainersSome), + "tweakExerciseKey" -> tweakExerciseKey(tweakOptKeyMaintainers), "tweakExerciseByKey(New Version)" -> tweakExerciseByKey(versionSinceMinByKey), "tweakExerciseVersion" -> tweakExerciseVersion, ) private val insigExeTweaks = Map( - "tweakExerciseKey(None)" -> tweakExerciseKey(tweakOptKeyMaintainersNone), - "tweakExerciseByKey(Old Version)" -> tweakExerciseByKey(versionBeforeMinByKey), + "tweakExerciseByKey(Old Version)" -> tweakExerciseByKey(versionBeforeMinByKey) ) //--[significant and insignificant tx tweaks]--