mirror of
https://github.com/corda/corda.git
synced 2025-06-17 14:48:16 +00:00
Advance TestClock instead of sleeping.
This commit is contained in:
@ -40,7 +40,7 @@ import org.junit.Rule
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.rules.ExpectedException
|
||||||
import org.junit.rules.ExternalResource
|
import org.junit.rules.ExternalResource
|
||||||
import java.lang.Thread.sleep
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
@ -198,7 +198,7 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
vaultFiller.fillWithSomeTestLinearStates(3, "ABC")
|
vaultFiller.fillWithSomeTestLinearStates(3, "ABC")
|
||||||
val dealStates = vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
val dealStates = vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||||
// Total unconsumed states = 10 + 1 + 2 + 3 + 3 = 19
|
// Total unconsumed states = 10 + 1 + 2 + 3 + 3 = 19
|
||||||
sleep(delay)
|
services.clock.advanceBy(Duration.ofMillis(delay))
|
||||||
|
|
||||||
// consume some states
|
// consume some states
|
||||||
vaultFiller.consumeLinearStates(linearStatesXYZ.states.toList())
|
vaultFiller.consumeLinearStates(linearStatesXYZ.states.toList())
|
||||||
@ -1806,12 +1806,11 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
// specifying Query on Linear state attributes
|
// specifying Query on Linear state attributes
|
||||||
@Test
|
@Test
|
||||||
fun `unconsumed linear heads for linearId between two timestamps`() {
|
fun `unconsumed linear heads for linearId between two timestamps`() {
|
||||||
val start = Instant.now()
|
|
||||||
val end = start.plus(1, ChronoUnit.SECONDS)
|
|
||||||
|
|
||||||
database.transaction {
|
database.transaction {
|
||||||
|
val start = services.clock.instant()
|
||||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
||||||
sleep(1000)
|
services.clock.advanceBy(1.seconds)
|
||||||
|
val end = services.clock.instant()
|
||||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
vaultFiller.fillWithSomeTestLinearStates(1, "TEST")
|
||||||
// 2 unconsumed states with same external ID
|
// 2 unconsumed states with same external ID
|
||||||
val recordedBetweenExpression = TimeCondition(TimeInstantType.RECORDED, builder { between(start, end) })
|
val recordedBetweenExpression = TimeCondition(TimeInstantType.RECORDED, builder { between(start, end) })
|
||||||
@ -1842,13 +1841,12 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
// specifying Query on Linear state attributes
|
// specifying Query on Linear state attributes
|
||||||
@Test
|
@Test
|
||||||
fun `unconsumed linear heads for linearId between two timestamps for a given external id`() {
|
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 {
|
database.transaction {
|
||||||
|
val start = services.clock.instant()
|
||||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST1")
|
vaultFiller.fillWithSomeTestLinearStates(1, "TEST1")
|
||||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST2")
|
vaultFiller.fillWithSomeTestLinearStates(1, "TEST2")
|
||||||
services.clock.advanceBy(1.seconds)
|
services.clock.advanceBy(1.seconds)
|
||||||
|
val end = services.clock.instant()
|
||||||
vaultFiller.fillWithSomeTestLinearStates(1, "TEST3")
|
vaultFiller.fillWithSomeTestLinearStates(1, "TEST3")
|
||||||
// 2 unconsumed states with same external ID
|
// 2 unconsumed states with same external ID
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user