diff --git a/ledger/error/src/main/scala/com/daml/error/ErrorCodesVersionSwitcher.scala b/ledger/error/src/main/scala/com/daml/error/ErrorCodesVersionSwitcher.scala index e3dbc139cc5f..2b8b9de54db6 100644 --- a/ledger/error/src/main/scala/com/daml/error/ErrorCodesVersionSwitcher.scala +++ b/ledger/error/src/main/scala/com/daml/error/ErrorCodesVersionSwitcher.scala @@ -7,7 +7,7 @@ import io.grpc.StatusRuntimeException import scala.concurrent.Future class ErrorCodesVersionSwitcher(enableSelfServiceErrorCodes: Boolean) - extends ValueSwitch[StatusRuntimeException](enableSelfServiceErrorCodes) { + extends ValueSwitch(enableSelfServiceErrorCodes) { def chooseAsFailedFuture[T]( v1: => StatusRuntimeException, diff --git a/ledger/error/src/main/scala/com/daml/error/ValueSwitch.scala b/ledger/error/src/main/scala/com/daml/error/ValueSwitch.scala index bf39f37d30ff..a3e0dd65d9f8 100644 --- a/ledger/error/src/main/scala/com/daml/error/ValueSwitch.scala +++ b/ledger/error/src/main/scala/com/daml/error/ValueSwitch.scala @@ -7,8 +7,8 @@ package com.daml.error * This class is intended to facilitate transition to self-service error codes. * Once the previous error codes are removed, this class and its specializations should be dropped as well. */ -class ValueSwitch[X](enableSelfServiceErrorCodes: Boolean) { - def choose( +class ValueSwitch(enableSelfServiceErrorCodes: Boolean) { + def choose[X]( v1: => X, v2: => X, ): X = diff --git a/ledger/error/src/test/suite/scala/com/daml/error/ValueSwitchSpec.scala b/ledger/error/src/test/suite/scala/com/daml/error/ValueSwitchSpec.scala index 66d8e8aa86f7..6faf0dda9ef1 100644 --- a/ledger/error/src/test/suite/scala/com/daml/error/ValueSwitchSpec.scala +++ b/ledger/error/src/test/suite/scala/com/daml/error/ValueSwitchSpec.scala @@ -9,11 +9,11 @@ import org.scalatest.matchers.should.Matchers class ValueSwitchSpec extends AnyFlatSpec with Matchers { - behavior of classOf[ValueSwitch[_]].getSimpleName + behavior of classOf[ValueSwitch].getSimpleName it should "use self-service (v2) error codes" in { // given - val tested = new ValueSwitch[StatusRuntimeException](enableSelfServiceErrorCodes = true) + val tested = new ValueSwitch(enableSelfServiceErrorCodes = true) // when val actual = @@ -28,7 +28,7 @@ class ValueSwitchSpec extends AnyFlatSpec with Matchers { it should "use legacy (v1) error codes" in { // given - val tested = new ValueSwitch[StatusRuntimeException](enableSelfServiceErrorCodes = false) + val tested = new ValueSwitch(enableSelfServiceErrorCodes = false) // when val actual = diff --git a/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/platform/server/api/services/grpc/GrpcHealthServiceSpec.scala b/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/platform/server/api/services/grpc/GrpcHealthServiceSpec.scala index aeffc33111cc..dab1463711d3 100644 --- a/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/platform/server/api/services/grpc/GrpcHealthServiceSpec.scala +++ b/ledger/ledger-api-common/src/test/suite/scala/com/digitalasset/platform/server/api/services/grpc/GrpcHealthServiceSpec.scala @@ -11,7 +11,6 @@ import com.daml.ledger.api.testing.utils.AkkaBeforeAndAfterAll import com.daml.logging.LoggingContext import com.daml.platform.server.api.services.grpc.GrpcHealthService._ import com.daml.platform.server.api.services.grpc.GrpcHealthServiceSpec._ -import io.grpc.StatusRuntimeException import io.grpc.health.v1.health.{HealthCheckRequest, HealthCheckResponse} import org.scalatest.concurrent.Eventually import org.scalatest.time.{Second, Span} @@ -346,10 +345,7 @@ final class GrpcHealthServiceSpec // Negative tests returning errors should explicitly instantiate it private def errorCodesVersionSwitcherMock: ErrorCodesVersionSwitcher = new ErrorCodesVersionSwitcher(false) { - override def choose( - v1: => StatusRuntimeException, - v2: => StatusRuntimeException, - ): StatusRuntimeException = { + override def choose[X](v1: => X, v2: => X): X = { val _ = (v1, v2) fail("Should not be called") } diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala index 43ab7e6673c9..6e13278ace58 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/Conversions.scala @@ -55,7 +55,6 @@ import com.daml.lf.{crypto, data} import com.fasterxml.jackson.databind.ObjectMapper import com.google.protobuf.Empty -import com.google.rpc.status.Status import scala.annotation.nowarn import scala.collection.mutable @@ -473,7 +472,7 @@ private[state] object Conversions { @nowarn("msg=deprecated") def decodeTransactionRejectionEntry( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): FinalReason = FinalReason(entry.getReasonCase match { case DamlTransactionRejectionEntry.ReasonCase.INVALID_LEDGER_TIME => diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala index 1be6a42ebaff..1c1359e3d0cc 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumption.scala @@ -31,7 +31,6 @@ import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.google.common.io.BaseEncoding import com.google.protobuf.ByteString -import com.google.rpc.status.Status import scala.jdk.CollectionConverters._ @@ -59,7 +58,7 @@ object KeyValueConsumption { def logEntryToUpdate( entryId: DamlLogEntryId, entry: DamlLogEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, recordTimeForUpdate: Option[Timestamp] = None, )(loggingContext: LoggingContext): List[Update] = { implicit val logContext: LoggingContext = loggingContext @@ -250,7 +249,7 @@ object KeyValueConsumption { private def transactionRejectionEntryToUpdate( recordTime: Timestamp, rejEntry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Update = { val reason = Conversions.decodeTransactionRejectionEntry(rejEntry, errorVersionSwitch) Update.CommandRejected( @@ -343,7 +342,7 @@ object KeyValueConsumption { private[kvutils] def outOfTimeBoundsEntryToUpdate( recordTime: Timestamp, outOfTimeBoundsEntry: DamlOutOfTimeBoundsEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: LoggingContext): Option[Update] = { val timeBounds = parseTimeBounds(outOfTimeBoundsEntry) val deduplicated = timeBounds.deduplicateUntil.exists(recordTime <= _) diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala index 485925fe4644..e4223686167c 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReader.scala @@ -17,7 +17,6 @@ import com.daml.lf.data.Time import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext import com.daml.metrics.{Metrics, Timed} -import com.google.rpc.status.Status /** Adapts a [[LedgerReader]] instance to [[ReadService]]. * Performs translation between the offsets required by the underlying reader and [[ReadService]]: @@ -34,7 +33,7 @@ class KeyValueParticipantStateReader private[api] ( logEntryToUpdate: ( DamlLogEntryId, DamlLogEntry, - ValueSwitch[Status], + ValueSwitch, Option[Timestamp], ) => LoggingContext => List[Update], timeUpdatesProvider: TimeUpdatesProvider, @@ -43,7 +42,7 @@ class KeyValueParticipantStateReader private[api] ( import KeyValueParticipantStateReader._ - private val errorVersionSwitch = new ValueSwitch[Status](enableSelfServiceErrorCodes) + private val errorVersionSwitch = new ValueSwitch(enableSelfServiceErrorCodes) override def ledgerInitialConditions(): Source[LedgerInitialConditions, NotUsed] = Source.single(createLedgerInitialConditions()) diff --git a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/updates/TransactionRejections.scala b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/updates/TransactionRejections.scala index 9a44e6185a10..b4b756efdd6a 100644 --- a/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/updates/TransactionRejections.scala +++ b/ledger/participant-state/kvutils/src/main/scala/com/daml/ledger/participant/state/kvutils/updates/TransactionRejections.scala @@ -39,7 +39,7 @@ private[kvutils] object TransactionRejections { tooEarlyUntil: Option[Timestamp], tooLateFrom: Option[Timestamp], rejectionEntry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Update.CommandRejected = { Update.CommandRejected( recordTime = recordTime, @@ -69,7 +69,7 @@ private[kvutils] object TransactionRejections { def duplicateCommandsRejectionUpdate( recordTime: Timestamp, rejectionEntry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Update.CommandRejected = { val definiteAnswer = rejectionEntry.getDefiniteAnswer Update.CommandRejected( @@ -90,7 +90,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def rejectionReasonNotSetStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status(entry, Code.UNKNOWN, "No reason set for rejection"), @@ -101,7 +101,7 @@ private[kvutils] object TransactionRejections { def invalidParticipantStateStatus( entry: DamlTransactionRejectionEntry, rejection: InvalidParticipantState, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails val metadata = rejection.getMetadataMap.asScala.toMap @@ -120,7 +120,7 @@ private[kvutils] object TransactionRejections { def partiesNotKnownOnLedgerStatus( entry: DamlTransactionRejectionEntry, rejection: PartiesNotKnownOnLedger, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val parties = rejection.getPartiesList errorVersionSwitch.choose( @@ -138,7 +138,7 @@ private[kvutils] object TransactionRejections { def submittingPartyNotKnownOnLedgerStatus( entry: DamlTransactionRejectionEntry, rejection: SubmittingPartyNotKnownOnLedger, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val submitter = rejection.getSubmitterParty errorVersionSwitch.choose( @@ -155,7 +155,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def causalMonotonicityViolatedStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -170,7 +170,7 @@ private[kvutils] object TransactionRejections { def recordTimeOutOfRangeStatus( entry: DamlTransactionRejectionEntry, rejection: RecordTimeOutOfRange, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val minRecordTime = Instant .ofEpochSecond( @@ -199,7 +199,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def externallyDuplicateKeysStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -213,7 +213,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def externallyInconsistentKeysStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -227,7 +227,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def externallyInconsistentContractsStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -242,7 +242,7 @@ private[kvutils] object TransactionRejections { def missingInputStateStatus( entry: DamlTransactionRejectionEntry, rejection: MissingInputState, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val key = rejection.getKey.toString errorVersionSwitch.choose( @@ -259,7 +259,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def internallyInconsistentKeysStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -273,7 +273,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def internallyDuplicateKeysStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -288,7 +288,7 @@ private[kvutils] object TransactionRejections { def validationFailureStatus( entry: DamlTransactionRejectionEntry, rejection: ValidationFailure, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails errorVersionSwitch.choose( @@ -300,7 +300,7 @@ private[kvutils] object TransactionRejections { @nowarn("msg=deprecated") def duplicateCommandStatus( entry: DamlTransactionRejectionEntry, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = errorVersionSwitch.choose( V1.status( @@ -315,7 +315,7 @@ private[kvutils] object TransactionRejections { def submitterCannotActViaParticipantStatus( entry: DamlTransactionRejectionEntry, rejection: SubmitterCannotActViaParticipant, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val submitter = rejection.getSubmitterParty val participantId = rejection.getParticipantId @@ -338,7 +338,7 @@ private[kvutils] object TransactionRejections { def invalidLedgerTimeStatus( entry: DamlTransactionRejectionEntry, rejection: InvalidLedgerTime, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails val ledgerTime = rejection.getLedgerTime @@ -381,7 +381,7 @@ private[kvutils] object TransactionRejections { def resourceExhaustedStatus( entry: DamlTransactionRejectionEntry, rejection: ResourcesExhausted, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails errorVersionSwitch.choose( @@ -398,7 +398,7 @@ private[kvutils] object TransactionRejections { def partyNotKnownOnLedgerStatus( entry: DamlTransactionRejectionEntry, rejection: PartyNotKnownOnLedger, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails errorVersionSwitch.choose( @@ -415,7 +415,7 @@ private[kvutils] object TransactionRejections { def inconsistentStatus( entry: DamlTransactionRejectionEntry, rejection: Inconsistent, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails errorVersionSwitch.choose( @@ -432,7 +432,7 @@ private[kvutils] object TransactionRejections { def disputedStatus( entry: DamlTransactionRejectionEntry, rejection: Disputed, - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, )(implicit loggingContext: ContextualizedErrorLogger): Status = { val details = rejection.getDetails errorVersionSwitch.choose( diff --git a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala index 79ef37758f3d..c526e78da823 100644 --- a/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala +++ b/ledger/participant-state/kvutils/src/test/lib/scala/com/daml/ledger/participant/state/kvutils/KVTest.scala @@ -64,7 +64,7 @@ object KVTest { private[kvutils] val metrics = new Metrics(new MetricRegistry) private[kvutils] val errorVersionSwitch = - new ValueSwitch[com.google.rpc.status.Status](enableSelfServiceErrorCodes = false) + new ValueSwitch(enableSelfServiceErrorCodes = false) private def initialTestState: KVTestState = { val engine = Engine.DevEngine() diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/ConversionsSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/ConversionsSpec.scala index da4cdb4d0243..12684ebd3a07 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/ConversionsSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/ConversionsSpec.scala @@ -41,7 +41,6 @@ import com.daml.logging.{ContextualizedLogger, LoggingContext} import com.fasterxml.jackson.databind.ObjectMapper import com.google.protobuf.{TextFormat, Timestamp} import com.google.rpc.error_details.{ErrorInfo, ResourceInfo} -import com.google.rpc.status.Status import io.grpc.Status.Code import org.scalatest.OptionValues import org.scalatest.matchers.should.Matchers @@ -545,7 +544,7 @@ class ConversionsSpec extends AnyWordSpec with Matchers with OptionValues { } private def checkErrors( - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, submitterInfo: DamlSubmitterInfo, rejection: Rejection, expectedCode: Code, @@ -638,8 +637,8 @@ class ConversionsSpec extends AnyWordSpec with Matchers with OptionValues { ) .build - private lazy val v1ErrorSwitch = new ValueSwitch[Status](enableSelfServiceErrorCodes = false) - private lazy val v2ErrorSwitch = new ValueSwitch[Status](enableSelfServiceErrorCodes = true) + private lazy val v1ErrorSwitch = new ValueSwitch(enableSelfServiceErrorCodes = false) + private lazy val v2ErrorSwitch = new ValueSwitch(enableSelfServiceErrorCodes = true) private[this] val txVersion = TransactionVersion.StableVersions.max diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala index 1f74abca0551..17d6f46a666c 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KVUtilsTransactionSpec.scala @@ -43,7 +43,7 @@ class KVUtilsTransactionSpec extends AnyWordSpec with Matchers with Inside { private implicit val loggingContext: LoggingContext = LoggingContext.ForTesting private val errorVersionSwitch = - new ValueSwitch[com.google.rpc.status.Status](enableSelfServiceErrorCodes = false) + new ValueSwitch(enableSelfServiceErrorCodes = false) private val alice = party("Alice") private val bob = party("Bob") diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala index 9cd90256c9df..3dc5f3218861 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/KeyValueConsumptionSpec.scala @@ -33,7 +33,6 @@ import com.google.protobuf.any.{Any => AnyProto} import com.google.protobuf.{ByteString, Empty} import com.google.rpc.code.Code import com.google.rpc.error_details.ErrorInfo -import com.google.rpc.status.Status import org.scalatest.Inside.inside import org.scalatest.matchers.should.Matchers import org.scalatest.prop.TableDrivenPropertyChecks._ @@ -58,7 +57,7 @@ class KeyValueConsumptionSpec extends AnyWordSpec with Matchers { .setPackageUploadEntry(DamlPackageUploadEntry.getDefaultInstance) .build - private val errorVersionsTable: TableFor1[ValueSwitch[Status]] = Table[ValueSwitch[Status]]( + private val errorVersionsTable: TableFor1[ValueSwitch] = Table[ValueSwitch]( "Error Version", v1ErrorSwitch, v2ErrorSwitch, @@ -447,13 +446,11 @@ class KeyValueConsumptionSpec extends AnyWordSpec with Matchers { } private def runAll( - table: TableFor5[ValueSwitch[ - Status - ], TimeBounds, Timestamp, DamlLogEntry.PayloadCase, Assertions] + table: TableFor5[ValueSwitch, TimeBounds, Timestamp, DamlLogEntry.PayloadCase, Assertions] ): Unit = forAll(table) { ( - errorVersionSwitch: ValueSwitch[Status], + errorVersionSwitch: ValueSwitch, timeBounds: TimeBounds, recordTime: Timestamp, logEntryType: DamlLogEntry.PayloadCase, @@ -572,10 +569,10 @@ class KeyValueConsumptionSpec extends AnyWordSpec with Matchers { Map.empty[String, String] } - private lazy val v1ErrorSwitch = new ValueSwitch[Status](enableSelfServiceErrorCodes = false) { + private lazy val v1ErrorSwitch = new ValueSwitch(enableSelfServiceErrorCodes = false) { override def toString: String = "1" } - private lazy val v2ErrorSwitch = new ValueSwitch[Status](enableSelfServiceErrorCodes = true) { + private lazy val v2ErrorSwitch = new ValueSwitch(enableSelfServiceErrorCodes = true) { override def toString: String = "2" } } diff --git a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReaderSpec.scala b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReaderSpec.scala index 2c6aa3eee4f4..3332a598cdec 100644 --- a/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReaderSpec.scala +++ b/ledger/participant-state/kvutils/src/test/suite/scala/com/daml/ledger/participant/state/kvutils/api/KeyValueParticipantStateReaderSpec.scala @@ -25,7 +25,6 @@ import com.daml.lf.data.Time.Timestamp import com.daml.logging.LoggingContext import com.daml.metrics.Metrics import com.google.protobuf.ByteString -import com.google.rpc.status.Status import org.mockito.Mockito.when import org.mockito.MockitoSugar._ import org.scalatest.matchers.should.Matchers @@ -248,7 +247,7 @@ object KeyValueParticipantStateReaderSpec { private val zeroUpdateGenerator: ( DamlLogEntryId, DamlLogEntry, - ValueSwitch[Status], + ValueSwitch, Option[Timestamp], ) => LoggingContext => List[Update] = (_, _, _, _) => _ => List.empty @@ -256,7 +255,7 @@ object KeyValueParticipantStateReaderSpec { private val singleUpdateGenerator: ( DamlLogEntryId, DamlLogEntry, - ValueSwitch[Status], + ValueSwitch, Option[Timestamp], ) => LoggingContext => List[Update] = (_, _, _, _) => @@ -274,7 +273,7 @@ object KeyValueParticipantStateReaderSpec { private val twoUpdatesGenerator: ( DamlLogEntryId, DamlLogEntry, - ValueSwitch[Status], + ValueSwitch, Option[Timestamp], ) => LoggingContext => List[Update] = (entryId, entry, errorVersionSwitch, recordTime) => @@ -310,7 +309,7 @@ object KeyValueParticipantStateReaderSpec { logEntryToUpdate: ( DamlLogEntryId, DamlLogEntry, - ValueSwitch[Status], + ValueSwitch, Option[Timestamp], ) => LoggingContext => List[Update] = singleUpdateGenerator, failOnUnexpectedEvent: Boolean = true,