Skip to content

Commit

Permalink
make srcloc test less fragile (digital-asset#14680)
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end
  • Loading branch information
nickchapman-da authored Aug 10, 2022
1 parent b73e852 commit 6b80715
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions daml-script/test/daml/ScriptTest.daml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import DA.Stack
import DA.Time
import Daml.Script

-- `mySubmit` and `stackTrace` are used when testing srcloc within a stack-trace.
-- If these functions are relocated within this file, the expected locations
-- in the "stack trace" test in AbstractFuncIT.scala will need to be updated.
-- By having these two definition at the head of this file, we are less likely to
-- have to adapt the expected src-locs as new Daml gets added.
mySubmit : HasCallStack => Party -> Commands a -> Script a -- line 22
mySubmit p cmds = submit p cmds

stackTrace : Script ()
stackTrace = do
p <- allocateParty "p" -- line 27
mySubmit p $ createAndExerciseCmd (C p 42) ShouldFail

template T
with
p1 : Party
Expand Down Expand Up @@ -389,14 +402,6 @@ tree = do
fromAnyTemplate c3.argument === Some (MessageSize p1)
pure ()

mySubmit : HasCallStack => Party -> Commands a -> Script a
mySubmit p cmds = submit p cmds

stackTrace : Script ()
stackTrace = do
p <- allocateParty "p"
mySubmit p $ createAndExerciseCmd (C p 42) ShouldFail

-- Create a contract only visible to one party to test readAs
jsonMultiPartySubmissionCreateSingle : Party -> Script (ContractId MultiPartyContract)
jsonMultiPartySubmissionCreateSingle p = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ abstract class AbstractFuncIT
end,
)
e.cmd.stackTrace shouldBe StackTrace(
Vector(loc("submit", (392, 18), (392, 31)), loc("mySubmit", (397, 2), (397, 12)))
Vector(loc("submit", (22, 18), (22, 31)), loc("mySubmit", (27, 2), (27, 12)))
)
}
}
Expand Down

0 comments on commit 6b80715

Please sign in to comment.