Advance TestClock instead of sleeping.

This commit is contained in:
Florian Friemel 2018-06-28 17:58:46 +01:00
parent 61d9d475c8
commit 136500d48d
No known key found for this signature in database
GPG Key ID: B355EFB36013CB32

View File

@ -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")
services.clock.advanceBy(1.seconds)
val end = services.clock.instant()
vaultFiller.fillWithSomeTestLinearStates(1, "TEST3")
// 2 unconsumed states with same external ID