mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
Extractor: replace sandbox-classic
-based fixtures with sandbox
-based ones (#11489)
* Replace `sandbox-classic`-based fixtures with `sandbox`-based ones changelog_begin changelog_end * Replace Scenarios with Script for BasicPrimitiveTypes * Adapt ListsSpec * Adapt TextMapsSpec * Adapt OptionalSpec * Adapt more tests * More tests passing - removed workflow_id testing (Daml Script doesn't set one) - reduced failure threshold for VeryLargeArchiveSpec - solved issu in TransactionSingleTableSpec (wrong parties were used) * Port EnumMod and make EnumSpec pass * Port GenMapMod and make GenMapSpec pass * Shaking things around to make Windows happy -- maybe
This commit is contained in:
parent
d86fe92950
commit
b84a9142d1
@ -27,6 +27,7 @@ da_scala_library(
|
||||
"//compiler/scenario-service:__subpackages__",
|
||||
"//daml-lf:__subpackages__",
|
||||
"//daml-script:__subpackages__",
|
||||
"//extractor:__subpackages__",
|
||||
"//ledger:__subpackages__",
|
||||
"//triggers:__subpackages__",
|
||||
],
|
||||
|
@ -121,6 +121,7 @@ da_scala_library(
|
||||
"@maven//:org_scalatest_scalatest_wordspec",
|
||||
"@maven//:org_scalaz_scalaz_core",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//bazel_tools/runfiles:scala_runfiles",
|
||||
"//daml-lf/archive:daml_lf_archive_reader",
|
||||
|
@ -20,21 +20,44 @@ load(
|
||||
":extractor.bzl",
|
||||
"extractor_test",
|
||||
)
|
||||
load("@build_environment//:configuration.bzl", "sdk_version")
|
||||
|
||||
TEST_DARS = [
|
||||
"RecordsAndVariants",
|
||||
"PrimitiveTypes",
|
||||
"TransactionExample",
|
||||
]
|
||||
|
||||
[
|
||||
daml_compile(
|
||||
name = darmod,
|
||||
srcs = ["src/test/resources/damls/%s.daml" % darmod],
|
||||
target = lf_version_configuration.get("default"),
|
||||
)
|
||||
for darmod in TEST_DARS
|
||||
]
|
||||
genrule(
|
||||
name = "test-dar",
|
||||
srcs = [
|
||||
"//daml-script/daml:daml-script.dar",
|
||||
":src/test/resources/damls/EnumMod.daml",
|
||||
":src/test/resources/damls/GenMapMod.daml",
|
||||
":src/test/resources/damls/PrimitiveTypes.daml",
|
||||
":src/test/resources/damls/RecordsAndVariants.daml",
|
||||
":src/test/resources/damls/TransactionExample.daml",
|
||||
],
|
||||
outs = ["test.dar"],
|
||||
cmd = """
|
||||
set -eou pipefail
|
||||
TMP_DIR=$$(mktemp -d)
|
||||
mkdir -p $$TMP_DIR/daml
|
||||
cp -L $(location :src/test/resources/damls/EnumMod.daml) $$TMP_DIR/daml
|
||||
cp -L $(location :src/test/resources/damls/GenMapMod.daml) $$TMP_DIR/daml
|
||||
cp -L $(location :src/test/resources/damls/RecordsAndVariants.daml) $$TMP_DIR/daml
|
||||
cp -L $(location :src/test/resources/damls/PrimitiveTypes.daml) $$TMP_DIR/daml
|
||||
cp -L $(location :src/test/resources/damls/TransactionExample.daml) $$TMP_DIR/daml
|
||||
cp -L $(location //daml-script/daml:daml-script.dar) $$TMP_DIR/
|
||||
cat << EOF > $$TMP_DIR/daml.yaml
|
||||
sdk-version: {sdk}
|
||||
name: test
|
||||
source: daml
|
||||
version: 0.0.1
|
||||
dependencies:
|
||||
- daml-stdlib
|
||||
- daml-prim
|
||||
- daml-script.dar
|
||||
EOF
|
||||
$(location //compiler/damlc) build --project-root=$$TMP_DIR --ghc-option=-Werror -o $$PWD/$(location test.dar)
|
||||
rm -rf $$TMP_DIR
|
||||
""".format(sdk = sdk_version),
|
||||
tools = ["//compiler/damlc"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "VeryLargeArchive_src",
|
||||
@ -79,6 +102,11 @@ daml_compile(
|
||||
da_scala_library(
|
||||
name = "extractor",
|
||||
srcs = glob(["src/main/scala/**/*.scala"]),
|
||||
data = [
|
||||
"//daml-script/test:script-test.dar",
|
||||
"//daml-script/test:script-test-1.dev.dar",
|
||||
"//extractor:test-dar",
|
||||
],
|
||||
plugins = [
|
||||
silencer_plugin,
|
||||
],
|
||||
@ -160,6 +188,7 @@ da_scala_library(
|
||||
"@maven//:com_typesafe_scala_logging_scala_logging",
|
||||
"@maven//:io_circe_circe_core",
|
||||
"@maven//:io_circe_circe_parser",
|
||||
"@maven//:io_spray_spray_json",
|
||||
"@maven//:org_scalacheck_scalacheck",
|
||||
"@maven//:org_scalactic_scalactic",
|
||||
"@maven//:org_scalatest_scalatest_core",
|
||||
@ -186,8 +215,14 @@ da_scala_library(
|
||||
],
|
||||
deps = [
|
||||
":extractor",
|
||||
"//bazel_tools/runfiles:scala_runfiles",
|
||||
"//daml-lf/archive:daml_lf_archive_reader",
|
||||
"//daml-lf/data",
|
||||
"//daml-lf/interface",
|
||||
"//daml-lf/interpreter",
|
||||
"//daml-lf/language",
|
||||
"//daml-script/runner:script-runner-lib",
|
||||
"//daml-script/test:test-utils",
|
||||
"//language-support/scala/bindings",
|
||||
"//ledger-api/rs-grpc-bridge",
|
||||
"//ledger-api/testing-utils",
|
||||
@ -195,8 +230,8 @@ da_scala_library(
|
||||
"//ledger/ledger-api-client",
|
||||
"//ledger/ledger-api-common",
|
||||
"//ledger/ledger-api-domain",
|
||||
"//ledger/sandbox-classic",
|
||||
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
|
||||
"//ledger/sandbox",
|
||||
"//ledger/sandbox:sandbox-scala-tests-lib",
|
||||
"//ledger/sandbox-common",
|
||||
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
|
||||
"//libs-scala/auth-utils",
|
||||
|
@ -15,9 +15,9 @@ def extractor_test(name, srcs, flaky):
|
||||
srcs = srcs,
|
||||
data = [
|
||||
"//daml-lf/encoder:testing-dar-latest",
|
||||
"//extractor:PrimitiveTypes.dar",
|
||||
"//extractor:RecordsAndVariants.dar",
|
||||
"//extractor:TransactionExample.dar",
|
||||
"//daml-script/test:script-test.dar",
|
||||
"//daml-script/test:script-test-1.dev.dar",
|
||||
"//extractor:test-dar",
|
||||
"//extractor:VeryLargeArchive.dar",
|
||||
"//ledger/test-common:dar-files",
|
||||
"//ledger/test-common/test-certificates",
|
||||
@ -34,6 +34,7 @@ def extractor_test(name, srcs, flaky):
|
||||
"@maven//:com_typesafe_scala_logging_scala_logging",
|
||||
"@maven//:io_circe_circe_core",
|
||||
"@maven//:io_circe_circe_parser",
|
||||
"@maven//:io_spray_spray_json",
|
||||
"@maven//:org_scalacheck_scalacheck",
|
||||
"@maven//:org_scalactic_scalactic",
|
||||
"@maven//:org_scalatest_scalatest_core",
|
||||
@ -57,11 +58,16 @@ def extractor_test(name, srcs, flaky):
|
||||
":extractor",
|
||||
":extractor-scala-tests-lib",
|
||||
"//bazel_tools/runfiles:scala_runfiles",
|
||||
"//daml-lf/archive:daml_lf_archive_reader",
|
||||
"//daml-lf/data",
|
||||
"//daml-lf/encoder:testing-dar-lookup-lib-latest",
|
||||
"//daml-lf/interface",
|
||||
"//daml-lf/interpreter",
|
||||
"//daml-lf/language",
|
||||
"//daml-lf/transaction",
|
||||
"//daml-lf/transaction-test-lib",
|
||||
"//daml-script/runner:script-runner-lib",
|
||||
"//daml-script/test:test-utils",
|
||||
"//language-support/scala/bindings",
|
||||
"//ledger-api/rs-grpc-bridge",
|
||||
"//ledger-api/testing-utils",
|
||||
@ -75,8 +81,8 @@ def extractor_test(name, srcs, flaky):
|
||||
"//ledger/ledger-resources",
|
||||
"//ledger/participant-integration-api",
|
||||
"//ledger/participant-state",
|
||||
"//ledger/sandbox-classic",
|
||||
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
|
||||
"//ledger/sandbox",
|
||||
"//ledger/sandbox:sandbox-scala-tests-lib",
|
||||
"//ledger/sandbox-common",
|
||||
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
|
||||
"//ledger/test-common",
|
||||
|
@ -3,39 +3,50 @@
|
||||
|
||||
package com.daml.extractor.services
|
||||
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
import cats.effect.{ContextShift, IO}
|
||||
import com.daml.bazeltools.BazelRunfiles
|
||||
import com.daml.extractor.Extractor
|
||||
import com.daml.extractor.config.{ExtractorConfig, SnapshotEndSetting}
|
||||
import com.daml.extractor.targets.PostgreSQLTarget
|
||||
import com.daml.ledger.api.tls.TlsConfiguration
|
||||
import com.daml.ledger.api.v1.ledger_offset.LedgerOffset
|
||||
import com.daml.lf.data.Ref.Party
|
||||
import com.daml.platform.sandbox.services.SandboxFixture
|
||||
import com.daml.lf.data.Ref.{Party, QualifiedName}
|
||||
import com.daml.lf.engine.script.ledgerinteraction.ScriptTimeMode
|
||||
import com.daml.lf.engine.script.test.SandboxParticipantFixture
|
||||
import com.daml.ports.Port
|
||||
import com.daml.testing.postgresql.{PostgresAround, PostgresAroundSuite}
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
import doobie.util.transactor.Transactor.Aux
|
||||
import org.scalatest._
|
||||
import scalaz.OneAnd
|
||||
import scalaz.{NonEmptyList, OneAnd}
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.concurrent.{Await, ExecutionContext}
|
||||
|
||||
trait ExtractorFixture extends SandboxFixture with PostgresAroundSuite with Types {
|
||||
trait ExtractorFixture extends SandboxParticipantFixture with PostgresAroundSuite with Types {
|
||||
self: Suite =>
|
||||
|
||||
import Types._
|
||||
|
||||
implicit val cs: ContextShift[IO] = IO.contextShift(ExecutionContext.global)
|
||||
|
||||
protected val baseConfig: ExtractorConfig = ExtractorConfig(
|
||||
protected def initScript: Option[String] = None
|
||||
|
||||
protected def parties: NonEmptyList[String] = NonEmptyList("IRRELEVANT")
|
||||
|
||||
override protected val timeMode: ScriptTimeMode = ScriptTimeMode.Static
|
||||
|
||||
protected def baseConfig: ExtractorConfig = ExtractorConfig(
|
||||
"127.0.0.1",
|
||||
ledgerPort = Port(666), // doesn't matter, will/must be overridden in the test cases
|
||||
ledgerInboundMessageSizeMax = 50 * 1024 * 1024,
|
||||
LedgerOffset(LedgerOffset.Value.Boundary(LedgerOffset.LedgerBoundary.LEDGER_BEGIN)),
|
||||
SnapshotEndSetting.Head,
|
||||
OneAnd(Party assertFromString "Bob", List.empty),
|
||||
OneAnd.oneAndNelIso.to(parties.map(Party.assertFromString)),
|
||||
Set.empty,
|
||||
TlsConfiguration(
|
||||
enabled = false,
|
||||
@ -46,6 +57,10 @@ trait ExtractorFixture extends SandboxFixture with PostgresAroundSuite with Type
|
||||
None,
|
||||
)
|
||||
|
||||
override def packageFiles: List[File] = {
|
||||
new File(BazelRunfiles.rlocation("extractor/test.dar")) :: super.packageFiles
|
||||
}
|
||||
|
||||
protected def outputFormat: String = "single-table"
|
||||
|
||||
protected def configureExtractor(ec: ExtractorConfig): ExtractorConfig = ec
|
||||
@ -99,6 +114,18 @@ trait ExtractorFixture extends SandboxFixture with PostgresAroundSuite with Type
|
||||
protected var extractor: Extractor[PostgreSQLTarget] = _
|
||||
|
||||
protected def run(): Unit = {
|
||||
initScript
|
||||
.map(QualifiedName.assertFromString)
|
||||
.foreach(init => {
|
||||
val ec = ExecutionContext.fromExecutorService(Executors.newSingleThreadExecutor())
|
||||
try {
|
||||
val (dar, _) = readDar(darFile)
|
||||
val result = participantClients().flatMap(run(_, init, dar = dar)(ec))(ec)
|
||||
val _ = Await.result(result, atMost = 30.seconds)
|
||||
} finally {
|
||||
ec.shutdown()
|
||||
}
|
||||
})
|
||||
val config: ExtractorConfig = configureExtractor(baseConfig.copy(ledgerPort = serverPort))
|
||||
|
||||
extractor = new Extractor(config, target)()
|
||||
|
33
extractor/src/test/resources/damls/EnumMod.daml
Normal file
33
extractor/src/test/resources/damls/EnumMod.daml
Normal file
@ -0,0 +1,33 @@
|
||||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
-- Port of daml-lf/encoder/src/test/lf/Enum_all_.lf
|
||||
|
||||
module EnumMod where
|
||||
|
||||
import Daml.Script
|
||||
|
||||
data Color = Red | Green | Blue deriving (Show, Eq)
|
||||
|
||||
template Box
|
||||
with
|
||||
x: Color
|
||||
party: Party
|
||||
where
|
||||
signatory party
|
||||
|
||||
createContracts =
|
||||
script do
|
||||
party <- allocatePartyWithHint "EnumMod" (PartyIdHint "EnumMod")
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = Red
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = Green
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = Blue
|
||||
party = party
|
45
extractor/src/test/resources/damls/GenMapMod.daml
Normal file
45
extractor/src/test/resources/damls/GenMapMod.daml
Normal file
@ -0,0 +1,45 @@
|
||||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
-- Port of daml-lf/encoder/src/test/lf/GenMap_1.11_1.12_1.13_1.14_1.dev_.lf
|
||||
|
||||
module GenMapMod where
|
||||
|
||||
import Daml.Script
|
||||
import DA.Map (Map)
|
||||
import DA.Map qualified as M
|
||||
|
||||
template Box
|
||||
with
|
||||
x: Map (Int, Decimal) (Either Int Decimal)
|
||||
party: Party
|
||||
where
|
||||
signatory party
|
||||
|
||||
l1 = []
|
||||
|
||||
l2 = ((1, 1.0), (Left (0))) :: l1
|
||||
|
||||
l3 = ((-2, -2.2222222222), (Right (1.1111111111))) :: l2
|
||||
|
||||
l4 = ((-3, -3333333333333333333333333333.0), (Right (-2.2222222222))) :: l3
|
||||
|
||||
createContracts =
|
||||
script do
|
||||
party <- allocatePartyWithHint "GenMapMod" (PartyIdHint "GenMapMod")
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = M.fromList l1
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = M.fromList l2
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = M.fromList l3
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Box with
|
||||
x = M.fromList l4
|
||||
party = party
|
@ -5,6 +5,7 @@ module PrimitiveTypes where
|
||||
|
||||
import DA.Date
|
||||
import DA.TextMap as TM
|
||||
import Daml.Script
|
||||
|
||||
template BasicPrimitiveTypes
|
||||
with
|
||||
@ -61,10 +62,10 @@ template TextMaps
|
||||
"whatevs"
|
||||
|
||||
primitives =
|
||||
scenario do
|
||||
bob <- getParty "Bob"
|
||||
submit bob do
|
||||
create BasicPrimitiveTypes with
|
||||
script do
|
||||
party <- allocatePartyWithHint "Primitives" (PartyIdHint "Primitives")
|
||||
submit party do
|
||||
createCmd BasicPrimitiveTypes with
|
||||
reference = "Simple values"
|
||||
int_field = 5
|
||||
decimal_field = 5.5
|
||||
@ -72,10 +73,11 @@ primitives =
|
||||
numeric37_field = 0.25
|
||||
text_field = "Hey"
|
||||
bool_field = True
|
||||
party_field = bob
|
||||
party_field = party
|
||||
date_field = date 2020 Feb 22
|
||||
time_field = datetime 2020 Feb 22 12 13 14
|
||||
create BasicPrimitiveTypes with
|
||||
submit party do
|
||||
createCmd BasicPrimitiveTypes with
|
||||
reference = "Positive extremes"
|
||||
int_field = 9223372036854775807
|
||||
decimal_field = 9999999999999999999999999999.9999999999
|
||||
@ -83,10 +85,11 @@ primitives =
|
||||
numeric37_field = 9.9999999999999999999999999999999999999
|
||||
text_field = "Hey"
|
||||
bool_field = True
|
||||
party_field = bob
|
||||
party_field = party
|
||||
date_field = date 9999 Dec 31
|
||||
time_field = datetime 9999 Dec 31 23 59 59
|
||||
create BasicPrimitiveTypes with
|
||||
submit party do
|
||||
createCmd BasicPrimitiveTypes with
|
||||
reference = "Negative extremes"
|
||||
int_field = -9223372036854775808
|
||||
decimal_field = -9999999999999999999999999999.9999999999
|
||||
@ -94,56 +97,60 @@ primitives =
|
||||
numeric37_field = -9.9999999999999999999999999999999999999
|
||||
text_field = "Hey"
|
||||
bool_field = True
|
||||
party_field = bob
|
||||
party_field = party
|
||||
date_field = date 0001 Jan 01
|
||||
time_field = datetime 0001 Jan 01 00 00 00
|
||||
|
||||
lists =
|
||||
scenario do
|
||||
bob <- getParty "Bob"
|
||||
submit bob do
|
||||
create Lists with
|
||||
script do
|
||||
party <- allocatePartyWithHint "Lists" (PartyIdHint "Lists")
|
||||
submit party do
|
||||
createCmd Lists with
|
||||
reference = "Empty lists"
|
||||
int_list = []
|
||||
text_list = []
|
||||
party = bob
|
||||
create Lists with
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Lists with
|
||||
reference = "Non-empty lists"
|
||||
int_list = [1, 2, 3, 4, 5]
|
||||
text_list = ["foo", "bar", "baz"]
|
||||
party = bob
|
||||
party = party
|
||||
|
||||
optionals =
|
||||
scenario do
|
||||
bob <- getParty "Bob"
|
||||
submit bob do
|
||||
create Optionals with
|
||||
script do
|
||||
party <- allocatePartyWithHint "Optionals" (PartyIdHint "Optionals")
|
||||
submit party do
|
||||
createCmd Optionals with
|
||||
reference = "Nones"
|
||||
optional = None
|
||||
deep_optional = None
|
||||
party = bob
|
||||
create Optionals with
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Optionals with
|
||||
reference = "Somes"
|
||||
optional = Some "foo"
|
||||
deep_optional = Some (Some "foo")
|
||||
party = bob
|
||||
create Optionals with
|
||||
party = party
|
||||
submit party do
|
||||
createCmd Optionals with
|
||||
reference = "Some None"
|
||||
optional = Some "foo"
|
||||
deep_optional = Some None
|
||||
party = bob
|
||||
party = party
|
||||
|
||||
textMaps =
|
||||
scenario do
|
||||
bob <- getParty "Bob"
|
||||
submit bob do
|
||||
create TextMaps with
|
||||
script do
|
||||
party <- allocatePartyWithHint "TextMaps" (PartyIdHint "TextMaps")
|
||||
submit party do
|
||||
createCmd TextMaps with
|
||||
reference = "Empty maps"
|
||||
map = TM.empty
|
||||
deep_map = TM.empty
|
||||
party = bob
|
||||
create TextMaps with
|
||||
party = party
|
||||
submit party do
|
||||
createCmd TextMaps with
|
||||
reference = "Non-empty maps"
|
||||
map = TM.fromList [("1", 1), ("2", 2), ("3",3), ("4",4), ("5",5)]
|
||||
deep_map = TM.empty
|
||||
party = bob
|
||||
party = party
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
module RecordsAndVariants where
|
||||
|
||||
import Daml.Script
|
||||
|
||||
data EitherM a b = LeftM a | RightM b deriving (Eq, Show)
|
||||
|
||||
data Maybe a = Nope | Just a deriving (Eq, Show)
|
||||
@ -37,12 +39,12 @@ template RecordsAndVariants
|
||||
"whatevs"
|
||||
|
||||
suite =
|
||||
scenario do
|
||||
bob <- getParty "Bob"
|
||||
submit bob do
|
||||
create RecordsAndVariants with
|
||||
script do
|
||||
party <- allocatePartyWithHint "Suite" (PartyIdHint "Suite")
|
||||
submit party do
|
||||
createCmd RecordsAndVariants with
|
||||
reference = "All-in-one"
|
||||
party = bob
|
||||
party = party
|
||||
simpleRecord = SimpleRecord with foo = True
|
||||
recordTextInt = RecordAB with foo = "Foo", baz = 6
|
||||
eitherVariant = RightM 7
|
||||
@ -69,16 +71,15 @@ template Duo
|
||||
signatory party
|
||||
observer other
|
||||
|
||||
multiParty = scenario do
|
||||
bob <- getParty "Bob"
|
||||
alice <- getParty "Alice"
|
||||
quux <- getParty "Quux"
|
||||
-- visible to Bob,Alice: 1, 2, 4, 5, 7
|
||||
submit bob do create (Solo bob 1)
|
||||
submit alice do create (Solo alice 2)
|
||||
submit quux do create (Solo quux 3)
|
||||
submit bob do create (Duo bob quux 4)
|
||||
submit quux do
|
||||
create (Duo quux alice 5)
|
||||
create (Duo quux quux 6)
|
||||
submit bob do create (Duo bob alice 7) -- ensure not seen twice
|
||||
multiParty = script do
|
||||
p1 <- allocatePartyWithHint "MultiParty1" (PartyIdHint "MultiParty1")
|
||||
p2 <- allocatePartyWithHint "MultiParty2" (PartyIdHint "MultiParty2")
|
||||
p3 <- allocatePartyWithHint "MultiParty3" (PartyIdHint "MultiParty3")
|
||||
-- visible to MultiParty1, MultiParty2: 1, 2, 4, 5, 7
|
||||
submit p1 do createCmd (Solo p1 1)
|
||||
submit p2 do createCmd (Solo p2 2)
|
||||
submit p3 do createCmd (Solo p3 3)
|
||||
submit p1 do createCmd (Duo p1 p3 4)
|
||||
submit p3 do createCmd (Duo p3 p2 5)
|
||||
submit p3 do createCmd (Duo p3 p3 6)
|
||||
submit p1 do createCmd (Duo p1 p2 7) -- ensure not seen twice
|
||||
|
@ -5,6 +5,7 @@
|
||||
module TransactionExample where
|
||||
|
||||
import DA.Date
|
||||
import Daml.Script
|
||||
|
||||
template RightOfUseAgreement
|
||||
with
|
||||
@ -47,49 +48,49 @@ template DummyTemplateWeDontSubscribeFor
|
||||
where
|
||||
signatory party1
|
||||
|
||||
example = scenario do
|
||||
bob <- getParty "Bob"
|
||||
alice <- getParty "Alice"
|
||||
example = script do
|
||||
p1 <- allocatePartyWithHint "Example1" (PartyIdHint "Example1")
|
||||
p2 <- allocatePartyWithHint "Example2" (PartyIdHint "Example2")
|
||||
|
||||
-- Alice offers Bob room at Blaha Lujza Square, Budapest
|
||||
offer <- submit alice do
|
||||
create RightOfUseOffer with
|
||||
landlord = alice
|
||||
tenant = bob
|
||||
-- Example2 offers Example1 room at Blaha Lujza Square, Budapest
|
||||
offer <- submit p2 do
|
||||
createCmd RightOfUseOffer with
|
||||
landlord = p2
|
||||
tenant = p1
|
||||
address = "Blaha Lujza Square, Budapest"
|
||||
expirationDate = date 2020 Jan 1
|
||||
|
||||
-- Bob accepts the offer, which creates a RightOfUseAgreement
|
||||
submit bob do
|
||||
exercise offer Accept
|
||||
-- Example1 accepts the offer, which creates a RightOfUseAgreement
|
||||
submit p1 do
|
||||
exerciseCmd offer Accept
|
||||
|
||||
-- create a transient RightOfUseOffer and archive it immediately.
|
||||
submit bob do
|
||||
createAndExercise
|
||||
submit p1 do
|
||||
createAndExerciseCmd
|
||||
RightOfUseOffer with
|
||||
landlord = bob
|
||||
tenant = alice
|
||||
landlord = p1
|
||||
tenant = p2
|
||||
address = "fobar"
|
||||
expirationDate = date 2020 Jan 1
|
||||
Archive
|
||||
|
||||
templateFilterTest = scenario do
|
||||
bob <- getParty "Bob"
|
||||
alice <- getParty "Alice"
|
||||
templateFilterTest = script do
|
||||
p1 <- allocatePartyWithHint "TemplateFilterTest1" (PartyIdHint "TemplateFilterTest1")
|
||||
p2 <- allocatePartyWithHint "TemplateFilterTest2" (PartyIdHint "TemplateFilterTest2")
|
||||
|
||||
submit alice do
|
||||
create DummyTemplateWeDontSubscribeFor with
|
||||
party1 = alice
|
||||
party2 = bob
|
||||
submit p2 do
|
||||
createCmd DummyTemplateWeDontSubscribeFor with
|
||||
party1 = p2
|
||||
party2 = p1
|
||||
|
||||
-- Alice offers Bob room at Blaha Lujza Square, Budapest
|
||||
offer <- submit alice do
|
||||
create RightOfUseOffer with
|
||||
landlord = alice
|
||||
tenant = bob
|
||||
-- TemplateFilterTest2 offers TemplateFilterTest1 room at Blaha Lujza Square, Budapest
|
||||
offer <- submit p2 do
|
||||
createCmd RightOfUseOffer with
|
||||
landlord = p2
|
||||
tenant = p1
|
||||
address = "Blaha Lujza Square, Budapest"
|
||||
expirationDate = date 2020 Jan 1
|
||||
|
||||
-- Bob accepts the offer, which creates a RightOfUseAgreement
|
||||
submit bob do
|
||||
exercise offer Accept
|
||||
-- TemplateFilterTest1 accepts the offer, which creates a RightOfUseAgreement
|
||||
submit p1 do
|
||||
exerciseCmd offer Accept
|
||||
|
@ -6,10 +6,10 @@ package com.daml.extractor
|
||||
import java.io.File
|
||||
|
||||
import com.daml.bazeltools.BazelRunfiles._
|
||||
import com.daml.extractor.services.ExtractorFixture
|
||||
import com.daml.extractor.services.ExtractorFixtureAroundAll
|
||||
import com.daml.grpc.{GrpcException, GrpcStatus}
|
||||
import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll
|
||||
import com.daml.testing.postgresql.PostgresAroundEach
|
||||
import com.daml.testing.postgresql.PostgresAroundAll
|
||||
import com.daml.timer.RetryStrategy
|
||||
import io.grpc.Status
|
||||
import org.scalatest._
|
||||
@ -21,9 +21,9 @@ import scala.concurrent.Future
|
||||
class VeryLargeArchiveSpec
|
||||
extends AsyncFlatSpec
|
||||
with Suite
|
||||
with PostgresAroundEach
|
||||
with PostgresAroundAll
|
||||
with SuiteResourceManagementAroundAll
|
||||
with ExtractorFixture
|
||||
with ExtractorFixtureAroundAll
|
||||
with Matchers
|
||||
with Inside {
|
||||
override protected def darFile = new File(rlocation("extractor/VeryLargeArchive.dar"))
|
||||
@ -50,11 +50,11 @@ class VeryLargeArchiveSpec
|
||||
// future editors of this test should not feel obliged to synthesize a failure
|
||||
// if the system design has really changed so failures of this nature cannot
|
||||
// happen.
|
||||
val failMB = 1
|
||||
val successMB = 10
|
||||
val failBytes = 1024 // 1 KB
|
||||
val successBytes = 10 * 1024 * 1024 // 10 MB
|
||||
|
||||
s"${failMB}MiB" should "fail" in {
|
||||
runWithInboundLimit(failMB * 1024 * 1024) {
|
||||
s"running with a limit of ${failBytes}B" should "fail" in {
|
||||
runWithInboundLimit(failBytes) {
|
||||
fail("shouldn't successfully run")
|
||||
}.recover {
|
||||
case RetryStrategy.FailedRetryException(
|
||||
@ -64,8 +64,8 @@ class VeryLargeArchiveSpec
|
||||
}
|
||||
}
|
||||
|
||||
s"${successMB}MiB" should "succeed" in {
|
||||
runWithInboundLimit(successMB * 1024 * 1024) {
|
||||
s"running with a limit of ${successBytes}B" should "succeed" in {
|
||||
runWithInboundLimit(successBytes) {
|
||||
succeed
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ import com.daml.ledger.client.services.commands.SynchronousCommandClient
|
||||
import com.daml.ledger.service.LedgerReader.PackageStore
|
||||
import com.daml.lf.data.Ref.Party
|
||||
import com.daml.platform.sandbox.SandboxRequiringAuthorization
|
||||
import com.daml.platform.sandbox.services.{SandboxFixture, TestCommands}
|
||||
import com.daml.platform.sandbox.services.TestCommands
|
||||
import com.daml.platform.sandboxnext.SandboxNextFixture
|
||||
import com.daml.timer.Delayed
|
||||
import org.scalatest.flatspec.AsyncFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
@ -36,7 +37,7 @@ import scala.util.{Failure, Success}
|
||||
|
||||
final class AuthSpec
|
||||
extends AsyncFlatSpec
|
||||
with SandboxFixture
|
||||
with SandboxNextFixture
|
||||
with SandboxRequiringAuthorization
|
||||
with SuiteResourceManagementAroundAll
|
||||
with Matchers
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class BasicPrimitiveTypesSpec
|
||||
@ -25,9 +26,13 @@ class BasicPrimitiveTypesSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/PrimitiveTypes.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("PrimitiveTypes:primitives")
|
||||
override protected val initScript = Some("PrimitiveTypes:primitives")
|
||||
|
||||
override protected val parties = NonEmptyList("Primitives")
|
||||
|
||||
private val party: String = parties.head
|
||||
|
||||
"Contracts" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,7 +44,7 @@ class BasicPrimitiveTypesSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Simple values",
|
||||
"int_field" : 5,
|
||||
@ -48,12 +53,12 @@ class BasicPrimitiveTypesSpec
|
||||
"numeric37_field" : "0.25",
|
||||
"text_field" : "Hey",
|
||||
"bool_field" : true,
|
||||
"party_field" : "Bob",
|
||||
"party_field" : "$party",
|
||||
"date_field" : "2020-02-22",
|
||||
"time_field" : "2020-02-22T12:13:14Z"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Positive extremes",
|
||||
"int_field" : 9223372036854775807,
|
||||
@ -62,12 +67,12 @@ class BasicPrimitiveTypesSpec
|
||||
"numeric37_field" : "9.9999999999999999999999999999999999999",
|
||||
"text_field" : "Hey",
|
||||
"bool_field" : true,
|
||||
"party_field" : "Bob",
|
||||
"party_field" : "$party",
|
||||
"date_field" : "9999-12-31",
|
||||
"time_field" : "9999-12-31T23:59:59Z"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Negative extremes",
|
||||
"int_field" : -9223372036854775808,
|
||||
@ -76,7 +81,7 @@ class BasicPrimitiveTypesSpec
|
||||
"numeric37_field" : "-9.9999999999999999999999999999999999999",
|
||||
"text_field" : "Hey",
|
||||
"bool_field" : true,
|
||||
"party_field" : "Bob",
|
||||
"party_field" : "$party",
|
||||
"date_field" : "0001-01-01",
|
||||
"time_field" : "0001-01-01T00:00:00Z"
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest.{Inside, Suite}
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class EnumSpec
|
||||
@ -25,9 +26,13 @@ class EnumSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation(com.daml.lf.archive.testing.TestDar.fileName))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("EnumMod:createContracts")
|
||||
override protected val initScript: Option[String] = Some("EnumMod:createContracts")
|
||||
|
||||
override protected val parties: NonEmptyList[String] = NonEmptyList("EnumMod")
|
||||
|
||||
private val party = parties.head
|
||||
|
||||
"Enum" should "be extracted" in {
|
||||
getContracts should have length 3
|
||||
@ -38,17 +43,17 @@ class EnumSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""{
|
||||
s"""{
|
||||
"x" : "Red",
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}""",
|
||||
"""{
|
||||
s"""{
|
||||
"x" : "Green",
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}""",
|
||||
"""{
|
||||
s"""{
|
||||
"x" : "Blue",
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}""",
|
||||
).traverse(parse)
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class GenMapSpec
|
||||
@ -25,10 +26,13 @@ class GenMapSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile =
|
||||
new File(rlocation(com.daml.lf.archive.testing.TestDar.fileName))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("GenMapMod:createContracts")
|
||||
override protected val initScript: Option[String] = Some("GenMapMod:createContracts")
|
||||
|
||||
override protected val parties = NonEmptyList("GenMapMod")
|
||||
|
||||
private val party = parties.head
|
||||
|
||||
"Lists" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,37 +43,37 @@ class GenMapSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"x" : [],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"x" : [
|
||||
[ { "fst" : 1, "snd" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
[ { "_1" : 1, "_2" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"x" : [
|
||||
[ { "fst" : -2, "snd" : "-2.2222222222" }, { "tag" : "Right", "value" : "1.1111111111" } ],
|
||||
[ { "fst" : 1, "snd" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
[ { "_1" : -2, "_2" : "-2.2222222222" }, { "tag" : "Right", "value" : "1.1111111111" } ],
|
||||
[ { "_1" : 1, "_2" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"x" : [
|
||||
[ { "fst" : -3, "snd" : "-3333333333333333333333333333.0" }, { "tag" : "Right", "value" : "-2.2222222222" } ],
|
||||
[ { "fst" : -2, "snd" : "-2.2222222222" }, { "tag" : "Right", "value" : "1.1111111111" } ],
|
||||
[ { "fst" : 1, "snd" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
[ { "_1" : -3, "_2" : "-3333333333333333333333333333.0" }, { "tag" : "Right", "value" : "-2.2222222222" } ],
|
||||
[ { "_1" : -2, "_2" : "-2.2222222222" }, { "tag" : "Right", "value" : "1.1111111111" } ],
|
||||
[ { "_1" : 1, "_2" : "1.0" }, { "tag" : "Left", "value" : 0 } ]
|
||||
],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
).traverse(parse)
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest.{Inside, Suite}
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class ListsSpec
|
||||
@ -25,9 +26,13 @@ class ListsSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/PrimitiveTypes.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("PrimitiveTypes:lists")
|
||||
override protected val initScript = Some("PrimitiveTypes:lists")
|
||||
|
||||
override protected val parties = NonEmptyList("Lists")
|
||||
|
||||
private val party: String = parties.head
|
||||
|
||||
"Lists" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,20 +44,20 @@ class ListsSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Empty lists",
|
||||
"int_list" : [],
|
||||
"text_list" : [],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Non-empty lists",
|
||||
"int_list" : [1, 2, 3, 4, 5],
|
||||
"text_list" : ["foo", "bar", "baz"],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
).traverse(parse)
|
||||
|
@ -35,14 +35,11 @@ class MultiPartySpec
|
||||
with Matchers
|
||||
with ScalaCheckDrivenPropertyChecks {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/RecordsAndVariants.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("RecordsAndVariants:multiParty")
|
||||
override protected val initScript = Some("RecordsAndVariants:multiParty")
|
||||
|
||||
override def configureExtractor(ec: ExtractorConfig): ExtractorConfig = {
|
||||
val ec2 = super.configureExtractor(ec)
|
||||
ec2.copy(parties = OneAnd(Party assertFromString "Alice", ec2.parties.toList))
|
||||
}
|
||||
override protected val parties = NonEmptyList(1, 2).map(n => s"MultiParty$n")
|
||||
|
||||
private[this] implicit def partyArb: Arbitrary[Party] = Arbitrary(partyGen)
|
||||
private[this] val readParties = implicitly[scopt.Read[ExtractorConfig.Parties]]
|
||||
|
@ -6,7 +6,6 @@ package com.daml.extractor
|
||||
import java.io.File
|
||||
|
||||
import com.daml.bazeltools.BazelRunfiles._
|
||||
import com.daml.lf.data.Ref.Party
|
||||
import com.daml.extractor.config.{ExtractorConfig, TemplateConfig}
|
||||
import com.daml.extractor.services.ExtractorFixtureAroundAll
|
||||
import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll
|
||||
@ -14,7 +13,7 @@ import com.daml.testing.postgresql.PostgresAroundAll
|
||||
import org.scalatest.{Inside, Suite}
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.OneAnd
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
class MultiPartyTemplateSubscriptionSpec
|
||||
extends AnyFlatSpec
|
||||
@ -25,21 +24,19 @@ class MultiPartyTemplateSubscriptionSpec
|
||||
with Matchers
|
||||
with Inside {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/TransactionExample.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("TransactionExample:templateFilterTest")
|
||||
override protected val initScript: Option[String] = Some("TransactionExample:templateFilterTest")
|
||||
|
||||
private final val alice = Party assertFromString "Alice"
|
||||
private final val bob = Party assertFromString "Bob"
|
||||
override protected val parties = NonEmptyList(1, 2).map(n => s"TemplateFilterTest$n")
|
||||
|
||||
override def configureExtractor(ec: ExtractorConfig): ExtractorConfig = {
|
||||
val ec2 = super.configureExtractor(ec)
|
||||
ec2.copy(
|
||||
parties = OneAnd(alice, List(bob)),
|
||||
templateConfigs = Set(
|
||||
TemplateConfig("TransactionExample", "RightOfUseOffer"),
|
||||
TemplateConfig("TransactionExample", "RightOfUseAgreement"),
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class OptionalSpec
|
||||
@ -25,9 +26,13 @@ class OptionalSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/PrimitiveTypes.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("PrimitiveTypes:optionals")
|
||||
override protected val initScript = Some("PrimitiveTypes:optionals")
|
||||
|
||||
override protected val parties = NonEmptyList("Optionals")
|
||||
|
||||
private val party: String = parties.head
|
||||
|
||||
"Optionals" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,28 +44,28 @@ class OptionalSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Nones",
|
||||
"optional" : null,
|
||||
"deep_optional" : null,
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Somes",
|
||||
"optional" : "foo",
|
||||
"deep_optional" : ["foo"],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Some None",
|
||||
"optional" : "foo",
|
||||
"deep_optional" : [],
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
).traverse(parse)
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest.{Inside, Suite}
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class RecordsAndVariantsSpec
|
||||
@ -25,9 +26,13 @@ class RecordsAndVariantsSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/RecordsAndVariants.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("RecordsAndVariants:suite")
|
||||
override protected val initScript = Some("RecordsAndVariants:suite")
|
||||
|
||||
override protected val parties = NonEmptyList("Suite")
|
||||
|
||||
private val party: String = parties.head
|
||||
|
||||
"Contracts" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,9 +44,9 @@ class RecordsAndVariantsSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"party" : "Bob",
|
||||
"party" : "$party",
|
||||
"reference" : "All-in-one",
|
||||
"deepNested" : {
|
||||
"tag" : "MaybeRecRecordABRight",
|
||||
|
@ -6,7 +6,6 @@ package com.daml.extractor
|
||||
import java.io.File
|
||||
|
||||
import com.daml.bazeltools.BazelRunfiles._
|
||||
import com.daml.lf.data.Ref.Party
|
||||
import com.daml.extractor.config.{ExtractorConfig, TemplateConfig}
|
||||
import com.daml.extractor.services.ExtractorFixtureAroundAll
|
||||
import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll
|
||||
@ -14,7 +13,7 @@ import com.daml.testing.postgresql.PostgresAroundAll
|
||||
import org.scalatest.{Inside, Suite}
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.OneAnd
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
class TemplateSubscriptionSpec
|
||||
extends AnyFlatSpec
|
||||
@ -25,15 +24,16 @@ class TemplateSubscriptionSpec
|
||||
with Matchers
|
||||
with Inside {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/TransactionExample.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("TransactionExample:templateFilterTest")
|
||||
override protected val initScript: Option[String] = Some("TransactionExample:templateFilterTest")
|
||||
|
||||
override protected val parties = NonEmptyList("TemplateFilterTest2")
|
||||
|
||||
override def configureExtractor(ec: ExtractorConfig): ExtractorConfig = {
|
||||
val ec2 = super.configureExtractor(ec)
|
||||
ec2.copy(
|
||||
parties = OneAnd(Party assertFromString "Bob", Nil),
|
||||
templateConfigs = Set(TemplateConfig("TransactionExample", "RightOfUseAgreement")),
|
||||
templateConfigs = Set(TemplateConfig("TransactionExample", "RightOfUseAgreement"))
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import io.circe.parser._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
import scalaz.Scalaz._
|
||||
|
||||
class TextMapsSpec
|
||||
@ -25,9 +26,13 @@ class TextMapsSpec
|
||||
with Matchers
|
||||
with CustomMatchers {
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/PrimitiveTypes.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("PrimitiveTypes:textMaps")
|
||||
override protected val initScript = Some("PrimitiveTypes:textMaps")
|
||||
|
||||
override protected val parties = NonEmptyList("TextMaps")
|
||||
|
||||
private val party: String = parties.head
|
||||
|
||||
"TextMaps" should "be extracted" in {
|
||||
val contracts = getContracts
|
||||
@ -39,15 +44,15 @@ class TextMapsSpec
|
||||
val contractsJson = getContracts.map(_.create_arguments)
|
||||
|
||||
val expected = List(
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Empty maps",
|
||||
"map" : {},
|
||||
"deep_map" : {},
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
"""
|
||||
s"""
|
||||
{
|
||||
"reference" : "Non-empty maps",
|
||||
"map" : { "1" : 1 ,
|
||||
@ -56,7 +61,7 @@ class TextMapsSpec
|
||||
"4" : 4 ,
|
||||
"5" : 5 },
|
||||
"deep_map" : {},
|
||||
"party" : "Bob"
|
||||
"party" : "$party"
|
||||
}
|
||||
""",
|
||||
).traverse(parse)
|
||||
|
@ -17,6 +17,7 @@ import io.circe.syntax._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
@ -33,9 +34,11 @@ class TransactionMultiTableSpec
|
||||
|
||||
import services.Types._
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/TransactionExample.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("TransactionExample:example")
|
||||
override protected val initScript = Some("TransactionExample:example")
|
||||
|
||||
override protected def parties: NonEmptyList[String] = NonEmptyList("Example1")
|
||||
|
||||
override protected def outputFormat: String = "multi-table"
|
||||
|
||||
@ -49,14 +52,13 @@ class TransactionMultiTableSpec
|
||||
case TransactionResult(
|
||||
transaction_id,
|
||||
seq,
|
||||
workflow_id,
|
||||
_, // Daml Script leaves the workflow identifier empty
|
||||
effective_at,
|
||||
extracted_at,
|
||||
ledger_offset,
|
||||
) =>
|
||||
transaction_id should not be empty
|
||||
seq should be >= 1
|
||||
workflow_id should not be empty
|
||||
effective_at should be(new Timestamp(0L))
|
||||
extracted_at should beWithin(30.seconds)(Timestamp.from(Instant.now()))
|
||||
ledger_offset should not be empty
|
||||
@ -68,7 +70,6 @@ class TransactionMultiTableSpec
|
||||
val transactions = getTransactions
|
||||
|
||||
transactions.map(_.transaction_id).toSet should have size 3
|
||||
transactions.map(_.workflow_id).toSet should have size 3
|
||||
transactions.map(_.seq).toSet should have size 3
|
||||
transactions.map(_.ledger_offset).toSet should have size 3
|
||||
}
|
||||
@ -77,7 +78,7 @@ class TransactionMultiTableSpec
|
||||
getExercises should have length 2
|
||||
}
|
||||
|
||||
"All the data" should "represent what went down in the scenario" in {
|
||||
"All the data" should "represent what went down in the script" in {
|
||||
// `transaction1` created `contract1`, then
|
||||
// `transaction2` created `exercise`, which archived `contract1` and resulted `contract2`
|
||||
|
||||
|
@ -16,6 +16,7 @@ import io.circe.syntax._
|
||||
import org.scalatest._
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
@ -32,9 +33,11 @@ class TransactionSingleTableSpec
|
||||
|
||||
import services.Types._
|
||||
|
||||
override protected def darFile = new File(rlocation("extractor/TransactionExample.dar"))
|
||||
override protected def darFile = new File(rlocation("extractor/test.dar"))
|
||||
|
||||
override def scenario: Option[String] = Some("TransactionExample:example")
|
||||
override protected val initScript = Some("TransactionExample:example")
|
||||
|
||||
override protected val parties = NonEmptyList("Example1")
|
||||
|
||||
"Transactions" should "be extracted" in {
|
||||
getTransactions should have length 3
|
||||
@ -46,14 +49,13 @@ class TransactionSingleTableSpec
|
||||
case TransactionResult(
|
||||
transaction_id,
|
||||
seq,
|
||||
workflow_id,
|
||||
_,
|
||||
effective_at,
|
||||
extracted_at,
|
||||
ledger_offset,
|
||||
) =>
|
||||
transaction_id should not be empty
|
||||
seq should be >= 1
|
||||
workflow_id should not be empty
|
||||
effective_at should be(new Timestamp(0L))
|
||||
extracted_at should beWithin(30.seconds)(Timestamp.from(Instant.now()))
|
||||
ledger_offset should not be empty
|
||||
@ -65,7 +67,6 @@ class TransactionSingleTableSpec
|
||||
val transactions = getTransactions
|
||||
|
||||
transactions.map(_.transaction_id).toSet should have size 3
|
||||
transactions.map(_.workflow_id).toSet should have size 3
|
||||
transactions.map(_.seq).toSet should have size 3
|
||||
transactions.map(_.ledger_offset).toSet should have size 3
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user