Expand upgrade validation testing (#19123)

* Remove duplication from tests

* lint

* lint

* Simplify tests

* lint

* add more tests for dependency behaviour

* track new test files

* lint

* add test for failure being only emitted in the module that originates it

* fix stdout capture for rules_daml

* lint

* lint

* Move CannotUpgradeView into own section

* Fix more upgrades gen
This commit is contained in:
dylant-da 2024-05-23 09:36:05 +01:00 committed by GitHub
parent b06a9e836e
commit 935c3fb10e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
65 changed files with 864 additions and 1175 deletions

View File

@ -446,10 +446,67 @@ da_haskell_test(
da_haskell_test(
name = "upgrades",
srcs = ["src/DA/Test/DamlcUpgrades.hs"],
compiler_flags = ["-Wno-unused-local-binds"],
data = [
"//compiler/damlc",
"//daml-script/daml:daml-script.dar",
"//daml-script/runner:daml-script-binary",
"//test-common:upgrades-CannotUpgradeView-files",
"//test-common:upgrades-FailWhenATopLevelEnumChangesChangesTheOrderOfItsVariants-files",
"//test-common:upgrades-FailWhenATopLevelVariantChangesChangesTheOrderOfItsVariants-files",
"//test-common:upgrades-FailsOnlyInModuleNotInReexports-files",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsANonOptionalField-files",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsAnOptionalFieldBeforeTheEnd-files",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAFieldToAVariantsType-files",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAVariant-files",
"//test-common:upgrades-FailsWhenATopLevelVariantRemovesAVariant-files",
"//test-common:upgrades-FailsWhenAnInstanceIsDropped-files",
"//test-common:upgrades-FailsWhenAnInterfaceIsDefinedInAnUpgradingPackageWhenItWasAlreadyInThePriorPackage-files",
"//test-common:upgrades-FailsWhenExistingFieldInTemplateChoiceIsChanged-files",
"//test-common:upgrades-FailsWhenExistingFieldInTemplateIsChanged-files",
"//test-common:upgrades-FailsWhenNewFieldIsAddedToTemplateChoiceWithoutOptionalType-files",
"//test-common:upgrades-FailsWhenNewFieldIsAddedToTemplateWithoutOptionalType-files",
"//test-common:upgrades-FailsWhenOldFieldIsDeletedFromTemplate-files",
"//test-common:upgrades-FailsWhenOldFieldIsDeletedFromTemplateChoice-files",
"//test-common:upgrades-FailsWhenTemplateAddsKeyType-files",
"//test-common:upgrades-FailsWhenTemplateChangesKeyType-files",
"//test-common:upgrades-FailsWhenTemplateChoiceChangesItsReturnType-files",
"//test-common:upgrades-FailsWhenTemplateRemovesKeyType-files",
"//test-common:upgrades-FailsWhenTwoDeeplyNestedTypeSynonymsResolveToDifferentDatatypes-files",
"//test-common:upgrades-FailsWithSynonymReturnTypeChange-files",
"//test-common:upgrades-FailsWithSynonymReturnTypeChangeInSeparatePackage-files",
"//test-common:upgrades-MissingChoice-files",
"//test-common:upgrades-MissingDataCon-files",
"//test-common:upgrades-MissingModule-files",
"//test-common:upgrades-MissingTemplate-files",
"//test-common:upgrades-RecordFieldsNewNonOptional-files",
"//test-common:upgrades-SucceedWhenATopLevelEnumAddsAField-files",
"//test-common:upgrades-SucceedsWhenATopLevelEnumChanges-files",
"//test-common:upgrades-SucceedsWhenATopLevelRecordAddsAnOptionalFieldAtTheEnd-files",
"//test-common:upgrades-SucceedsWhenATopLevelTypeSynonymChanges-files",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAVariant-files",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-files",
"//test-common:upgrades-SucceedsWhenAnInstanceIsAddedSeparateDep-files",
"//test-common:upgrades-SucceedsWhenAnInstanceIsAddedUpgradedPackage-files",
"//test-common:upgrades-SucceedsWhenAnInterfaceIsOnlyDefinedInTheInitialPackage-files",
"//test-common:upgrades-SucceedsWhenNewFieldWithOptionalTypeIsAddedToTemplate-files",
"//test-common:upgrades-SucceedsWhenNewFieldWithOptionalTypeIsAddedToTemplateChoice-files",
"//test-common:upgrades-SucceedsWhenTemplateChoiceInputArgumentHasChanged-files",
"//test-common:upgrades-SucceedsWhenTemplateChoiceReturnsATemplateWhichHasChanged-files",
"//test-common:upgrades-SucceedsWhenTwoDeeplyNestedTypeSynonymsResolveToTheSameDatatypes-files",
"//test-common:upgrades-SucceedsWhenUpgradingADependency-files",
"//test-common:upgrades-TemplateChangedKeyType-files",
"//test-common:upgrades-ValidUpgrade-files",
"//test-common:upgrades-WarnsWhenAnInterfaceAndATemplateAreDefinedInTheSamePackage-files",
"//test-common:upgrades-WarnsWhenAnInterfaceIsDefinedAndThenUsedInAPackageThatUpgradesIt-files",
"//test-common:upgrades-WarnsWhenAnInterfaceIsUsedInThePackageThatItsDefinedIn-files",
"//test-common:upgrades-WarnsWhenControllersOfTemplateChoiceAreChanged-files",
"//test-common:upgrades-WarnsWhenObserversOfTemplateChoiceAreChanged-files",
"//test-common:upgrades-WarnsWhenTemplateChangesEnsure-files",
"//test-common:upgrades-WarnsWhenTemplateChangesKeyExpression-files",
"//test-common:upgrades-WarnsWhenTemplateChangesKeyMaintainers-files",
"//test-common:upgrades-WarnsWhenTemplateChangesObservers-files",
"//test-common:upgrades-WarnsWhenTemplateChangesSignatories-files",
],
hackage_deps = [
"base",

File diff suppressed because it is too large Load Diff

View File

@ -189,16 +189,16 @@ da_scala_test_suite(
"//test-common:upgrades-FailsWhenUpgradingV3ThenV2-v3.dar",
# More tests ported from DamlcUpgrades.hs
"//test-common:upgrades-FailsWhenATopLevelEnumChanges-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelEnumChanges-v2.dar",
"//test-common:upgrades-SucceedsWhenATopLevelEnumChanges-v1.dar",
"//test-common:upgrades-SucceedsWhenATopLevelEnumChanges-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsANonOptionalField-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsANonOptionalField-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsAnOptionalFieldBeforeTheEnd-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelRecordAddsAnOptionalFieldBeforeTheEnd-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAFieldToAVariantsType-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAFieldToAVariantsType-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v2.dar",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v1.dar",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAVariant-v1.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantAddsAVariant-v2.dar",
"//test-common:upgrades-FailsWhenATopLevelVariantRemovesAVariant-v1.dar",
@ -231,6 +231,8 @@ da_scala_test_suite(
"//test-common:upgrades-SucceedsWhenAnInstanceIsAddedSeparateDep-v2.dar",
"//test-common:upgrades-SucceedsWhenAnInstanceIsAddedUpgradedPackage-v1.dar",
"//test-common:upgrades-SucceedsWhenAnInstanceIsAddedUpgradedPackage-v2.dar",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAVariant-v1.dar",
"//test-common:upgrades-SucceedsWhenATopLevelVariantAddsAVariant-v2.dar",
],
flaky = True,
scala_deps = [

View File

@ -411,8 +411,8 @@ trait LongTests { this: UpgradesSpec =>
"Succeeds when a top-level variant adds a variant" in {
testPackagePair(
"test-common/upgrades-FailsWhenATopLevelVariantAddsAVariant-v1.dar",
"test-common/upgrades-FailsWhenATopLevelVariantAddsAVariant-v2.dar",
"test-common/upgrades-SucceedsWhenATopLevelVariantAddsAVariant-v1.dar",
"test-common/upgrades-SucceedsWhenATopLevelVariantAddsAVariant-v2.dar",
assertPackageUpgradeCheck(None),
)
}
@ -453,16 +453,16 @@ trait LongTests { this: UpgradesSpec =>
"Succeeds when a top-level variant adds an optional field to a variant's type" in {
testPackagePair(
"test-common/upgrades-FailsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v1.dar",
"test-common/upgrades-FailsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v2.dar",
"test-common/upgrades-SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v1.dar",
"test-common/upgrades-SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType-v2.dar",
assertPackageUpgradeCheck(None),
)
}
"Succeeds when a top-level enum changes" in {
testPackagePair(
"test-common/upgrades-FailsWhenATopLevelEnumChanges-v1.dar",
"test-common/upgrades-FailsWhenATopLevelEnumChanges-v2.dar",
"test-common/upgrades-SucceedsWhenATopLevelEnumChanges-v1.dar",
"test-common/upgrades-SucceedsWhenATopLevelEnumChanges-v2.dar",
assertPackageUpgradeCheck(None),
)
}

View File

@ -113,12 +113,13 @@ def _daml_build_impl(ctx):
damlc = ctx.executable.damlc
input_dars = [file_of_target(k) for k in dar_dict.keys()]
output_dar = ctx.outputs.dar
output_stdout = ctx.outputs.stdout
posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"]
ghc_opts = ctx.attr.ghc_options
ctx.actions.run_shell(
tools = [damlc],
inputs = [daml_yaml] + srcs + input_dars,
outputs = [output_dar],
outputs = [output_dar] + ([output_stdout] if output_stdout != None else []),
progress_message = "Building Daml project %s" % name,
command = """
set -eou pipefail
@ -131,7 +132,7 @@ def _daml_build_impl(ctx):
{sed} -i 's/daml-script$/daml-script.dar/;s/daml3-script$/daml3-script.dar/;s/daml-trigger$/daml-trigger.dar/' $tmpdir/daml.yaml
{cp_srcs}
{cp_dars}
{damlc} build --project-root $tmpdir {ghc_opts} -o $PWD/{output_dar}
{damlc} build --project-root $tmpdir {ghc_opts} -o $PWD/{output_dar} 2>&1 | {output_stdout_command}
""".format(
config = daml_yaml.path,
cp_srcs = "\n".join([
@ -152,6 +153,7 @@ def _daml_build_impl(ctx):
sed = posix.commands["sed"],
damlc = damlc.path,
output_dar = output_dar.path,
output_stdout_command = "tee " + output_stdout.path if output_stdout != None else "cat",
sdk_version = sdk_version,
ghc_opts = " ".join(ghc_opts),
),
@ -179,6 +181,9 @@ _daml_build = rule(
mandatory = True,
doc = "The generated DAR file.",
),
"stdout": attr.output(
doc = "The standard output of the build command.",
),
"ghc_options": attr.string_list(
doc = "Options passed to GHC.",
default = ["--ghc-option=-Werror", "--log-level=WARNING"],
@ -348,6 +353,7 @@ def daml_compile(
dar_dict =
{dar: path_to_dar(dar) for dar in (dependencies + data_dependencies + ([upgrades] if upgrades else []))},
dar = name + ".dar",
stdout = name + ".stdout",
ghc_options =
ghc_options +
(["--enable-scenarios=yes"] if enable_scenarios and (target == None or _supports_scenarios(target)) else []) +

View File

@ -69,6 +69,11 @@ da_scala_dar_resources_library(
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v1".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v1/*.daml".format(identifier)]),
@ -122,11 +127,10 @@ da_scala_dar_resources_library(
"SucceedsWhenTemplateChoiceReturnsATemplateWhichHasChanged",
# More tests ported from DamlcUpgrades.hs
"FailsWhenATopLevelEnumChanges",
"SucceedsWhenATopLevelEnumChanges",
"FailsWhenATopLevelRecordAddsANonOptionalField",
"FailsWhenATopLevelRecordAddsAnOptionalFieldBeforeTheEnd",
"FailsWhenATopLevelVariantAddsAFieldToAVariantsType",
"FailsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType",
"FailsWhenATopLevelVariantAddsAVariant",
"FailsWhenATopLevelVariantRemovesAVariant",
"FailsWhenTwoDeeplyNestedTypeSynonymsResolveToDifferentDatatypes",
@ -141,11 +145,30 @@ da_scala_dar_resources_library(
# More more more tests ported from DamlcUpgrades.hs
"FailsWhenAnInterfaceIsDefinedInAnUpgradingPackageWhenItWasAlreadyInThePriorPackage",
"SucceedsWhenAnInterfaceIsOnlyDefinedInTheInitialPackage",
"SucceedWhenATopLevelEnumAddsAField",
"SucceedsWhenATopLevelVariantAddsAVariant",
"SucceedsWhenATopLevelVariantAddsAnOptionalFieldToAVariantsType",
"WarnsWhenAnInterfaceAndATemplateAreDefinedInTheSamePackage",
"WarnsWhenAnInterfaceIsUsedInThePackageThatItsDefinedIn",
"WarnsWhenControllersOfTemplateChoiceAreChanged",
"WarnsWhenObserversOfTemplateChoiceAreChanged",
"WarnsWhenTemplateChangesEnsure",
"WarnsWhenTemplateChangesKeyExpression",
"WarnsWhenTemplateChangesKeyMaintainers",
"WarnsWhenTemplateChangesObservers",
"WarnsWhenTemplateChangesSignatories",
"FailsWithSynonymReturnTypeChange",
"FailsOnlyInModuleNotInReexports",
]
]
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v1".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v1/*.daml".format(identifier)]),
@ -177,11 +200,99 @@ da_scala_dar_resources_library(
for identifier in [
# More more more tests ported from DamlcUpgrades.hs
"SucceedsWhenAnInstanceIsAddedUpgradedPackage",
"WarnsWhenAnInterfaceIsDefinedAndThenUsedInAPackageThatUpgradesIt",
]
]
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
]
for identifier in [
"CannotUpgradeView",
]
]
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-dep-v1".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/dep-v1/*.daml".format(identifier)]),
dependencies = ["//daml-script/daml:daml-script-2.dev.dar"],
enable_interfaces = True,
ghc_options = default_damlc_opts + ["--ghc-option=-Wno-unused-imports"],
project_name = "upgrades-example-{}-dep".format(identifier),
target = "2.dev",
version = "1.0.0",
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-dep-v2".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/dep-v2/*.daml".format(identifier)]),
dependencies = ["//daml-script/daml:daml-script-2.dev.dar"],
enable_interfaces = True,
ghc_options = default_damlc_opts + ["--ghc-option=-Wno-unused-imports"],
project_name = "upgrades-example-{}-dep".format(identifier),
target = "2.dev",
# We want to check the validity of this upgrade on the ledger
# client, not during compilation
typecheck_upgrades = False,
upgrades = "//test-common:upgrades-{}-dep-v1.dar".format(identifier),
version = "2.0.0",
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v1".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v1/*.daml".format(identifier)]),
data_dependencies = ["//test-common:upgrades-{}-dep-v1.dar".format(identifier)],
dependencies = ["//daml-script/daml:daml-script-2.dev.dar"],
enable_interfaces = True,
ghc_options = default_damlc_opts + ["--ghc-option=-Wno-unused-imports"],
project_name = "upgrades-example-{}".format(identifier),
target = "2.dev",
version = "1.0.0",
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v2".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v2/*.daml".format(identifier)]),
data_dependencies = ["//test-common:upgrades-{}-dep-v2.dar".format(identifier)],
dependencies = ["//daml-script/daml:daml-script-2.dev.dar"],
enable_interfaces = True,
ghc_options = default_damlc_opts + ["--ghc-option=-Wno-unused-imports"],
project_name = "upgrades-example-{}".format(identifier),
target = "2.dev",
# We want to check the validity of this upgrade on the ledger
# client, not during compilation
typecheck_upgrades = False,
upgrades = "//test-common:upgrades-{}-v1.dar".format(identifier),
version = "2.0.0",
visibility = ["//visibility:public"],
),
]
for identifier in [
# More more more tests ported from DamlcUpgrades.hs
"FailsWithSynonymReturnTypeChangeInSeparatePackage",
"SucceedsWhenUpgradingADependency",
]
]
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-dep".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/dep/*.daml".format(identifier)]),
@ -231,6 +342,11 @@ da_scala_dar_resources_library(
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v1a".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v1a/*.daml".format(identifier)]),
@ -257,6 +373,11 @@ da_scala_dar_resources_library(
[
[
filegroup(
name = "upgrades-{}-files".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/*/*.daml".format(identifier)]),
visibility = ["//visibility:public"],
),
daml_compile(
name = "upgrades-{}-v1".format(identifier),
srcs = glob(["src/main/daml/upgrades/{}/v1/*.daml".format(identifier)]),

View File

@ -0,0 +1,13 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template T with
p: Party
where
signatory p
data IView = IView { i : Text }
interface I where
viewtype IView
method1 : Int

View File

@ -0,0 +1,14 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import qualified "upgrades-example-CannotUpgradeView" Main as V1
template T with
p: Party
where
signatory p
interface instance V1.I for T where
view = IView "hi" None
method1 = 2
data IView = IView { i : Text, other : Optional Text }

View File

@ -0,0 +1,7 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main (module Other) where
import Other

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Other where
data A = A
{ field1 : Text
}

View File

@ -0,0 +1,7 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main (module Other) where
import Other

View File

@ -0,0 +1,10 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Other where
data A = A
{ field1 : Text
, field2 : Text
}

View File

@ -0,0 +1,18 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = A { a : Text }
data B = B { b : Text }
type Synonym = A
template T with
p : Party
where
signatory p
choice C : Synonym
controller p
do pure A { a = "a" }

View File

@ -0,0 +1,19 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = A { a : Text }
data B = B { b : Text }
type Synonym = B
template T with
p : Party
where
signatory p
choice C : Synonym
controller p
do pure B { b = "b" }

View File

@ -0,0 +1,10 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Dep where
data A = A { a : Text }
data B = B { b : Text }
type Synonym = A

View File

@ -0,0 +1,10 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Dep where
data A = A { a : Text }
data B = B { b : Text }
type Synonym = B

View File

@ -0,0 +1,15 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import Dep
template T with
p: Party
where
signatory p
choice C : Synonym
controller p
do pure $ A { a = "a" }

View File

@ -0,0 +1,15 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import Dep
template T with
p: Party
where
signatory p
choice C : Synonym
controller p
do pure $ B { b = "b" }

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
template T with
p: Party
where

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
template T with
p: Party
where

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data T = T with
x : Text
deriving Show

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data T = T with
x : Text
deriving Show

View File

@ -4,9 +4,3 @@
module Main where
import qualified Other
import Daml.Script
main : Script ()
main = do
Other.main
pure ()

View File

@ -2,8 +2,3 @@
-- SPDX-License-Identifier: Apache-2.0
module Other where
import Daml.Script
main : Script ()
main = pure ()

View File

@ -2,8 +2,3 @@
-- SPDX-License-Identifier: Apache-2.0
module Main where
import Daml.Script
main : Script ()
main = pure ()

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
template T with
p: Party
where

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
template T with
p: Party
where

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data Struct = Struct with
field1 : Int

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data Struct = Struct with
field1 : Int
field2 : Text

View File

@ -0,0 +1,6 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = X

View File

@ -0,0 +1,6 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = X | Y

View File

@ -0,0 +1,6 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = X { x : Int } | Y { y : Int } | Z { z : Int }

View File

@ -0,0 +1,6 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data A = X { x : Int } | Y { y : Int }

View File

@ -0,0 +1,15 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Dep where
data D = D { field1 : Text }
template T with
p: Party
where
signatory p
choice C1 : D
controller p
do pure $ D "field1"

View File

@ -0,0 +1,18 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Dep where
data D = D { field1 : Text, field2 : Optional Text }
template T with
p: Party
where
signatory p
choice C1 : D
controller p
do pure $ D "field1" (Some "field2")
choice C2 : D
controller p
do pure $ D "field1" None

View File

@ -0,0 +1,23 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import qualified Dep
data D = D { field1 : Text }
template T with
p: Party
t: ContractId Dep.T
where
signatory p
choice C1 : D
controller p
do
depD <- exercise t Dep.C1
pure $ D "field1"
choice C2 : Dep.D
controller p
do exercise t Dep.C1

View File

@ -0,0 +1,23 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import qualified Dep
data D = D { field1 : Text, field2 : Optional Dep.D }
template T with
p: Party
t: ContractId Dep.T
where
signatory p
choice C1 : D
controller p
do
depD <- exercise t Dep.C1 -- only works when party is same
pure $ D "field1" (Some depD)
choice C2 : Dep.D
controller p
do exercise t Dep.C2 -- only works when party is same

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data TKey1 = TKey1 with p : Party
data TKey2 = TKey2 with p : Party

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data TKey1 = TKey1 with p : Party
data TKey2 = TKey2 with p : Party

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data TKey1 = TKey1 { p : Party }
template T with

View File

@ -3,11 +3,6 @@
module Main where
import Daml.Script
main : Script ()
main = pure ()
data TKey1 = TKey1 with
p : Party

View File

@ -0,0 +1,5 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where

View File

@ -0,0 +1,13 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data IView = IView { i : Text }
interface I where
viewtype IView
method1 : Int
template T with
p: Party
where
signatory p

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data IView = IView { i : Text }
interface I where
viewtype IView
method1 : Int

View File

@ -0,0 +1,14 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
import qualified "upgrades-example-WarnsWhenAnInterfaceIsDefinedAndThenUsedInAPackageThatUpgradesIt" Main as V1
data IView = IView { i : Text }
template T with
p: Party
where
signatory p
interface instance V1.I for T where
view = V1.IView "hi"
method1 = 2

View File

@ -0,0 +1,5 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where

View File

@ -0,0 +1,16 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
data IView = IView { i : Text }
interface I where
viewtype IView
method1 : Int
template T with
p: Party
where
signatory p
interface instance I for T where
view = IView "hi"
method1 = 2

View File

@ -0,0 +1,13 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
choice C : ()
controller p
do pure ()

View File

@ -0,0 +1,13 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
choice C : ()
controller p, q
do pure ()

View File

@ -0,0 +1,14 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
choice C : ()
observer p
controller p
do pure ()

View File

@ -0,0 +1,14 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
choice C : ()
observer p, q
controller p
do pure ()

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
ensure True

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
ensure True == True

View File

@ -0,0 +1,12 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
key (p, "example") : (Party, Text)
maintainer (fst key)

View File

@ -0,0 +1,12 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
key (q, "example") : (Party, Text)
maintainer (fst key)

View File

@ -0,0 +1,12 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
key (p, q) : (Party, Party)
maintainer (fst key)

View File

@ -0,0 +1,12 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
key (p, q) : (Party, Party)
maintainer (snd key)

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
observer p

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where
signatory p
observer p, q

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where signatory [p]

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Main where
template A with
p : Party
q : Party
where signatory [p, q]