move ContractTransactionChecks to ledger-api-integration-tests (#339)

This commit is contained in:
Francesco Mazzoli 2019-04-11 10:22:34 +02:00 committed by GitHub
parent c90169cddf
commit 10fcab8040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 827 additions and 766 deletions

View File

@ -72,7 +72,7 @@ class TransactionServiceIT
Config
.defaultWithTimeProvider(TimeProviderType.WallClock)
override val timeLimit: Span = 30.seconds
override val timeLimit: Span = 60.seconds
private def newClient(stub: TransactionService, ledgerId: String): TransactionClient =
new TransactionClient(ledgerId, stub)
@ -511,8 +511,7 @@ class TransactionServiceIT
}
"accept huge submissions with a large number of commands" in allFixtures { c =>
// Sandbox is tested with 20000, platform fails with a read pipeline error if we use that number.
val targetNumberOfSubCommands = 2000
val targetNumberOfSubCommands = 15000
val superSizedCommand = c.command(
"Huge composite command",
List.fill(targetNumberOfSubCommands)(

View File

@ -0,0 +1,37 @@
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.tests.integration.ledger.api.commands
import com.digitalasset.ledger.api.v1.command_service.SubmitAndWaitRequest
import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.platform.apitesting.{CommandTransactionChecks, LedgerContext}
import com.google.protobuf.empty.Empty
import com.google.rpc.status.Status
import io.grpc.StatusRuntimeException
import scala.concurrent.Future
class CommandTransactionChecksHighLevelIT extends CommandTransactionChecks {
private[this] def emptyToCompletion(
commandId: String,
emptyF: Future[Empty]): Future[Completion] =
emptyF
.map(_ => Completion(commandId, Some(Status(io.grpc.Status.OK.getCode.value(), ""))))
.recover {
case sre: StatusRuntimeException =>
Completion(
commandId,
Some(Status(sre.getStatus.getCode.value(), sre.getStatus.getDescription)))
}
override protected def submitCommand(
ctx: LedgerContext,
submitRequest: SubmitRequest): Future[Completion] = {
emptyToCompletion(
submitRequest.commands.value.commandId,
ctx.commandService.submitAndWait(
SubmitAndWaitRequest(submitRequest.commands, submitRequest.traceContext)))
}
}

View File

@ -0,0 +1,27 @@
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.tests.integration.ledger.api.commands
import akka.stream.scaladsl.{Sink, Source}
import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.platform.apitesting.{CommandTransactionChecks, LedgerContext}
import com.digitalasset.util.Ctx
import scala.concurrent.Future
class CommandTransactionChecksLowLevelIT extends CommandTransactionChecks {
override protected def submitCommand(
ctx: LedgerContext,
submitRequest: SubmitRequest): Future[Completion] = {
for {
commandClient <- ctx.commandClient()
tracker <- commandClient.trackCommands[Int](List(submitRequest.getCommands.party))
completion <- Source
.single(Ctx(0, submitRequest))
.via(tracker)
.runWith(Sink.head)
} yield completion.value
}
}

View File

@ -7,25 +7,94 @@ import com.digitalasset.ledger.api.v1.value.Identifier
final case class TestTemplateIdentifiers(testPackageId: String) {
val dummy = Identifier(testPackageId, "Test.Dummy", "Test", "Dummy")
val dummyWithParam = Identifier(testPackageId, "Test.DummyWithParam", "Test", "DummyWithParam")
val dummyFactory = Identifier(testPackageId, "Test.DummyFactory", "Test", "DummyFactory")
val dummy = Identifier(testPackageId, "Test.Dummy", moduleName = "Test", entityName = "Dummy")
val dummyWithParam =
Identifier(
testPackageId,
"Test.DummyWithParam",
moduleName = "Test",
entityName = "DummyWithParam")
val dummyFactory =
Identifier(testPackageId, "Test.DummyFactory", moduleName = "Test", entityName = "DummyFactory")
val dummyContractFactory =
Identifier(testPackageId, "Test.DummyContractFactory", "Test", "DummyContractFactory")
Identifier(
testPackageId,
"Test.DummyContractFactory",
moduleName = "Test",
entityName = "DummyContractFactory")
val parameterShowcase =
Identifier(testPackageId, "Test.ParameterShowcase", "Test", "ParameterShowcase")
Identifier(
testPackageId,
"Test.ParameterShowcase",
moduleName = "Test",
entityName = "ParameterShowcase")
val parameterShowcaseChoice1 =
Identifier(testPackageId, "Test.Choice1", moduleName = "Test", entityName = "Choice1")
val optionalInteger =
Identifier(
testPackageId,
"Test.OptionalInteger",
moduleName = "Test",
entityName = "OptionalInteger")
val agreementFactory =
Identifier(testPackageId, "Test.AgreementFactory", "Test", "AgreementFactory")
val agreement = Identifier(testPackageId, "Test.Agreement", "Test", "Agreement")
val triAgreement = Identifier(testPackageId, "Test.TriAgreement", "Test", "TriAgreement")
val triProposal = Identifier(testPackageId, "Test.TriProposal", "Test", "TriProposal")
val textContainer = Identifier(testPackageId, "Test.TextContainer", "Test", "TextContainer")
val nothingArgument = Identifier(testPackageId, "Test.NothingArgument", "Test", "NothingArgument")
val withObservers = Identifier(testPackageId, "Test.WithObservers", "Test", "WithObservers")
Identifier(
testPackageId,
"Test.AgreementFactory",
moduleName = "Test",
entityName = "AgreementFactory")
val agreement =
Identifier(testPackageId, "Test.Agreement", moduleName = "Test", entityName = "Agreement")
val triAgreement =
Identifier(testPackageId, "Test.TriAgreement", moduleName = "Test", entityName = "TriAgreement")
val triProposal =
Identifier(testPackageId, "Test.TriProposal", moduleName = "Test", entityName = "TriProposal")
val textContainer = Identifier(
testPackageId,
"Test.TextContainer",
moduleName = "Test",
entityName = "TextContainer")
val nothingArgument =
Identifier(
testPackageId,
"Test.NothingArgument",
moduleName = "Test",
entityName = "NothingArgument")
val maybeType = Identifier(testPackageId, "Test.Maybe", moduleName = "Test", entityName = "Maybe")
val withObservers = Identifier(
testPackageId,
"Test.WithObservers",
moduleName = "Test",
entityName = "WithObservers")
val branchingSignatories =
Identifier(testPackageId, "Test.BranchingSignatories", "Test", "BranchingSignatories")
Identifier(
testPackageId,
"Test.BranchingSignatories",
moduleName = "Test",
entityName = "BranchingSignatories")
val branchingControllers =
Identifier(testPackageId, "Test.BranchingControllers", "Test", "BranchingControllers")
Identifier(
testPackageId,
"Test.BranchingControllers",
moduleName = "Test",
entityName = "BranchingControllers")
val callablePayout =
Identifier(
testPackageId,
"Test.CallablePayout",
moduleName = "Test",
entityName = "CallablePayout")
val callablePayoutTransfer =
Identifier(testPackageId, "Test.Transfer", moduleName = "Test", entityName = "Transfer")
val callablePayoutCall =
Identifier(testPackageId, "Test.Call", moduleName = "Test", entityName = "Call")
val textKey =
Identifier(testPackageId, "Test.TextKey", moduleName = "Test", entityName = "TextKey")
val textKeyOperations =
Identifier(
testPackageId,
"Test.TextKeyOperations",
moduleName = "Test",
entityName = "TextKeyOperations")
val divulgence1 =
Identifier(testPackageId, "Test.Divulgence1", "Test", "Divulgence1")
val divulgence2 =
@ -40,6 +109,8 @@ final case class TestTemplateIdentifiers(testPackageId: String) {
triProposal,
triAgreement,
textContainer,
textKey,
textKeyOperations,
divulgence1,
divulgence2)
}

View File

@ -1,97 +0,0 @@
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox.services.commands
import java.time.Duration
import akka.stream.scaladsl.{Sink, Source}
import com.digitalasset.ledger.api.testing.utils.{
AkkaBeforeAndAfterAll,
SuiteResourceManagementAroundAll,
MockMessages => M
}
import com.digitalasset.ledger.api.v1.command_completion_service.CommandCompletionServiceGrpc
import com.digitalasset.ledger.api.v1.command_service.{CommandServiceGrpc, SubmitAndWaitRequest}
import com.digitalasset.ledger.api.v1.command_submission_service.{
CommandSubmissionServiceGrpc,
SubmitRequest
}
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.ledger.client.configuration.CommandClientConfiguration
import com.digitalasset.ledger.client.services.commands.CommandClient
import com.digitalasset.platform.sandbox.TestExecutionSequencerFactory
import com.digitalasset.platform.sandbox.services.SandboxFixture
import com.digitalasset.platform.sandbox.utils.LedgerTestingHelpers
import com.digitalasset.util.Ctx
import org.scalatest.{OptionValues, Suite}
import scala.collection.immutable
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
class CommandTransactionIT
extends Suite
with SandboxFixture
with SuiteResourceManagementAroundAll
with OptionValues
with AkkaBeforeAndAfterAll
with TestExecutionSequencerFactory {
private lazy val timeProviderForClient = getTimeProviderForClient(materializer, esf)
override def nestedSuites: immutable.IndexedSeq[Suite] =
Vector(
new CommandTransactionChecks(
submitAsync,
"submitting via low level services",
testPackageId,
ledgerIdOnServer,
channel,
timeProviderForClient,
materializer,
esf),
new CommandTransactionChecks(
submitSync,
"submitting via high level service",
testPackageId,
ledgerIdOnServer,
channel,
timeProviderForClient,
materializer,
esf)
)
private val testPackageId = config.damlPackageContainer.packageIds.head
private lazy val commandClient = newCommandClient()
private lazy val syncCommandClient = CommandServiceGrpc.stub(channel)
private def newCommandClient(applicationId: String = M.applicationId) =
new CommandClient(
CommandSubmissionServiceGrpc.stub(channel),
CommandCompletionServiceGrpc.stub(channel),
ledgerIdOnServer,
applicationId,
CommandClientConfiguration(1, 1, true, Duration.ofSeconds(10L)),
Some(timeProviderForClient)
)
private def submitAsync(submitRequest: SubmitRequest): Future[Completion] = {
for {
tracker <- commandClient.trackCommands[Int](List(submitRequest.getCommands.party))
completion <- Source
.single(Ctx(0, submitRequest))
.via(tracker)
.runWith(Sink.head)
} yield completion.value
}
private def submitSync(submitRequest: SubmitRequest): Future[Completion] = {
LedgerTestingHelpers.emptyToCompletion(
submitRequest.commands.value.commandId,
syncCommandClient.submitAndWait(
SubmitAndWaitRequest(submitRequest.commands, submitRequest.traceContext)))
}
}