mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
Merge pull request #3473 from corda/fix_flaky_test
[CORDA-1698] Fix flaky test
This commit is contained in:
commit
2b6018f050
@ -6328,7 +6328,7 @@ public class net.corda.testing.node.MockServices extends java.lang.Object implem
|
||||
@NotNull
|
||||
public final net.corda.testing.services.MockAttachmentStorage getAttachments()
|
||||
@NotNull
|
||||
public java.time.Clock getClock()
|
||||
public net.corda.testing.node.TestClock getClock()
|
||||
@NotNull
|
||||
public net.corda.core.node.services.ContractUpgradeService getContractUpgradeService()
|
||||
@NotNull
|
||||
|
@ -40,7 +40,7 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.ExternalResource
|
||||
import java.lang.Thread.sleep
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneOffset
|
||||
@ -198,7 +198,7 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
vaultFiller.fillWithSomeTestLinearStates(3, "ABC")
|
||||
val dealStates = vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
// Total unconsumed states = 10 + 1 + 2 + 3 + 3 = 19
|
||||
sleep(delay)
|
||||
services.clock.advanceBy(Duration.ofMillis(delay))
|
||||
|
||||
// consume some states
|
||||
vaultFiller.consumeLinearStates(linearStatesXYZ.states.toList())
|
||||
@ -1806,12 +1806,11 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
// specifying Query on Linear state attributes
|
||||
@Test
|
||||
fun `unconsumed linear heads for linearId between two timestamps`() {
|
||||
val start = Instant.now()
|
||||
val end = start.plus(1, ChronoUnit.SECONDS)
|
||||
|
||||
database.transaction {
|
||||
val start = services.clock.instant()
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
||||
sleep(1000)
|
||||
services.clock.advanceBy(1.seconds)
|
||||
val end = services.clock.instant()
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
||||
// 2 unconsumed states with same external ID
|
||||
val recordedBetweenExpression = TimeCondition(TimeInstantType.RECORDED, builder { between(start, end) })
|
||||
@ -1842,13 +1841,12 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
// specifying Query on Linear state attributes
|
||||
@Test
|
||||
fun `unconsumed linear heads for linearId between two timestamps for a given external id`() {
|
||||
val start = Instant.now()
|
||||
val end = start.plus(1, ChronoUnit.SECONDS)
|
||||
|
||||
database.transaction {
|
||||
val start = services.clock.instant()
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST1")
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST2")
|
||||
sleep(1000)
|
||||
services.clock.advanceBy(1.seconds)
|
||||
val end = services.clock.instant()
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST3")
|
||||
// 2 unconsumed states with same external ID
|
||||
|
||||
|
@ -230,7 +230,7 @@ open class MockServices private constructor(
|
||||
override val vaultService: VaultService get() = throw UnsupportedOperationException()
|
||||
override val contractUpgradeService: ContractUpgradeService get() = throw UnsupportedOperationException()
|
||||
override val networkMapCache: NetworkMapCache get() = throw UnsupportedOperationException()
|
||||
override val clock: Clock get() = Clock.systemUTC()
|
||||
override val clock: TestClock get() = TestClock(Clock.systemUTC())
|
||||
override val myInfo: NodeInfo
|
||||
get() {
|
||||
return NodeInfo(listOf(NetworkHostAndPort("mock.node.services", 10000)), listOf(initialIdentity.identity), 1, serial = 1L)
|
||||
@ -242,7 +242,7 @@ open class MockServices private constructor(
|
||||
protected val servicesForResolution: ServicesForResolution get() = ServicesForResolutionImpl(identityService, attachments, cordappProvider, networkParameters, validatedTransactions)
|
||||
|
||||
internal fun makeVaultService(hibernateConfig: HibernateConfiguration, schemaService: SchemaService, database: CordaPersistence): VaultServiceInternal {
|
||||
val vaultService = NodeVaultService(Clock.systemUTC(), keyManagementService, servicesForResolution, hibernateConfig, database)
|
||||
val vaultService = NodeVaultService(clock, keyManagementService, servicesForResolution, hibernateConfig, database)
|
||||
HibernateObserver.install(vaultService.rawUpdates, hibernateConfig, schemaService)
|
||||
return vaultService
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user