diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt index 51c36d4d56..60a5628773 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt @@ -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