Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up daml script tests #16570

Merged
merged 2 commits into from
Mar 20, 2023
Merged

Clean up daml script tests #16570

merged 2 commits into from
Mar 20, 2023

Conversation

remyhaemmerle-da
Copy link
Collaborator

In this PR:

  • We drop usage of Json parsing for input value (we use engine's ValueTranslator instead)
  • We avoid repeating parsing and compilation of the dars of a tests
  • We avoid creation of EnvironmentSignature which was never used.

@remyhaemmerle-da remyhaemmerle-da requested a review from a team March 20, 2023 08:16
@@ -22,7 +22,8 @@ final class AuthIT
with Matchers
with SuiteResourceManagementAroundAll {
override def darFile = new File(rlocation("daml-script/test/script-test.dar"))
val (dar, envIface) = readDar(darFile)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

envIface was never used.

Comment on lines +29 to +31
val dar = DarDecoder.assertReadArchiveFromFile(file)
val pkgs = PureCompiledPackages.assertBuild(dar.all.toMap, Runner.compilerConfig)
CompiledDar(dar.main._1, pkgs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We compiled the package just when we read it and do not do it each time Runner.run is called

@remyhaemmerle-da remyhaemmerle-da marked this pull request as ready for review March 20, 2023 08:18
Copy link
Contributor

@samuel-williams-da samuel-williams-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it seems weird that the runner handles input conversion at all, surely that should be the job of whatever is passing in an input?

Comment on lines +34 to +39
def tuple(a: SValue, b: SValue) =
SValue.SRecord(
id = DA.Types.Tuple2,
fields = ImmArray(Ref.Name.assertFromString("_1"), Ref.Name.assertFromString("_2")),
values = ArrayList(a, b),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if theres anywhere else we do this - seems generic enough that it could be outside of a specific test.
I thinking perhaps specifically some of the question answers for ScriptRunner, do any of those return a tuple that we manually create?

Comment on lines 64 to 69
def tuple(a: SValue, b: SValue) =
SRecord(
id = DA.Types.Tuple2,
fields = ImmArray(Name.assertFromString("_1"), Name.assertFromString("_2")),
fields = ImmArray(Ref.Name.assertFromString("_1"), Ref.Name.assertFromString("_2")),
values = ArrayList(a, b),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractScriptTest.tuple?

@remyhaemmerle-da
Copy link
Collaborator Author

I noted you question about the converter in the runner and the tuple inside answers.
Those are indeed legitimate questions about the Script runner, but outside the scope of this PR.
I may tackle them, once I finish with the migration from Sandbox-on-x to Canton .

Copy link
Contributor

@carlpulley-da carlpulley-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@remyhaemmerle-da remyhaemmerle-da merged commit 44b43a4 into main Mar 20, 2023
@remyhaemmerle-da remyhaemmerle-da deleted the remy-script-test-cleanup branch March 20, 2023 14:02
@samuel-williams-da
Copy link
Contributor

I noted you question about the converter in the runner and the tuple inside answers. Those are indeed legitimate questions about the Script runner, but outside the scope of this PR. I may tackle them, once I finish with the migration from Sandbox-on-x to Canton .

I could also maybe tackle these, depending on complexity, but I think I've covered enough scala to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants