Change CashIssueFlow to always issue to ourselves

Change CashIssueFlow to always issue to ourselves, and require the cash is then moved in a separate payment
operation. This more closely models actual operation inside banks, and is a step towards making all move-like
operations go through a uniform verification process.
This commit is contained in:
Ross Nicoll
2017-08-11 17:02:39 +01:00
parent 89476904fc
commit b76d036843
29 changed files with 111 additions and 168 deletions

View File

@ -111,7 +111,7 @@ class NodePerformanceTests {
a.rpcClientToNode().use("A", "A") { connection ->
println("ISSUING")
val doneFutures = (1..100).toList().parallelStream().map {
connection.proxy.startFlow(::CashIssueFlow, 1.DOLLARS, OpaqueBytes.of(0), a.nodeInfo.legalIdentity, a.nodeInfo.notaryIdentity).returnValue
connection.proxy.startFlow(::CashIssueFlow, 1.DOLLARS, OpaqueBytes.of(0), a.nodeInfo.notaryIdentity).returnValue
}.toList()
doneFutures.transpose().get()
println("STARTING PAYMENT")

View File

@ -134,14 +134,10 @@ class DistributedServiceTests : DriverBasedTest() {
}
private fun issueCash(amount: Amount<Currency>) {
val issueHandle = aliceProxy.startFlow(
::CashIssueFlow,
amount, OpaqueBytes.of(0), alice.nodeInfo.legalIdentity, raftNotaryIdentity)
issueHandle.returnValue.getOrThrow()
aliceProxy.startFlow(::CashIssueFlow, amount, OpaqueBytes.of(0), raftNotaryIdentity).returnValue.getOrThrow()
}
private fun paySelf(amount: Amount<Currency>) {
val payHandle = aliceProxy.startFlow(::CashPaymentFlow, amount, alice.nodeInfo.legalIdentity)
payHandle.returnValue.getOrThrow()
aliceProxy.startFlow(::CashPaymentFlow, amount, alice.nodeInfo.legalIdentity).returnValue.getOrThrow()
}
}

View File

@ -93,9 +93,8 @@ class CordaRPCOpsImplTest {
}
// Tell the monitoring service node to issue some cash
val anonymous = false
val recipient = aliceNode.info.legalIdentity
val result = rpc.startFlow(::CashIssueFlow, Amount(quantity, GBP), recipient, rpc.nodeIdentity().legalIdentity, ref, notaryNode.info.notaryIdentity, anonymous)
val result = rpc.startFlow(::CashIssueFlow, Amount(quantity, GBP), ref, notaryNode.info.notaryIdentity)
mockNet.runNetwork()
var issueSmId: StateMachineRunId? = null
@ -133,11 +132,8 @@ class CordaRPCOpsImplTest {
val anonymous = false
val result = rpc.startFlow(::CashIssueFlow,
100.DOLLARS,
aliceNode.info.legalIdentity,
rpc.nodeIdentity().legalIdentity,
OpaqueBytes(ByteArray(1, { 1 })),
notaryNode.info.notaryIdentity,
false
notaryNode.info.notaryIdentity
)
mockNet.runNetwork()
@ -212,14 +208,7 @@ class CordaRPCOpsImplTest {
fun `cash command by user not permissioned for cash`() {
CURRENT_RPC_CONTEXT.set(RpcContext(User("user", "pwd", permissions = emptySet())))
assertThatExceptionOfType(PermissionException::class.java).isThrownBy {
rpc.startFlow(::CashIssueFlow,
Amount(100, USD),
aliceNode.info.legalIdentity,
rpc.nodeIdentity().legalIdentity,
OpaqueBytes(ByteArray(1, { 1 })),
notaryNode.info.notaryIdentity,
false
)
rpc.startFlow(::CashIssueFlow, Amount(100, USD), OpaqueBytes(ByteArray(1, { 1 })), notaryNode.info.notaryIdentity)
}
}

View File

@ -330,11 +330,8 @@ class FlowFrameworkTests {
assertEquals(notary1.info.notaryIdentity, notary2.info.notaryIdentity)
node1.services.startFlow(CashIssueFlow(
2000.DOLLARS,
node1.info.legalIdentity,
node1.info.legalIdentity,
OpaqueBytes.of(0x01),
notary1.info.notaryIdentity,
anonymous = false))
notary1.info.notaryIdentity))
// We pay a couple of times, the notary picking should go round robin
for (i in 1..3) {
val flow = node1.services.startFlow(CashPaymentFlow(500.DOLLARS, node2.info.legalIdentity, anonymous = false))