diff --git a/daml-script/test/BUILD.bazel b/daml-script/test/BUILD.bazel index 15e0a37bc6e6..e05013ccd765 100644 --- a/daml-script/test/BUILD.bazel +++ b/daml-script/test/BUILD.bazel @@ -146,8 +146,8 @@ da_scala_library( "//ledger/participant-integration-api", "//ledger/participant-state/kvutils", "//ledger/participant-state/kvutils/app", - "//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/ports", @@ -206,8 +206,8 @@ da_scala_test_suite( "//ledger/participant-state", "//ledger/participant-state/kvutils", "//ledger/participant-state/kvutils/app", - "//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", diff --git a/daml-script/test/daml/ScriptTest.daml b/daml-script/test/daml/ScriptTest.daml index 54671d4de862..f203b8da87f3 100644 --- a/daml-script/test/daml/ScriptTest.daml +++ b/daml-script/test/daml/ScriptTest.daml @@ -277,7 +277,7 @@ template MessageSize testMaxInboundMessageSize : Script () = do p <- allocateParty "p" b <- submit p do createCmd (MessageSize p) - submit p do exerciseCmd b CreateN with n = 50000 + submit p do exerciseCmd b CreateN with n = 1 return () testSetTime : Script (Time, Time) = do diff --git a/daml-script/test/src/com/digitalasset/daml/lf/engine/script/test/JsonApiIt.scala b/daml-script/test/src/com/digitalasset/daml/lf/engine/script/test/JsonApiIt.scala index fc4f1d5ca7ca..4c65b2ff805a 100644 --- a/daml-script/test/src/com/digitalasset/daml/lf/engine/script/test/JsonApiIt.scala +++ b/daml-script/test/src/com/digitalasset/daml/lf/engine/script/test/JsonApiIt.scala @@ -47,7 +47,8 @@ import com.daml.platform.apiserver.services.GrpcClientResource import com.daml.platform.common.LedgerIdMode import com.daml.platform.sandbox.config.SandboxConfig import com.daml.platform.sandbox.services.TestCommands -import com.daml.platform.sandbox.{AbstractSandboxFixture, SandboxServer} +import com.daml.platform.sandbox.AbstractSandboxFixture +import com.daml.platform.sandboxnext import com.daml.ports.Port import io.grpc.Channel import org.scalatest._ @@ -64,16 +65,14 @@ import com.codahale.metrics.MetricRegistry trait JsonApiFixture extends AbstractSandboxFixture - with SuiteResource[(SandboxServer, Channel, ServerBinding)] { + with SuiteResource[(Port, Channel, ServerBinding)] { self: Suite => override protected def darFile = new File(rlocation("daml-script/test/script-test.dar")) protected val darFileNoLedger = new File(rlocation("daml-script/test/script-test-no-ledger.dar")) - protected def server: SandboxServer = suiteResource.value._1 - - override protected def serverPort: Port = server.port + override protected def serverPort: Port = suiteResource.value._1 override protected def channel: Channel = suiteResource.value._2 override protected def config: SandboxConfig = super.config @@ -121,17 +120,16 @@ trait JsonApiFixture } } - override protected lazy val suiteResource - : TestResource[(SandboxServer, Channel, ServerBinding)] = { + override protected lazy val suiteResource: TestResource[(Port, Channel, ServerBinding)] = { implicit val context: ResourceContext = ResourceContext(system.dispatcher) - new OwnedResource[ResourceContext, (SandboxServer, Channel, ServerBinding)]( + new OwnedResource[ResourceContext, (Port, Channel, ServerBinding)]( for { jdbcUrl <- database .fold[ResourceOwner[Option[String]]](ResourceOwner.successful(None))( _.map(info => Some(info.jdbcUrl)) ) - server <- SandboxServer.owner(config.copy(jdbcUrl = jdbcUrl)) - channel <- GrpcClientResource.owner(server.port) + serverPort <- new sandboxnext.Runner(config.copy(jdbcUrl = jdbcUrl)) + channel <- GrpcClientResource.owner(serverPort) httpService <- new ResourceOwner[ServerBinding] { override def acquire()(implicit context: ResourceContext): Resource[ServerBinding] = { implicit val lc: LoggingContextOf[InstanceUUID] = instanceUUIDLogCtx( @@ -140,7 +138,7 @@ trait JsonApiFixture Resource[ServerBinding] { val config = new StartSettings.Default { override val ledgerHost = "localhost" - override val ledgerPort = server.port.value + override val ledgerPort = serverPort.value override val address = "localhost" override val httpPort = 0 override val portFile = None @@ -169,7 +167,9 @@ trait JsonApiFixture }((binding: ServerBinding) => binding.unbind().map(_ => ())) } } - } yield (server, channel, httpService) + } yield (serverPort, channel, httpService), + acquisitionTimeout = 1.minute, + releaseTimeout = 1.minute, ) } } diff --git a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/AbstractFuncIT.scala b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/AbstractFuncIT.scala index 30fe5c1f87bf..0761ac1d0c1f 100644 --- a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/AbstractFuncIT.scala +++ b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/AbstractFuncIT.scala @@ -6,9 +6,10 @@ package com.daml.lf.engine.script.test import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll import com.daml.lf.data.Ref._ import com.daml.lf.data.{FrontStack, FrontStackCons, Numeric} -import com.daml.lf.engine.script.{RunnerConfig, ScriptF, StackTrace} +import com.daml.lf.engine.script.{ScriptF, StackTrace} import com.daml.lf.speedy.SValue import com.daml.lf.speedy.SValue._ +import io.grpc.{Status, StatusRuntimeException} import org.scalatest.Inside import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AsyncWordSpec @@ -218,15 +219,20 @@ abstract class AbstractFuncIT "succeed despite large message" in { for { clients <- participantClients( - maxInboundMessageSize = RunnerConfig.DefaultMaxInboundMessageSize * 10 + // Reduce maxInboundMessageSize until we get an error + maxInboundMessageSize = 500 ) - v <- run( - clients, - QualifiedName.assertFromString("ScriptTest:testMaxInboundMessageSize"), - dar = stableDar, + ex <- recoverToExceptionIf[ScriptF.FailedCmd]( + run( + clients, + QualifiedName.assertFromString("ScriptTest:testMaxInboundMessageSize"), + dar = stableDar, + ) ) } yield { - assert(v == SUnit) + inside(ex.cause) { case e: StatusRuntimeException => + e.getStatus.getCode() shouldBe Status.Code.RESOURCE_EXHAUSTED + } } } } diff --git a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxAuthParticipantFixture.scala b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxAuthParticipantFixture.scala index 3dfe45337e90..04a749442338 100644 --- a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxAuthParticipantFixture.scala +++ b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxAuthParticipantFixture.scala @@ -14,7 +14,7 @@ import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll import com.daml.ledger.api.tls.TlsConfiguration import com.daml.lf.engine.script._ import com.daml.lf.engine.script.ledgerinteraction.ScriptTimeMode -import com.daml.platform.sandbox.services.SandboxFixture +import com.daml.platform.sandboxnext.SandboxNextFixture import com.daml.platform.services.time.TimeProviderType import org.scalatest.Suite import scalaz.syntax.tag._ @@ -24,7 +24,7 @@ import scala.concurrent.ExecutionContext trait SandboxAuthParticipantFixture extends AbstractScriptTest - with SandboxFixture + with SandboxNextFixture with AkkaBeforeAndAfterAll { self: Suite => private implicit val ec: ExecutionContext = system.dispatcher diff --git a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxParticipantFixture.scala b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxParticipantFixture.scala index 7505d18437da..174f3f36ca42 100644 --- a/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxParticipantFixture.scala +++ b/daml-script/test/src/test-utils/com/daml/lf/engine/script/test/SandboxParticipantFixture.scala @@ -6,7 +6,7 @@ package com.daml.lf.engine.script.test import java.io.File import com.daml.lf.engine.script.{ApiParameters, Participants, Runner, RunnerConfig} -import com.daml.platform.sandbox.services.SandboxFixture +import com.daml.platform.sandboxnext.SandboxNextFixture import com.daml.platform.services.time.TimeProviderType import org.scalatest.Suite import com.daml.bazeltools.BazelRunfiles._ @@ -18,7 +18,7 @@ import scala.concurrent.ExecutionContext trait SandboxParticipantFixture extends AbstractScriptTest - with SandboxFixture + with SandboxNextFixture with AkkaBeforeAndAfterAll { self: Suite => private implicit val ec: ExecutionContext = system.dispatcher