@@ -291,6 +291,40 @@ class ScanEventStoreTest extends StoreTest with HasExecutionContext with SpliceP
291291 }
292292 }
293293
294+ " correctly handles migration with no verdicts in prior migration" in {
295+ val mig0 = domainMigrationId
296+ val mig1 = mig0 + 1
297+ for {
298+ ctx0 <- newEventStore(mig0)
299+ ctx1 <- newEventStore(mig1)
300+
301+ // mig0: has only one update (T1), no verdicts
302+ recordTs1 = CantonTimestamp .now()
303+ tx0 <- insertUpdate(ctx0.updateHistory, recordTs1, " update-mig0" )
304+ updateId0 = tx0.getUpdateId
305+
306+ // mig1 (current): has 1 update and 1 verdict (T2)
307+ recordTs2 = recordTs1.plusSeconds(1 )
308+ tx1 <- insertUpdate(ctx1.updateHistory, recordTs2, " update-mig1" )
309+ updateId1 = tx1.getUpdateId
310+ _ <- insertVerdict(ctx1.verdictStore, updateId1, recordTs2, migrationId = mig1)
311+
312+ // Query combined events at current migration = mig1, starting from beginning of time
313+ events <- fetchEvents(ctx1.eventStore, None , mig1, pageLimit)
314+ } yield {
315+ // Both the update from mig0 and the combined event from mig1 should be present
316+ events.size shouldBe 2
317+ hasUpdate(events, updateId0) shouldBe true
318+ hasUpdate(events, updateId1) shouldBe true
319+ hasVerdict(events, updateId1) shouldBe true
320+
321+ // The event for mig0 should only have an update, no verdict
322+ val event0 = events.find(_._2.exists(_.update.update.updateId == updateId0)).value
323+ event0._1.isEmpty shouldBe true
324+ event0._2.isDefined shouldBe true
325+ }
326+ }
327+
294328 " Cap the assignments till the latest verdict" in {
295329 for {
296330 ctx <- newEventStore()
0 commit comments