Skip to content

Commit fc0efc2

Browse files
Fix flaky BFT scan test (#3357)
[ci] Basically, there was no guarantee that the BFT call would happen with the new scan. If every retry only used the first one (f=0), then it would never be called. It's better to just assert that the scan is now there... Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
1 parent 4f7481a commit fc0efc2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

apps/scan/src/test/scala/org/lfdecentralizedtrust/splice/scan/admin/api/client/BftScanConnectionTest.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ class BftScanConnectionTest
7373

7474
val synchronizerId = SynchronizerId.tryFromString("domain::id")
7575

76+
private def scanUrl(n: Int) = s"https://$n.example.com"
77+
7678
def getMockedConnections(n: Int): Seq[SingleScanConnection] = {
7779
val connections = (0 until n).map { n =>
7880
val m = mock[SingleScanConnection]
7981
when(m.config).thenReturn(
80-
ScanAppClientConfig(NetworkAppClientConfig(s"https://$n.example.com"))
82+
ScanAppClientConfig(NetworkAppClientConfig(scanUrl(n)))
8183
)
8284
m
8385
}
@@ -314,6 +316,11 @@ class BftScanConnectionTest
314316
Future.successful(connections(1))
315317
},
316318
)
319+
// sanity check
320+
bft.scanList.scanConnections.open.map(_.config.adminApi.url).toSet should be(
321+
connections.take(1).map(_.config.adminApi.url).toSet
322+
)
323+
317324
clock.advance(Duration.ofSeconds(refreshSeconds + 1))
318325
// even after advancing it shouldn't refresh yet, as that's less than refreshSeconds
319326
clock.advance(Duration.ofSeconds(1))
@@ -324,10 +331,9 @@ class BftScanConnectionTest
324331
// eventually the refresh goes through and the second connection is used
325332
eventually() {
326333
refreshCalled.intValue() should be(1)
327-
val result = bft.getDsoPartyId().futureValue
328-
try { verify(connections(1), atLeast(1)).getDsoPartyId() }
329-
catch { case cause: MockitoAssertionError => fail("Mockito fail", cause) }
330-
result should be(partyIdA)
334+
bft.scanList.scanConnections.open.map(_.config.adminApi.url).toSet should be(
335+
connections.map(_.config.adminApi.url).toSet
336+
)
331337
}
332338
}
333339

0 commit comments

Comments
 (0)