Commit Graph

4593 Commits

Author SHA1 Message Date
Remy
ec7d53eb59
LF-REPL: proper dev-mode (#6453)
We add a flag in LF-REPL to prevent usage of DAML-LF Dev and dev value/transaction version.

This PR advances #5164.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-23 17:08:37 +02:00
Moritz Kiefer
75eb554841
Prefix IDE include paths with project root (#6463)
* Prefix IDE include paths with project root

As described in #6174, `--include` is broken pretty badly in the IDE
atm. LSP works based on absolute file paths so if you have a relative
include dir you run into two issues:

1. You end up with two GHC sessions e.g, one for `/multidir` and one
   for `.`. That results in fun type errors like “Couldn’t match expected
   type `Text` with actual type `Text`”.
2. The same file can end up being represented twice. Apart from being
   horribly inefficient, this breaks as soon as we try to build a DALF
   since the function for constructing that (correctly) explodes when
   there are two files with the same module name.

This change does not break `daml build` since the project root is
relative there.

fixes #6174

changelog_begin

- [DAML Studio] Fix an issue where use of the `--include` option
  resulted in various confusing type errors. See
  https://github.com/digital-asset/daml/issues/6174

changelog_end

* Stop wasting my time hlint

changelog_begin
changelog_end
2020-06-23 16:58:14 +02:00
Leonid Rozenberg
ea344518e9
Group context and hook creation so that it is exportable. (#6451)
CHANGELOG_BEGIN
Export Ledger context and hook creation to enable nested interaction,
with different parties or different ledgers, within one React app.
CHANGELOG_END

* Group context and hook creation so that it is exportable.

* Use undefined as default state to avoid cast

* Word choice

* Document new functions

* Revert commit to build script

* Test nesting of contexts

* Document extra feature in README

* Reorganize code to preserve individual function documentation.

* Correct names to starting with lowercase in build.

* Single quote imports and spacing style

* Add copyright notice

* Spacing around useReload

* Use a good variable name

* Do not export by default

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-06-23 10:45:19 -04:00
Stefano Baghino
6bab178195
Improve explanation of offsets on the protobuf docs (#6465)
* Improve explanation of offsets on the protobuf docs

changelog_begin
[Documentation] More detailed explanation of how to use (and not use) offsets in the Ledger API reference docs
changelog_end

* Address https://github.com/digital-asset/daml/pull/6465#discussion_r444200217
2020-06-23 14:11:07 +00:00
Shayne Fletcher
4d896bc3bd
Update ghc-lib, da-ghc-master-8.8.1 (#6460)
changelog_begin
changelog_end
2020-06-23 08:29:16 -04:00
Gary Verhaegen
fc5fa4c213
granular test selection, take 3 (#6458)
This is the final bit extracted from #6314. This PR adds the capability
to filter individual test cases (for either inclusion or exclusion)
while being completely backwards compatible. It also introduces a new
cli option, `--list-all`, to list all test cases, keeping the behaviour
of the existing `--list` option unchanged, i.e. only print test suites.

Unlike #6314, this is still building upon the idea of defining test
suites as maps, preserving the known-good order of tests and thereby not
introducing flakiness into our builds.

CHANGELOG_BEGIN

- [Ledger API Test Tool] ``--exclude`` and ``--include`` now match the
  full test name as a prefix, rather than just suite names. Test name is
built by combining the suite name with a test identifier, so this change
should be fully backwards compatible. Run with ``--list-all`` to list
all tests (as opposed to just the test suites with ``--list``).

CHANGELOG_END
2020-06-23 14:27:36 +02:00
Oliver Seeliger
fa652e8fce
Revert "Multinode ledgers reflect whether party is non-local (#6382)" (#6461)
This reverts commit 004d2800f0.

CHANGELOG_BEGIN
NOTE: the following line needs to be removed from the change log:
- [Ledger Api] The Package Management Service's `ListKnownParties` response's `PartyDetails` now
  properly reflects where a party is non-local on distributed, multi-participant ledgers that
  expose parties to remote participants.

CHANGELOG_END
2020-06-23 09:44:22 +00:00
Oliver Seeliger
b68333c29e
Reenable multi-node ledger-api-test-tool conformance test against Canton (#6449)
Canton test suite had been disabled shortly before DAML 1.0. Reenabling
those tests that have been running flake-free in Canton for over a month.

In addition:
- Switched test selection from --include to --exclude so that we see how newly
  added suites run multi-node.
- Switched Canton from in-memory to h2. Also adopted other config settings in
  canton.conf from how tests are invoked in canton continuous integration.
- Increased number of participants from 2 to 4.
- Upgraded Canton from 0.11.0 to 0.15.0

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-23 09:06:28 +02:00
Gary Verhaegen
7d3dae4b1f
update perf-sha (#6457)
CHANGELOG_BEGIN
CHANGELOG_END
2020-06-22 18:46:19 +02:00
Gary Verhaegen
d48efd35c7
exit on failed benchmark (#6448)
At the moment, JMH seems happy to just swallow exceptions and consider
the benchmark done, which makes it produce inaccurate speed results and
lets errors slip through to master. This makes unexpected errors in the
benchmark a hard stop.

This is not a complete solution: ideally there would be a way to just
tell jmh to abort on uncaught exceptions. However, I don't seem to be
able to find any relevant documentation on how to do that.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-22 18:20:05 +02:00
Martin Huschenbett
953b3c08fe
Save the expression in the CollectAuthority benchmark (#6454)
During some refactoring we forgot to save the initial expression to
evaluate for the machine during benchmarking. This PR fixes the issue.
It also make the error messages a bit more descriptive so that we can
actually debug this.

A test to make sure issues like this one don't get through CI again is
worked on by @gary-verhaegen-da in a separate PR.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-22 16:03:40 +00:00
Moritz Kiefer
3e099b9633
Bump compat versions (#6452)
Following the changes to exclusions, this is purely running the
update-versions script so we are now at the point where at least a PR
bot that makes these PRs is feasible.

changelog_begin
changelog_end
2020-06-22 15:16:50 +00:00
Moritz Kiefer
7cc5a02152
Further simplify test tool exclusions (#6450)
After adding ranges for sandbox versions, this PR now also adds ranges
for test tool versions. This is particularly useful since this gets us
to the point where adding a new version usually (unless we’ve actually
broken compatibility more than before) does not require any change in
exclusions.

I’ve also cleaned up exclusions that only affect snapshots. While I’ve
previously argued against that since that seemed more annoying to
maintain, the list is small enough now that I’m no longer worried
about that.

changelog_begin
changelog_end
2020-06-22 17:01:09 +02:00
Oliver Seeliger
004d2800f0
Multinode ledgers reflect whether party is non-local (#6382)
* Multinode ledgers reflect whether party is non-local

Closes #2026

The new `PartyManagement` test `PMListKnowPartiesIsLocal` checks whether any known non-local
party is either not known or marked with `PartyDetails.isLocal == false`. This check is not
run for single-participant ledger setups. The test also verifies that `PartyDetails.displayName`
is preserved.

CHANGELOG_BEGIN
- [Ledger Api] The Package Management Service's `ListKnownParties` response's `PartyDetails` now
  properly reflects where a party is non-local on distributed, multi-participant ledgers that
  expose parties to remote participants.
CHANGELOG_END

* Review feedback from Stefano and sql fix from Ratko

* Simplify #6382 (#6413)

* Simplify https://github.com/digital-asset/daml/pull/6382

changelog_begin
changelog_end

* Test fixes switching alpha/beta and alice/bob

* STRANGENESS / DONT MERGE: getParties don't seem to become available

when run against statically created parties until a transaction is run:

when testing

bazel test //ledger/sandbox:next-conformance-test-wall-clock-time-postgresql

Co-authored-by: Oliver Seeliger <oliver.seeliger@digitalasset.com>

* More review feedback

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-06-22 15:22:04 +02:00
Gary Verhaegen
f101085bc8
api test tool: remove suite name duplication (#6441)
This is the last refactoring extracted from #6314. In #6314, this was
done by turning the `Tests.Tests` type into a Seq (instead of a Map),
which changed the order in which tests ran, thereby introducing
flakiness. This approach, however, still removes the source-level
duplication, but keeps the same Maps at runtime. This makes it a true
refactoring, and thus does not introduce flakiness.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-22 13:15:48 +02:00
Martin Huschenbett
5e97019894
damlc tests: Add suppressed test in Iou12 back (#6446)
The suppressed test works just fine as is. This must be something
pre-historic.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-22 10:57:15 +00:00
Moritz Kiefer
cfb4c182a5
Consistently display stakeholders for key visibility errors (#6434)
* Consistently display stakeholders for key visibility errors

fixes #6404

As pointed out by Bernhard in #6404, the previous behavior was pretty
weird. If the committer was only a divulgee, we only displayed
stakeholders. If the committer was neither a stakeholder nor a
divulgee, we displayed stakeholders + parties the contract has been
divulged to. Given that only stakeholders can do lookups it makes much
more sense to display them consistently which is what this PR
achieves. I’ve also renamed “disclosed to” to “stakeholders” to make
it very explicit what is shown there.

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>

* fmt

changelog_begin
changelog_end

* lalala

changelog_begin
changelog_end

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
2020-06-22 10:22:37 +00:00
Moritz Kiefer
038388cdb7
Fix handling of non-visibile contract keys in scenario runner (#6433)
fixes #6403

I am not entirely sure why I thought that using `missingWith` makes
sense here but it clearly doesn’t make sense and resulted in a pretty
bad bug where a transaction both succeeded via `submit` as well as
failed via `submitMustFail` which is clearly the wrong thing to do.

This PR fixes this issue and introduces a `notVisibleWith` function
that does the right thing. I’ve also added some comments and an extra
assertion to clarify things a bit.

changelog_begin
changelog_end
2020-06-22 10:20:24 +02:00
Shayne Fletcher
333bf0471d
Support external anchors (#6386)
* support external anchors

changelog_begin
- `daml docs` now supports an `--input-anchor` argument specifying the
path to a database of external anchors
changelog_end

* Add daml-base-anchors.json to the damlc-dist target
2020-06-21 19:44:36 -04:00
Gary Verhaegen
2923048935
remove purge_old_agents (#6439)
This script was supposed to remove old agents from the Azure Pipelines
UI. It may have been useful at some time (notably, when we used
ephemeral instances, they did not necessarily get to run their shutdown
script), but as it stands now, it's broken. The output from that step
ends in:

```
error: 2 derivations need to be built, but neither local builds ('--max-jobs') nor remote builds ('--builders') are enabled
```

after listing the nix packages it would build. Furthermore, it does not
seem to be useful as I have not seen any spurious entry in the agents
list on Azure since we switched to permanent nodes, on either the Linux
or Windows side (and this would only run on Linux, if it ran).

I'm also not convinced it ever ran, as I used to see a lot of spurious
machines on both Linux and Windows when we did use ephemeral instances.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-20 17:37:24 +02:00
Gary Verhaegen
d839acdbce
increase nix cache retention time (#6437)
The nix cache is currently only 3.5GB, and GHC takes a long time to
build, so I think the convenience vs. cost tradeoff is in favour of
keeping things for a bit longer.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-20 16:25:02 +02:00
Shayne Fletcher
cec2693dc7
enable -Wunused-matches (#6423)
changelog_begin
changelog_end
2020-06-19 19:35:10 +00:00
Rohan Jacob-Rao
b10bfa1ba7
Trigger service: Write packages to database if we have one (#6424)
This is needed to recover state after the service shuts down or crashes.
We add a method to the RunningTriggerDao to persistPackages. This only
does something in the case of a DbTriggerDao. In any case the Server
keeps a package map in memory as it's required to construct a trigger runner.
Uploads of existing packages is considered harmless.

changelog_begin
changelog_end
2020-06-19 13:49:49 -04:00
Samir Talwar
a749928172
caching: Wait for the cache to evict some values in tests. (#6438)
* caching: Wait for the cache to evict some values in tests.

Windows, especially, might not do it the first time. Not sure why;
caching is weird.

CHANGELOG_BEGIN
CHANGELOG_END

* caching: Pull out duplicate tests into CacheEvictionSpecBase.
2020-06-19 19:30:58 +02:00
Moritz Kiefer
8ee7de78ef
Only print diagnostics from integration tests on failures (#6436)
This makes the tests super noisy and makes it hard to spot the
interesting part.

changelog_begin
changelog_end
2020-06-19 18:13:21 +02:00
Sofia Faro
4d698fc5ed
constant lifting: adjust what gets lifted (#6430)
* Adjust what gets lifted

* dont lift typerep

changelog_begin
changelog_end
2020-06-19 17:09:52 +01:00
Miklos
9dd78fc508
Ledger data export for non-determinism checks (#6418)
CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 17:52:11 +02:00
Gary Verhaegen
e1bfbd6a72
remove jo from dev-env (#6435)
It doesn't seem to be used anywhere. Obviously `git grep jo` returns a
lot of results, so I may have missed something in the noise, but I did a
reasonable effort to look through them.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 15:21:43 +00:00
Samir Talwar
6496ddd903
caching | kvutils | sandbox: Use a size-based cache for LF value translation. (#6432)
* caching: Split caches into new files.

* caching: Rename `Cache.from` to `WeightedCache.from`.

* caching: Move `Configuration` inside `WeightedCache`.

* caching: Add test cases.

* caching: Allow for Caffeine builders to be covariant.

* caching: When instrumenting the Caffeine cache, compose, don't inherit.

* caching: Add a size-based cache.

* caching: Extract out common test cases into base classes.

* caching: Use the size-based cache for LF value translation.

CHANGELOG_BEGIN
CHANGELOG_END

* caching: Simplify the eviction tests.

* caching: Increase the encapsulation in CaffeineCache.

* caching: Commas are important.

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-06-19 14:42:40 +00:00
Moritz Kiefer
ec8c209b65
Include sadbonx-classic in compatibility tests (#6399)
Given that sadbonx-classic came back from the dead my initial
reasoning that we don’t have to include it since it will be gone soon
anyway is obsolete. Therefore, this PR adds both the in-memory and
postgresql variant to the ledger-api-test-tool tests. For other tests,
I did not yet create variants for sadbonx-classic. Not sure how
important that is, we can always add it later.

changelog_begin
changelog_end
2020-06-19 15:55:39 +02:00
Rohan Jacob-Rao
78d598ecf3
Trigger service: Improve formation of SQL queries (#6422)
Avoid the use of Fragment.const which interprets raw strings as SQL
queries without any checks. Use the `sql` string interpolation which I
found out does the right thing with Strings and other simple types.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 09:32:27 -04:00
Gert-Jan Bottu
e5c62ecce2
Verification tool bugfix for PR#6101 (#6431)
CHANGELOG_BEGIN
- Bugfix: forward references are inlined in create updates.
CHANGELOG_END
2020-06-19 15:04:59 +02:00
Remy
1b1b4eab2c
Speedy: clean machine builder name (#6427)
* Address comment martin made in #6368

* changelog

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-19 14:58:13 +02:00
Moritz Kiefer
8730555bc6
Clarify docs around getTime (#6425)
changelog_begin
changelog_end
2020-06-19 14:56:53 +02:00
Moritz Kiefer
f5078046e4
Do not expect a specific location in ledger-api-test-tool (#6429)
* Do not expect a specific source location in ledger-api-test-tool

This broke running the ledger-api-test-tool against older ledgers
since the behavior of Speedy has changed slightly.

This PR changes `assertGrpcError` to accept a regex and uses that to
match for a wildcard in place of a specific location. I’ve gone
through the existing calls and added appropriate levels of escaping.

changelog_begin
changelog_end

* Pass an Option[Pattern] to avoid having to convert back to a String

changelog_begin
changelog_end
2020-06-19 14:28:43 +02:00
Rohan Jacob-Rao
0ca1288d9d
Trigger service: Increase server binding timeout (#6421)
To avoid timeouts in CI. Also factor out the implicit val one level
so it is used by both tests and main method.

changelog_begin
changelog_end
2020-06-18 19:54:24 +00:00
Gary Verhaegen
ddd8eec701
remove LedgerSession from LedgerTestSuite constructor (#6414)
This is another refactoring extracted from #6314. This is removing the
`LedgerSession` argument from `LedgerTestSuite`. The goal of this change
is to remove the closures from the `Tests.Tests` type, so it becomes a
plain map of name to test suite, rather than a map of name to
function-that-returns-a-test-suite.

In context, this is another step towards removing the name duplication
that occurs in the `Tests.default` and `Tests.optional` maps. I have
separated this step from the one that actually removes the duplication
because removing the duplication in #6314 was done by turning the maps
into seqs, thereby changing the order in which tests are run, which
caused the flakiness issues I've been investigating over the past week.

This commit does not yet change the order in which tests are run and is
therefore safe from that perspective. It's still a true refactoring.

It's a fairly simple one at that as `LedgerTestSuite` itself never uses
the session, and there was only one subclass that did. The subclass,
`TransactionScaleIT`, only used it to get at one config parameter. In
this PR, that config parameter is instead passed down directly to the
`Tests.default` method.

The other use of the `session` attribute was to extract it from the test
suite in order to pass it to the `run` method of
`LedgerTestSuiteRunner`. This was done right after creating the test
suites and giving them that same session, so we're now skipping that
round trip and just giving the session directly to `run`.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 20:32:46 +02:00
Sofia Faro
f5613785e0
Constant lifting transformation in the LF simplifier. (#6101)
* First draft of constant lifting

changelog_begin
changelog_end

* refactoring

* doing stuff

* run simplifier on template exprs

* remove merge artifact

* Fix ExerciseWithoutActors

* add comments

* fix trace order test

* prefix generated val names with their provenance

* Verification tool bugfix

During the value collection phase, when encountering a record projection on a (yet) undefined value, stop searching this branch instead of throwing an error.

* Bump pattern-match-perf memory limit with cocreature`s blessing

* bump again

* Filter generated identifiers from daml script test runner

changelog_begin
changelog_end

* Fix party literals

* Remove inlineClosedExpr for now.

* Improve comments

* Reset script test locations

* Unhashmap

* disable daml-lf-verify quickstart tests for now

Co-authored-by: Gert-Jan Bottu <gertjan.bottu@kuleuven.be>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-06-18 17:36:28 +00:00
Remy
2a10a124d8
LF: Control transaction version inferrence. (#6365)
CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 19:11:33 +02:00
Rohan Jacob-Rao
5934b22dda
Trigger service: Refactor Server.addDar to take encoded dar (#6395)
Trigger service: Refactor Server.addDar to take encoded dar

This is so we can write the encoded packages to the database if we have
one (without re-encoding them).

changelog_begin
changelog_end
2020-06-18 12:37:43 -04:00
Moritz Kiefer
0a8c1eba4e
Integrate time service into DAML Script (#6417)
This integrates the time service into DAML script thereby covering the
main piece of scenarios that was missing from DAML script.

This PR does two things (they are very related and doing them together
makes it much easier to test):

1. It “fixes” `getTime` to return the ledger time in static mode by
   querying the ledger time service instead of defaulting to the Unix
   epoch which is pretty useless and I would consider the old behavior
   a bug. We keep the old behavior via the JSON API since there is no
   time service.

2. It adds `setTime` to set the ledger time via the time service. This
   is only supported in static time mode (sadbonx and other ledgers do
   not expose the time service in wallclock mode because changing time
   makes it not wallclock) or via the JSON API (no time service).

fixes #6220

changelog_begin

- [DAML Script] DAML Script’s `getTime` now correctly handles time
  changes in static time mode and returns the current time by querying
  the time service rather than defaulting to the Unix epoch. Note that
  when run via the JSON API, it still returns the Unix epoch.

- [DAML Script] Add `setTime` to DAML Script which sets the ledger
  time via the ledger API time service. Note that this is only
  supported when running over gRPC in static time mode.

changelog_end
2020-06-18 18:25:24 +02:00
Remy
86ceeea8d8
LF: shield value versioning in Transaction builder. (#6415)
We want to avoid that code outside LF version is own LF values.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 17:20:47 +02:00
Remy
149bfc89ff
Update LF Perf test SHA (#6416)
CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 14:27:26 +00:00
Remy
5a9e7ebc7c
Speedy: refactor Machine builders (#6368)
In this PR we cleanup the constructor for the speedy Machine.

* We remove the `case`  keyword since `Machine` is a stateful class,
* We replace the pre-existing builders with
  + one generic builder `Machine.apply`,
  + scenario specific builder,

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 15:39:55 +02:00
Gary Verhaegen
aa86a64842
remove temp linux nodes (#6410)
This is the last step of the plan outlined in #6405. As of opening this
PR, "old" nodes are back up, "temp" nodes are disabled at the Azure
level, and there is no job running on either (🤔). In other
words, this can be deployed as soon as it gets a stamp.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 13:20:56 +00:00
Gary Verhaegen
3e0fe58c53
rename test suites to match their names (#6409)
This is extracted from #6314. This is a simple renaming of a few
classes. The goal here is to have the `LedgerTestSuite#name` match the
key currently used in the `Tests.default` and `Tests.optional` maps so
that we can eventually remove that duplication (after the
`LedgerSession` argument is removed so we can actually construct the
`LedgerTestSuite` objects and ask them their name).

Note that `LedgerTestSuite#name` is [already defined][0] as:

```
  val name: String = getClass.getSimpleName
```

In the context of #6314, this is useful to align the existing behaviour
of `--include` with the desired future behaviour of `--exclude`, so we
can use the same names in both. Alternatives could be to remove the
`LedgerTestSuite#name` method and thread the key `String`s through to
the individual tests somehow, or make the `name` field a constructor
argument rather than reconstruct it based on the class name. This
approach of using the class name is the cleanest I could think of.

CHANGELOG_BEGIN
CHANGELOG_END

[0]: d01715bf2f/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuite.scala (L14)
2020-06-18 15:16:12 +02:00
Gary Verhaegen
3f5f907212
api test tool: remove dead code (#6408)
This is extracted from #6314, but actually has nothing to do with it.
This is removing two functions that are never called, as well as a type
that is never constructed (and the one pattern match on it).

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 14:52:11 +02:00
Gary Verhaegen
72f428d8df
macos nodes: add nix redirect (#6406)
See #6400; split out as separate PR so master == reality and we can
track when this is done. @nycnewman please merge this once the change
is deployed.

Note: it has to be deployed before the next restart; nodes will _not_ be
able to boot with the current configuration.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 14:51:25 +02:00
Gary Verhaegen
d01715bf2f
add redirect to nix curl (linux) (#6407)
This is the second PR in the plan outlined in #6405. I have already
disabled the old nodes so no new job will get started there; I will,
however, wait until I've seen a few successful builds on the new nodes
before pulling the plug.

CHANGELOG_BEGIN
CHANGELOG_END
2020-06-18 14:08:21 +02:00
Gary Verhaegen
300895a802
remove ec from LedgerTestSuite (#6387)
`LedgerTestSuite` itself does not do anything with the `ExecutionContext`;
it is only used to provide it as an "ambient" implicit throughout each
test definition. Instead, with this PR, the `ExecutionContext` is
explicitly passed down as an additional argument to the `runTestCase`
closure.

For this not to change the behaviour of the program, we need to be
confident that the `ExecutionContext` is still the same. Let's first
look at how the `ExecutionContext` used to reach a test case. For any
execution of the test tool, there is only one `LedgerTestSuiteRunner`
created [by the main method][0], on which [we call][1] the
`verifyRequirementsAndRun` method. This in turn [calls][2] the `run`
method after checking that the given configuration is valid, and
[that][3] is where the `ExecutionContext` gets created. It is declared
as implicit so it gets picked up by the [`LedgerSession`][4] constructor
[call][5]. This (single) `LedgerSession` then [gets passed][6] to the
[constructor][7] of each individual `LedgerTestSuite`, which [extracts
the `ExecutionContext` from the session][8] to make it available to each
individual test created in the enclosing scope of a subclass when
calling the [`test`][9] method.

With this PR, the `ExecutionContext` is no longer extracted from the
`LedgerSession` in the `LedgerTestSuite` constructor, but is instead
threaded through to the `apply` method of `LedgerTestCase` through the
`run` (different signature) [call][10] for the individual test, which
itself [calls][11] `start`, which then [calls][12] the `apply` method of
`LedgerTestCase`. Because each of these methods (`run` and `start` on
`LedgerTestSuiterunner` and `apply` on `LedgerTestCase`) already
expected an implicit `ExecutionContext`, no change is required on the
`LedgerTestSuiteRunner` side.

A handful of helper functions in various test suites also needed to be
changed to fetch the `ExecutionContext` implicitly from their calling
context rather than capturing it lexically from the enclosing
`LedgerTestSuite`. This is, again, the same `ExecutionContext` it used
to be, but instead of getting it from the `LedgerSession` they get it
from the `LedgerTestCase` closure.

This was originally part of #6314, but despite it being a pure
refactoring, it is quite a large (and somewhat subtle) changeset, so I
believe it is better to review/merge separately.

CHANGELOG_BEGIN
CHANGELOG_END

[0]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala (L125-L136)
[1]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala (L138)
[2]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L155)
[3]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L119)
[4]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerSession.scala (L13-L16)
[5]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L122)
[6]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L123)
[7]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuite.scala (L13)
[8]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuite.scala (L20)
[9]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuite.scala (L22-L32)
[10]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L134)
[11]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L114)
[12]: 53bddb54d7/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/LedgerTestSuiteRunner.scala (L60)
2020-06-18 13:29:56 +02:00