mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Migrate trigger tests from sandbox-classic to sandbox (#11478)
Deliberately does not include the tests for the trigger service. changelog_begin changelog_end
This commit is contained in:
parent
f9ec12be12
commit
c415d9d1ee
@ -5,7 +5,7 @@ load(
|
||||
"//bazel_tools:scala.bzl",
|
||||
"da_scala_binary",
|
||||
"da_scala_library",
|
||||
"da_scala_test",
|
||||
"da_scala_test_suite",
|
||||
"silencer_plugin",
|
||||
)
|
||||
load("@build_environment//:configuration.bzl", "sdk_version")
|
||||
@ -109,8 +109,8 @@ da_scala_library(
|
||||
"//ledger/ledger-api-common",
|
||||
"//ledger/ledger-api-domain",
|
||||
"//ledger/ledger-resources",
|
||||
"//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",
|
||||
@ -122,10 +122,8 @@ da_scala_library(
|
||||
],
|
||||
)
|
||||
|
||||
# For now turning this into a scala_test_suite has too much overhead and ends up making
|
||||
# things slower rather than faster. Once we have more tests, we might want to reconsider.
|
||||
[
|
||||
da_scala_test(
|
||||
da_scala_test_suite(
|
||||
name = "trigger-integration-tests" + suffix,
|
||||
srcs = [
|
||||
"src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/%s.scala" % f
|
||||
@ -167,8 +165,7 @@ da_scala_library(
|
||||
"//ledger/ledger-configuration",
|
||||
"//ledger/ledger-resources",
|
||||
"//ledger/participant-integration-api",
|
||||
"//ledger/sandbox-classic",
|
||||
"//ledger/sandbox-classic:sandbox-classic-scala-tests-lib",
|
||||
"//ledger/sandbox:sandbox-scala-tests-lib",
|
||||
"//ledger/sandbox-common",
|
||||
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
|
||||
"//ledger/test-common",
|
||||
|
@ -17,22 +17,11 @@ maxInboundMessageSizeTrigger = Trigger
|
||||
}
|
||||
|
||||
maxInboundMessageSizeRule : Party -> TriggerA () ()
|
||||
maxInboundMessageSizeRule party = query @MessageSize >>= \case
|
||||
[] ->
|
||||
void $ emitCommands [createAndExerciseCmd (MessageSize { p = party }) (CreateN {n = 50000})] []
|
||||
_ -> pure ()
|
||||
maxInboundMessageSizeRule party = do
|
||||
void $ emitCommands [createCmd (T party)] []
|
||||
|
||||
template MessageSize
|
||||
template T
|
||||
with
|
||||
p : Party
|
||||
where
|
||||
signatory p
|
||||
nonconsuming choice CreateN : ()
|
||||
with
|
||||
n : Int
|
||||
controller p
|
||||
do
|
||||
res <- forA [1..n] (\_ -> do
|
||||
create this
|
||||
)
|
||||
return()
|
||||
|
@ -12,13 +12,13 @@ import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll
|
||||
import com.daml.ledger.api.v1.commands.CreateCommand
|
||||
import com.daml.ledger.api.v1.{value => LedgerApi}
|
||||
import com.daml.platform.services.time.TimeProviderType
|
||||
import io.grpc.{Status, StatusRuntimeException}
|
||||
import org.scalatest._
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import org.scalatest.wordspec.AsyncWordSpec
|
||||
import scalaz.syntax.traverse._
|
||||
|
||||
import com.daml.lf.engine.trigger.TriggerMsg
|
||||
import com.daml.lf.engine.trigger.RunnerConfig
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
@ -314,21 +314,23 @@ abstract class AbstractFuncTests
|
||||
"MaxMessageSizeTests" should {
|
||||
val triggerId =
|
||||
QualifiedName.assertFromString("MaxInboundMessageTest:maxInboundMessageSizeTrigger")
|
||||
val tId = LedgerApi.Identifier(packageId, "MaxInboundMessageTest", "MessageSize")
|
||||
"fail" in {
|
||||
for {
|
||||
client <- ledgerClient(
|
||||
maxInboundMessageSize = 5 * RunnerConfig.DefaultMaxInboundMessageSize
|
||||
// Sufficiently low that the transaction is larger than the max inbound message size
|
||||
maxInboundMessageSize = 300
|
||||
)
|
||||
party <- allocateParty(client)
|
||||
runner = getRunner(client, triggerId, party)
|
||||
(acs, offset) <- runner.queryACS()
|
||||
// 1 for create and exercise
|
||||
// 1 for completion
|
||||
_ <- runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(2))._2
|
||||
acs <- queryACS(client, party)
|
||||
// 1 for the transaction
|
||||
ex <- recoverToExceptionIf[StatusRuntimeException](
|
||||
runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(3))._2
|
||||
)
|
||||
} yield {
|
||||
assert(acs(tId).length == 50001)
|
||||
ex.getStatus.getCode() shouldBe Status.Code.RESOURCE_EXHAUSTED
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,15 +442,12 @@ abstract class AbstractFuncTests
|
||||
QualifiedName.assertFromString("TemplateIdFilter:testOne"),
|
||||
party,
|
||||
)
|
||||
(acs, offset) <- runner.queryACS()
|
||||
// 2 for the creates from the test
|
||||
// 2 for the completions from the test
|
||||
// 1 for the create in the trigger
|
||||
// 1 for the completion from the trigger
|
||||
finalStateF = runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(6))._2
|
||||
_ <- create(client, party, one(party))
|
||||
_ <- create(client, party, two(party))
|
||||
_ <- finalStateF
|
||||
(acs, offset) <- runner.queryACS()
|
||||
// 1 for the create in the trigger
|
||||
// 1 for the completion from the trigger
|
||||
_ <- runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(2))._2
|
||||
acs <- queryACS(client, party)
|
||||
} yield {
|
||||
assert(acs(doneOneId).length == 1)
|
||||
@ -464,15 +463,12 @@ abstract class AbstractFuncTests
|
||||
QualifiedName.assertFromString("TemplateIdFilter:testTwo"),
|
||||
party,
|
||||
)
|
||||
(acs, offset) <- runner.queryACS()
|
||||
// 2 for the creates from the test
|
||||
// 2 for the completions from the test
|
||||
// 1 for the create in the trigger
|
||||
// 1 for the completion from the trigger
|
||||
finalStateF = runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(6))._2
|
||||
_ <- create(client, party, one(party))
|
||||
_ <- create(client, party, two(party))
|
||||
_ <- finalStateF
|
||||
(acs, offset) <- runner.queryACS()
|
||||
// 1 for the create in the trigger
|
||||
// 1 for the completion from the trigger
|
||||
_ <- runner.runWithACS(acs, offset, msgFlow = Flow[TriggerMsg].take(2))._2
|
||||
acs <- queryACS(client, party)
|
||||
} yield {
|
||||
assert(!acs.contains(doneOneId))
|
||||
|
@ -26,7 +26,8 @@ import com.daml.lf.archive.DarDecoder
|
||||
import com.daml.lf.data.Ref._
|
||||
import com.daml.lf.speedy.SValue
|
||||
import com.daml.lf.speedy.SValue._
|
||||
import com.daml.platform.sandbox.services.{SandboxFixture, TestCommands}
|
||||
import com.daml.platform.sandboxnext.SandboxNextFixture
|
||||
import com.daml.platform.sandbox.services.TestCommands
|
||||
import org.scalatest._
|
||||
import scalaz.syntax.tag._
|
||||
|
||||
@ -34,7 +35,7 @@ import scala.collection.compat._
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
import scala.util.Try
|
||||
|
||||
trait AbstractTriggerTest extends SandboxFixture with TestCommands {
|
||||
trait AbstractTriggerTest extends SandboxNextFixture with TestCommands {
|
||||
self: Suite =>
|
||||
|
||||
protected def toHighLevelResult(s: SValue) = s match {
|
||||
|
@ -12,7 +12,7 @@ import com.daml.ledger.client.configuration.LedgerClientConfiguration
|
||||
import com.daml.lf.data.Ref._
|
||||
import com.daml.lf.engine.trigger.TriggerMsg
|
||||
import com.daml.platform.sandbox.SandboxRequiringAuthorization
|
||||
import com.daml.platform.sandbox.services.SandboxFixture
|
||||
import com.daml.platform.sandboxnext.SandboxNextFixture
|
||||
import org.scalatest._
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import org.scalatest.wordspec.AsyncWordSpec
|
||||
@ -20,7 +20,7 @@ import org.scalatest.wordspec.AsyncWordSpec
|
||||
class Jwt
|
||||
extends AsyncWordSpec
|
||||
with AbstractTriggerTest
|
||||
with SandboxFixture
|
||||
with SandboxNextFixture
|
||||
with SandboxRequiringAuthorization
|
||||
with Matchers
|
||||
with SuiteResourceManagementAroundAll
|
||||
|
Loading…
Reference in New Issue
Block a user