Skip to content

Commit a910e4c

Browse files
author
DA Automation
committed
[ci] Added v2/updates/
Signed-off-by: DA Automation <splice-maintainers@digitalasset.com>
1 parent 82c3c88 commit a910e4c

File tree

9 files changed

+447
-111
lines changed

9 files changed

+447
-111
lines changed

apps/app/src/main/scala/org/lfdecentralizedtrust/splice/console/ScanAppReference.scala

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import org.lfdecentralizedtrust.splice.codegen.java.splice.ans.AnsRules
2525
import org.lfdecentralizedtrust.splice.config.NetworkAppClientConfig
2626
import org.lfdecentralizedtrust.splice.environment.SpliceConsoleEnvironment
2727
import org.lfdecentralizedtrust.splice.http.v0.definitions
28-
import org.lfdecentralizedtrust.splice.http.v0.definitions.GetDsoInfoResponse
28+
import org.lfdecentralizedtrust.splice.http.v0.definitions.{
29+
GetDsoInfoResponse,
30+
UpdateHistoryItem,
31+
UpdateHistoryItemV2,
32+
}
2933
import org.lfdecentralizedtrust.splice.scan.{ScanApp, ScanAppBootstrap}
3034
import org.lfdecentralizedtrust.splice.scan.automation.ScanAutomationService
3135
import org.lfdecentralizedtrust.splice.scan.admin.api.client.commands.HttpScanAppClient
@@ -457,24 +461,39 @@ abstract class ScanAppReference(
457461
count: Int,
458462
after: Option[(Long, String)],
459463
lossless: Boolean,
460-
) = {
464+
): Seq[UpdateHistoryItem] = {
461465
consoleEnvironment.run {
462466
httpCommand(
463467
HttpScanAppClient.GetUpdateHistoryV0(count, after, lossless)
464468
)
465469
}
466470
}
471+
472+
@deprecated(message = "Use getUpdateHistory instead", since = "0.4.2")
473+
def getUpdateHistoryV1(
474+
count: Int,
475+
after: Option[(Long, String)],
476+
encoding: definitions.DamlValueEncoding,
477+
): Seq[UpdateHistoryItem] = {
478+
consoleEnvironment.run {
479+
httpCommand(
480+
HttpScanAppClient.GetUpdateHistoryV1(count, after, encoding)
481+
)
482+
}
483+
}
484+
467485
def getUpdateHistory(
468486
count: Int,
469487
after: Option[(Long, String)],
470488
encoding: definitions.DamlValueEncoding,
471-
) = {
489+
): Seq[UpdateHistoryItemV2] = {
472490
consoleEnvironment.run {
473491
httpCommand(
474-
HttpScanAppClient.GetUpdateHistory(count, after, encoding)
492+
HttpScanAppClient.GetUpdateHistoryV2(count, after, encoding)
475493
)
476494
}
477495
}
496+
478497
def getUpdate(updateId: String, encoding: definitions.DamlValueEncoding) = {
479498
consoleEnvironment.run {
480499
httpCommand(

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/plugins/UpdateHistorySanityCheckPlugin.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import org.lfdecentralizedtrust.splice.config.SpliceConfig
77
import org.lfdecentralizedtrust.splice.console.ScanAppBackendReference
88
import org.lfdecentralizedtrust.splice.environment.SpliceEnvironment
99
import org.lfdecentralizedtrust.splice.http.v0.definitions.DamlValueEncoding.members.CompactJson
10-
import org.lfdecentralizedtrust.splice.http.v0.definitions.{AcsResponse, UpdateHistoryItem}
11-
import org.lfdecentralizedtrust.splice.http.v0.definitions.UpdateHistoryItem.members
10+
import org.lfdecentralizedtrust.splice.http.v0.definitions.{AcsResponse, UpdateHistoryItemV2}
11+
import org.lfdecentralizedtrust.splice.http.v0.definitions.UpdateHistoryItemV2.members
1212
import org.lfdecentralizedtrust.splice.http.v0.definitions.UpdateHistoryReassignment.Event.members as reassignmentMembers
1313
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.SpliceTestConsoleEnvironment
1414
import org.lfdecentralizedtrust.splice.scan.automation.AcsSnapshotTrigger
@@ -90,13 +90,13 @@ class UpdateHistorySanityCheckPlugin(
9090
private def paginateHistory(
9191
scan: ScanAppBackendReference,
9292
after: Option[(Long, String)],
93-
acc: Chain[UpdateHistoryItem],
94-
): Chain[UpdateHistoryItem] = {
93+
acc: Chain[UpdateHistoryItemV2],
94+
): Chain[UpdateHistoryItemV2] = {
9595
val result = scan.getUpdateHistory(10, after, encoding = CompactJson)
9696
val newAcc = acc ++ Chain.fromSeq(result)
9797
result.lastOption match {
9898
case None => acc // done
99-
case Some(members.UpdateHistoryTransaction(last)) =>
99+
case Some(members.UpdateHistoryTransactionV2(last)) =>
100100
paginateHistory(
101101
scan,
102102
Some((last.migrationId, last.recordTime)),

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanHistoryBackfillingIntegrationTest.scala

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ package org.lfdecentralizedtrust.splice.integration.tests
22

33
import com.daml.ledger.javaapi.data.TransactionTree
44
import org.lfdecentralizedtrust.splice.config.ConfigTransforms
5-
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
6-
ConfigurableApp,
7-
updateAutomationConfig,
8-
}
5+
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{ConfigurableApp, updateAutomationConfig}
96
import org.lfdecentralizedtrust.splice.console.ScanAppBackendReference
107
import org.lfdecentralizedtrust.splice.environment.ledger.api.TransactionTreeUpdate
118
import org.lfdecentralizedtrust.splice.http.v0.definitions
129
import org.lfdecentralizedtrust.splice.http.v0.definitions.DamlValueEncoding.members.CompactJson
1310
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
14-
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{
15-
IntegrationTest,
16-
SpliceTestConsoleEnvironment,
17-
}
11+
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{IntegrationTest, SpliceTestConsoleEnvironment}
1812
import org.lfdecentralizedtrust.splice.scan.admin.http.ProtobufJsonScanHttpEncodings
1913
import org.lfdecentralizedtrust.splice.scan.automation.ScanHistoryBackfillingTrigger
2014
import org.lfdecentralizedtrust.splice.store.{PageLimit, TreeUpdateWithMigrationId}
@@ -27,12 +21,14 @@ import scala.math.BigDecimal.javaBigDecimal2bigDecimal
2721
import com.digitalasset.canton.{HasActorSystem, HasExecutionContext}
2822
import org.lfdecentralizedtrust.splice.automation.TxLogBackfillingTrigger
2923
import org.lfdecentralizedtrust.splice.http.v0.definitions.TransactionHistoryRequest.SortOrder
24+
import org.lfdecentralizedtrust.splice.http.v0.definitions.UpdateHistoryItemV2
3025
import org.lfdecentralizedtrust.splice.scan.store.TxLogEntry
3126
import org.lfdecentralizedtrust.splice.store.MultiDomainAcsStore.TxLogBackfillingState
3227
import org.lfdecentralizedtrust.splice.store.UpdateHistory.BackfillingState
3328
import org.scalactic.source.Position
3429

3530
import scala.annotation.nowarn
31+
import scala.collection.immutable.SortedMap
3632
import scala.jdk.CollectionConverters.*
3733
import scala.jdk.OptionConverters.*
3834

@@ -377,6 +373,24 @@ class ScanHistoryBackfillingIntegrationTest
377373
}
378374

379375
clue("Compare scan histories with each other using the v1 HTTP endpoint") {
376+
// The v1 endpoint is deprecated, but we still have users using it
377+
@nowarn("cat=deprecation")
378+
val sv1HttpUpdates =
379+
sv1ScanBackend.getUpdateHistoryV1(1000, None, encoding = CompactJson)
380+
381+
@nowarn("cat=deprecation")
382+
val sv2HttpUpdates =
383+
sv2ScanBackend.getUpdateHistoryV1(1000, None, encoding = CompactJson)
384+
385+
// Compare common prefix, as there might be concurrent activity
386+
val commonLength = sv1HttpUpdates.length min sv2HttpUpdates.length
387+
commonLength should be > 10
388+
val sv1Items = sv1HttpUpdates.take(commonLength)
389+
val sv2Items = sv2HttpUpdates.take(commonLength)
390+
sv1Items should contain theSameElementsInOrderAs sv2Items
391+
}
392+
393+
clue("Compare scan histories with each other using the v2 HTTP endpoint") {
380394
val sv1HttpUpdates =
381395
readUpdateHistoryFromScan(sv1ScanBackend)
382396
val sv2HttpUpdates =
@@ -387,6 +401,19 @@ class ScanHistoryBackfillingIntegrationTest
387401
commonLength should be > 10
388402
val sv1Items = sv1HttpUpdates.take(commonLength)
389403
val sv2Items = sv2HttpUpdates.take(commonLength)
404+
def collectEventsById(items: Seq[UpdateHistoryItemV2]) = items.collect {
405+
case definitions.UpdateHistoryItemV2.members.UpdateHistoryTransactionV2(http) =>
406+
http.eventsById
407+
}
408+
val eventsByIdSv1 = collectEventsById(sv1Items)
409+
val eventsByIdSv2 = collectEventsById(sv2Items)
410+
411+
def assertOrderedEventsById(eventsByIdSeq: Seq[SortedMap[String, definitions.TreeEvent]]) =
412+
forAll(eventsByIdSeq) { eventsById =>
413+
eventsById.keys.toSeq should contain theSameElementsInOrderAs SortedMap.from(eventsById).keys.toSeq
414+
}
415+
assertOrderedEventsById(eventsByIdSv1)
416+
assertOrderedEventsById(eventsByIdSv2)
390417
sv1Items should contain theSameElementsInOrderAs sv2Items
391418
}
392419

0 commit comments

Comments
 (0)