Skip to content

Commit

Permalink
Fix trigger compat test for canton sandbox (#12549)
Browse files Browse the repository at this point in the history
This fixes the timeout on trigger compat tests for the new sandbox (with LF >= 1.14).

The issue was that the trigger was "readAs"-ing with a party that
doesn't exist, since party ids aren't predictable with the new sandbox.

The solution is to allocate the Alice party ahead of time, and then
pass the allocated party in when calling `daml trigger`.

changelog_begin
changelog_end
  • Loading branch information
sofiafaro-da authored Jan 24, 2022
1 parent 3ea8ade commit 8692d80
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
13 changes: 12 additions & 1 deletion compatibility/bazel_tools/daml_trigger/daml_trigger.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,21 @@ canonicalize_rlocation() {{
runner=$$(canonicalize_rlocation $(rootpath {runner}))
# Cleanup the trigger runner process but maintain the script runner exit code.
trap 'status=$$?; kill -TERM $$PID; wait $$PID; exit $$status' INT TERM
SCRIPTOUTPUT=$$(mktemp -d)
$$runner script \\
--ledger-host localhost \\
--ledger-port 6865 \\
--wall-clock-time \\
--dar $$(canonicalize_rlocation $(rootpath {dar})) \\
--script-name TestScript:allocateAlice \\
--output-file $$SCRIPTOUTPUT/alice.json
ALICE=$$(cat $$SCRIPTOUTPUT/alice.json | sed 's/"//g')
rm -rf $$SCRIPTOUTPUT
$$runner trigger \\
--ledger-host localhost \\
--ledger-port 6865 \\
--ledger-party Alice \\
--ledger-party $$ALICE \\
--wall-clock-time \\
--dar $$(canonicalize_rlocation $(rootpath {dar})) \\
--trigger-name CopyTrigger:copyTrigger &
Expand Down
18 changes: 16 additions & 2 deletions compatibility/bazel_tools/daml_trigger/example/src/TestScript.daml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@ import DA.Assert
import DA.Time
import Daml.Script

allocateAlice : Script Party
allocateAlice = do
debug "Creating Alice ..."
alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
debug alice
debug "... done"
pure alice

test : Script ()
test = do
debug "Creating parties ..."
alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
debug "Searching for Alice ..."
let isAlice x = displayName x == Some "Alice"
Some aliceDetails <- find isAlice <$> listKnownParties
let alice = party aliceDetails
debug alice
debug "... done"

debug "Creating Bob ..."
bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
debug alice
debug bob
Expand Down

0 comments on commit 8692d80

Please sign in to comment.