mirror of
https://github.com/corda/corda.git
synced 2025-01-26 06:09:25 +00:00
Add missing @Suspendable
Add missing @Suspendable to CashIssueFlow, as well as adding sanity check to result of starting CashIssueFlow from IntegrationTestingTutorial.
This commit is contained in:
parent
5d6abb6387
commit
3b8d696379
@ -1,6 +1,7 @@
|
||||
package net.corda.docs
|
||||
|
||||
import com.google.common.util.concurrent.Futures
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import net.corda.contracts.asset.Cash
|
||||
import net.corda.core.contracts.DOLLARS
|
||||
import net.corda.core.contracts.issuedBy
|
||||
@ -21,6 +22,7 @@ import net.corda.testing.expectEvents
|
||||
import net.corda.testing.parallel
|
||||
import net.corda.testing.sequence
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ -58,16 +60,20 @@ class IntegrationTestingTutorial {
|
||||
|
||||
// START 4
|
||||
val issueRef = OpaqueBytes.of(0)
|
||||
val futures = Stack<ListenableFuture<*>>()
|
||||
for (i in 1 .. 10) {
|
||||
thread {
|
||||
aliceProxy.startFlow(::CashIssueFlow,
|
||||
futures.push(aliceProxy.startFlow(::CashIssueFlow,
|
||||
i.DOLLARS,
|
||||
issueRef,
|
||||
bob.nodeInfo.legalIdentity,
|
||||
notary.nodeInfo.notaryIdentity
|
||||
)
|
||||
).returnValue)
|
||||
}
|
||||
}
|
||||
while (!futures.empty()) {
|
||||
futures.pop().getOrThrow()
|
||||
}
|
||||
|
||||
bobVaultUpdates.expectEvents {
|
||||
parallel(
|
||||
@ -86,11 +92,10 @@ class IntegrationTestingTutorial {
|
||||
|
||||
// START 5
|
||||
for (i in 1 .. 10) {
|
||||
val flowHandle = bobProxy.startFlow(::CashPaymentFlow,
|
||||
bobProxy.startFlow(::CashPaymentFlow,
|
||||
i.DOLLARS.issuedBy(alice.nodeInfo.legalIdentity.ref(issueRef)),
|
||||
alice.nodeInfo.legalIdentity
|
||||
)
|
||||
flowHandle.returnValue.getOrThrow()
|
||||
).returnValue.getOrThrow()
|
||||
}
|
||||
|
||||
aliceVaultUpdates.expectEvents {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.corda.flows
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.contracts.asset.Cash
|
||||
import net.corda.core.contracts.Amount
|
||||
import net.corda.core.contracts.PartyAndReference
|
||||
@ -30,6 +31,7 @@ class CashIssueFlow(val amount: Amount<Currency>,
|
||||
recipient: Party,
|
||||
notary: Party) : this(amount, issueRef, recipient, notary, tracker())
|
||||
|
||||
@Suspendable
|
||||
override fun call(): SignedTransaction {
|
||||
progressTracker.currentStep = GENERATING_TX
|
||||
val builder: TransactionBuilder = TransactionType.General.Builder(notary = null)
|
||||
|
@ -32,7 +32,7 @@ open class CashPaymentFlow(val amount: Amount<Issued<Currency>>, val recipient:
|
||||
recipient.owningKey,
|
||||
setOf(amount.token.issuer.party))
|
||||
} catch (e: InsufficientBalanceException) {
|
||||
throw CashException("Insufficent cash for spend", e)
|
||||
throw CashException("Insufficient cash for spend", e)
|
||||
}
|
||||
|
||||
progressTracker.currentStep = SIGNING_TX
|
||||
|
@ -130,7 +130,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
internal fun commitTransaction() {
|
||||
val transaction = TransactionManager.current()
|
||||
try {
|
||||
logger.trace { "Commiting database transaction $transaction on ${Strand.currentStrand()}." }
|
||||
logger.trace { "Committing database transaction $transaction on ${Strand.currentStrand()}." }
|
||||
transaction.commit()
|
||||
} catch (e: SQLException) {
|
||||
// TODO: we will get here if the database is not available. Think about how to shutdown and restart cleanly.
|
||||
|
Loading…
x
Reference in New Issue
Block a user