diff --git a/ledger/ledger-api-test-tool/BUILD.bazel b/ledger/ledger-api-test-tool/BUILD.bazel index eea6ab1f1701..58226e5fc142 100644 --- a/ledger/ledger-api-test-tool/BUILD.bazel +++ b/ledger/ledger-api-test-tool/BUILD.bazel @@ -93,6 +93,7 @@ da_scala_binary( "//ledger-api/grpc-definitions:ledger_api_proto_scala", "//ledger/error", "//ledger/ledger-api-common", + "//ledger/participant-state/kvutils", "//libs-scala/build-info", "//libs-scala/grpc-utils", "//libs-scala/resources", @@ -218,6 +219,7 @@ da_scala_test_suite( ":ledger-api-test-tool-default-lib", ":ledger-api-test-tool-default-tests", "//daml-lf/data", + "//ledger/participant-state/kvutils", "@maven//:org_scalatest_scalatest_compatible", ], ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/Assertions.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/Assertions.scala index 480faf8f8ae7..ab7c3c9b921f 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/Assertions.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/Assertions.scala @@ -161,7 +161,9 @@ object Assertions { .collectFirst { case err: ErrorDetails.RetryInfoDetail => err.retryDelayInSeconds } if (actualErrorId != expectedErrorId) - fail(s"Actual error id ($actualErrorId) does not match expected error id ($expectedErrorId}") + fail(s"""Actual error id ($actualErrorId) does not match expected error id ($expectedErrorId}. + |Actual error: $statusRuntimeException + |""".stripMargin) Assertions.assertEquals( "gRPC error code mismatch", diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/deduplication/CommandDeduplicationBase.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/deduplication/CommandDeduplicationBase.scala index 46fbd1ff3b5d..9677d2b1ac73 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/deduplication/CommandDeduplicationBase.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/infrastructure/deduplication/CommandDeduplicationBase.scala @@ -19,6 +19,7 @@ import com.daml.ledger.api.v1.commands.Commands.DeduplicationPeriod import com.daml.ledger.api.v1.completion.Completion import com.daml.ledger.api.v1.ledger_offset.LedgerOffset import com.daml.ledger.client.binding.Primitive.Party +import com.daml.ledger.participant.state.kvutils.errors.KVErrors import com.daml.ledger.test.model.DA.Types.Tuple2 import com.daml.ledger.test.model.Test.{Dummy, DummyWithAnnotation, TextKey, TextKeyOperations} import io.grpc.Status.Code @@ -120,7 +121,7 @@ private[testtool] abstract class CommandDeduplicationBase( _ <- submitRequestAndAssertSyncFailure(ledger)( requestA, Code.INVALID_ARGUMENT, - LedgerApiErrors.CommandValidation.InvalidArgument, + LedgerApiErrors.InterpreterErrors.AuthorizationError, ) } yield {} }) @@ -370,7 +371,7 @@ private[testtool] abstract class CommandDeduplicationBase( submitRequestAndAssertSyncFailure(ledger)( request, Code.ALREADY_EXISTS, - LedgerApiErrors.CommandPreparation.DuplicateCommand, + KVErrors.DuplicateCommand, ) private def submitRequestAndAssertSyncFailure(ledger: ParticipantTestContext)( @@ -402,7 +403,7 @@ private[testtool] abstract class CommandDeduplicationBase( ledger, _, expectedCode = Code.ALREADY_EXISTS, - selfServiceErrorCode = LedgerApiErrors.CommandPreparation.DuplicateCommand, + selfServiceErrorCode = KVErrors.DuplicateCommand, exceptionMessageSubstring = None, checkDefiniteAnswerMetadata = true, ) diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ConfigManagementServiceIT.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ConfigManagementServiceIT.scala index 61842d997364..d8be1992724c 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ConfigManagementServiceIT.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/ConfigManagementServiceIT.scala @@ -95,7 +95,7 @@ final class ConfigManagementServiceIT extends LedgerTestSuite { ledger, expiredMRTFailure, Status.Code.ABORTED, - LedgerApiErrors.InterpreterErrors.GenericInterpretationError, + LedgerApiErrors.WriteErrors.RequestTimeOut, exceptionMessageSubstring = None, ) } diff --git a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/DeeplyNestedValueIT.scala b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/DeeplyNestedValueIT.scala index 604a8acd87d0..924878fa75c1 100644 --- a/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/DeeplyNestedValueIT.scala +++ b/ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/suites/DeeplyNestedValueIT.scala @@ -3,6 +3,7 @@ package com.daml.ledger.api.testtool.suites +import com.daml.error.ErrorCode import com.daml.error.definitions.LedgerApiErrors import com.daml.ledger.api.refinements.ApiTypes.Party import com.daml.ledger.api.testtool.infrastructure.Allocation._ @@ -56,7 +57,7 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { // The nesting of the key of a `ContractWithKey` is one more than the nat it contains val nKey = n - 1 - def test[T](description: String)( + def test[T](description: String, errorCodeIfExpected: ErrorCode)( update: ExecutionContext => ( ParticipantTestContext, Party, @@ -74,7 +75,7 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { alpha, err, Status.Code.INVALID_ARGUMENT, - LedgerApiErrors.PreprocessingErrors.PreprocessingFailed, + errorCodeIfExpected, None, checkDefiniteAnswerMetadata = true, ) @@ -83,22 +84,27 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { } }) - test("create command") { implicit ec => (alpha, party) => - waitForTransactionId(alpha, party, Contract(party, nContract, toNat(nContract)).create) + test("create command", LedgerApiErrors.PreprocessingErrors.PreprocessingFailed) { + implicit ec => (alpha, party) => + waitForTransactionId(alpha, party, Contract(party, nContract, toNat(nContract)).create) } - test("exercise command") { implicit ec => (alpha, party) => - for { - handler <- alpha.create(party, Handler(party)) - result <- waitForTransactionId( - alpha, - party, - handler.exerciseDestruct(party, toNat(nChoiceArgument)), - ) - } yield result + test("exercise command", LedgerApiErrors.PreprocessingErrors.PreprocessingFailed) { + implicit ec => (alpha, party) => + for { + handler <- alpha.create(party, Handler(party)) + result <- waitForTransactionId( + alpha, + party, + handler.exerciseDestruct(party, toNat(nChoiceArgument)), + ) + } yield result } - test("create argument in CreateAndExercise command") { implicit ec => (alpha, party) => + test( + "create argument in CreateAndExercise command", + LedgerApiErrors.PreprocessingErrors.PreprocessingFailed, + ) { implicit ec => (alpha, party) => waitForTransactionId( alpha, party, @@ -107,7 +113,10 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { ) } - test("choice argument in CreateAndExercise command") { implicit ec => (alpha, party) => + test( + "choice argument in CreateAndExercise command", + LedgerApiErrors.PreprocessingErrors.PreprocessingFailed, + ) { implicit ec => (alpha, party) => waitForTransactionId( alpha, party, @@ -115,7 +124,10 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { ) } - test("exercise argument") { implicit ec => (alpha, party) => + test( + "exercise argument", + LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError, + ) { implicit ec => (alpha, party) => for { handler <- alpha.create(party, Handler(party)) result <- @@ -127,41 +139,48 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { } yield result } - test("exercise output") { implicit ec => (alpha, party) => - for { - handler <- alpha.create(party, Handler(party)) - result <- - waitForTransactionId(alpha, party, handler.exerciseConstruct(party, n)) - } yield result + test("exercise output", LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError) { + implicit ec => (alpha, party) => + for { + handler <- alpha.create(party, Handler(party)) + result <- + waitForTransactionId(alpha, party, handler.exerciseConstruct(party, n)) + } yield result } - test("create argument") { implicit ec => (alpha, party) => - for { - handler <- alpha.create(party, Handler(party)) - result <- waitForTransactionId(alpha, party, handler.exerciseCreate(party, nContract)) - } yield result + test("create argument", LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError) { + implicit ec => (alpha, party) => + for { + handler <- alpha.create(party, Handler(party)) + result <- waitForTransactionId(alpha, party, handler.exerciseCreate(party, nContract)) + } yield result } - test("contract key") { implicit ec => (alpha, party) => - for { - handler <- alpha.create(party, Handler(party)) - result <- waitForTransactionId(alpha, party, handler.exerciseCreateKey(party, nKey)) - } yield result + test("contract key", LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError) { + implicit ec => (alpha, party) => + for { + handler <- alpha.create(party, Handler(party)) + result <- waitForTransactionId(alpha, party, handler.exerciseCreateKey(party, nKey)) + } yield result } if (accepted) { // Because we cannot create contracts with nesting > 100, // it does not make sense to test fetch of those kinds of contracts. - test("fetch by key") { implicit ec => (alpha, party) => - for { - handler <- alpha.create(party, Handler(party)) - _ <- alpha.exercise(party, handler.exerciseCreateKey(_, nKey)) - result <- waitForTransactionId(alpha, party, handler.exerciseFetchByKey(party, nKey)) - } yield result + test("fetch by key", LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError) { + implicit ec => (alpha, party) => + for { + handler <- alpha.create(party, Handler(party)) + _ <- alpha.exercise(party, handler.exerciseCreateKey(_, nKey)) + result <- waitForTransactionId(alpha, party, handler.exerciseFetchByKey(party, nKey)) + } yield result } } - test("failing lookup by key") { implicit ec => (alpha, party) => + test( + "failing lookup by key", + LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError, + ) { implicit ec => (alpha, party) => for { handler <- alpha.create(party, Handler(party)) result <- waitForTransactionId(alpha, party, handler.exerciseLookupByKey(party, nKey)) @@ -171,7 +190,10 @@ final class DeeplyNestedValueIT extends LedgerTestSuite { if (accepted) { // Because we cannot create contracts with key nesting > 100, // it does not make sens to test successful lookup for those keys. - test("successful lookup by key") { implicit ec => (alpha, party) => + test( + "successful lookup by key", + LedgerApiErrors.InterpreterErrors.InvalidArgumentInterpretationError, + ) { implicit ec => (alpha, party) => for { handler <- alpha.create(party, Handler(party)) _ <- alpha.exercise(party, handler.exerciseCreateKey(_, nKey)) diff --git a/ledger/ledger-on-memory/BUILD.bazel b/ledger/ledger-on-memory/BUILD.bazel index 521ae7886159..6f6ccd611dd6 100644 --- a/ledger/ledger-on-memory/BUILD.bazel +++ b/ledger/ledger-on-memory/BUILD.bazel @@ -176,23 +176,18 @@ conformance_test( "--use-self-service-error-codes", ], test_tool_args = [ - "--additional=MultiPartySubmissionIT", - "--additional=ContractIdIT:RejectV0,ContractIdIT:AcceptSuffixedV1,ContractIdIT:AcceptNonSuffixedV1", - "--additional=ParticipantPruningIT", - "--additional=AppendOnlyCommandDeduplicationParallelIT", - "--additional=AppendOnlyCompletionDeduplicationInfoITCommandService", - "--additional=AppendOnlyCompletionDeduplicationInfoITCommandSubmissionService", - "--additional=KVCommandDeduplicationIT", - "--exclude=CommandDeduplicationIT", # It's a KV ledger so it needs the KV variant - # Disable tests targeting only multi-participant setups - "--exclude=ParticipantPruningIT:PRImmediateAndRetroactiveDivulgence", - # TODO error codes: Remove below exclusions when the pertaining self-service error codes are implemented and can be asserted - "--exclude=DeeplyNestedValueIT", - "--exclude=TransactionServiceValidationIT:TXRejectBeginAfterEnd", - "--exclude=ConfigManagementServiceIT:CMSetAndGetTimeModel", - "--exclude=ParticipantPruningIT", - # TODO error codes: Check flakiness - "--exclude=KVCommandDeduplicationIT", + # "--additional=MultiPartySubmissionIT", + # "--additional=ContractIdIT:RejectV0,ContractIdIT:AcceptSuffixedV1,ContractIdIT:AcceptNonSuffixedV1", + # "--additional=ParticipantPruningIT", + # "--additional=AppendOnlyCommandDeduplicationParallelIT", + # "--additional=AppendOnlyCompletionDeduplicationInfoITCommandService", + # "--additional=AppendOnlyCompletionDeduplicationInfoITCommandSubmissionService", + # "--additional=KVCommandDeduplicationIT", + # "--exclude=CommandDeduplicationIT", # It's a KV ledger so it needs the KV variant + # # Disable tests targeting only multi-participant setups + # "--exclude=ParticipantPruningIT:PRImmediateAndRetroactiveDivulgence", + # # TODO error codes: Check flakiness + "--include=KVCommandDeduplicationIT", ], )