Flakey test fix

This commit is contained in:
Chris Cochrane 2023-04-21 16:00:19 +01:00
parent fc758ab766
commit e5a6cac9e8
No known key found for this signature in database
GPG Key ID: 4D4602B5BBC63950
2 changed files with 12 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import net.corda.core.flows.*
import net.corda.core.identity.Party
import net.corda.core.internal.concurrent.transpose
import net.corda.core.messaging.startFlow
import net.corda.core.node.services.StatesNotAvailableException
import net.corda.core.node.services.queryBy
import net.corda.core.node.services.vault.QueryCriteria
import net.corda.core.transactions.TransactionBuilder
@ -69,7 +70,11 @@ class ScheduledFlowIntegrationTests {
val state = results.states.firstOrNull() ?: return
require(!state.state.data.processed) { "Cannot spend an already processed state" }
val lock = UUID.randomUUID()
serviceHub.vaultService.softLockReserve(lock, NonEmptySet.of(state.ref))
try {
serviceHub.vaultService.softLockReserve(lock, NonEmptySet.of(state.ref))
} catch (e: StatesNotAvailableException) {
return
}
val notary = state.state.notary
val outputState = SpentState(identity, ourIdentity, state.state.data.destination)
val builder = TransactionBuilder(notary)

View File

@ -4,6 +4,7 @@ import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.*
import net.corda.core.flows.*
import net.corda.core.identity.Party
import net.corda.core.node.services.StatesNotAvailableException
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.NonEmptySet
import net.corda.testing.contracts.DummyContract
@ -25,7 +26,11 @@ class ScheduledFlow(private val stateRef: StateRef) : FlowLogic<Unit>() {
}
require(!scheduledState.processed) { "State should not have been previously processed" }
val lock = UUID.randomUUID()
serviceHub.vaultService.softLockReserve(lock, NonEmptySet.of(state.ref))
try {
serviceHub.vaultService.softLockReserve(lock, NonEmptySet.of(state.ref))
} catch (e: StatesNotAvailableException) {
return
}
val notary = state.state.notary
val newStateOutput = scheduledState.copy(processed = true)
val builder = TransactionBuilder(notary)