Merge commit '02348a584d56cdb562581d99be5b56348f7d1001' into chrisr3-os-merge

This commit is contained in:
Chris Rankin
2018-06-22 12:58:41 +01:00
64 changed files with 234 additions and 270 deletions

View File

@ -125,7 +125,7 @@ object TopupIssuerFlow {
val txns: List<SignedTransaction> = reserveLimits.map { amount ->
// request asset issue
logger.info("Requesting currency issue $amount")
val txn = issueCashTo(amount, topupRequest.issueToParty, topupRequest.issuerPartyRef)
val txn = issueCashTo(amount, topupRequest.issueToParty, topupRequest.issuerPartyRef, topupRequest.notaryParty)
progressTracker.currentStep = SENDING_TOP_UP_ISSUE_REQUEST
return@map txn.stx
}
@ -138,10 +138,8 @@ object TopupIssuerFlow {
@Suspendable
private fun issueCashTo(amount: Amount<Currency>,
issueTo: Party,
issuerPartyRef: OpaqueBytes): AbstractCashFlow.Result {
// TODO: pass notary in as request parameter
val notaryParty = serviceHub.networkMapCache.notaryIdentities.firstOrNull()
?: throw IllegalArgumentException("Couldn't find any notary in NetworkMapCache")
issuerPartyRef: OpaqueBytes,
notaryParty: Party): AbstractCashFlow.Result {
// invoke Cash subflow to issue Asset
progressTracker.currentStep = ISSUING
val issueCashFlow = CashIssueFlow(amount, issuerPartyRef, notaryParty)

View File

@ -79,15 +79,15 @@ private fun prepareOurInputsAndOutputs(serviceHub: ServiceHub, lockId: UUID, req
val (inputs, residual) = gatherOurInputs(serviceHub, lockId, sellAmount, request.notary)
// Build and an output state for the counterparty
val transferedFundsOutput = Cash.State(sellAmount, request.counterparty)
val transferredFundsOutput = Cash.State(sellAmount, request.counterparty)
val outputs = if (residual > 0L) {
// Build an output state for the residual change back to us
val residualAmount = Amount(residual, sellAmount.token)
val residualOutput = Cash.State(residualAmount, serviceHub.myInfo.singleIdentity())
listOf(transferedFundsOutput, residualOutput)
listOf(transferredFundsOutput, residualOutput)
} else {
listOf(transferedFundsOutput)
listOf(transferredFundsOutput)
}
return Pair(inputs, outputs)
// DOCEND 2

View File

@ -1,106 +0,0 @@
/*
* R3 Proprietary and Confidential
*
* Copyright (c) 2018 R3 Limited. All rights reserved.
*
* The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
*
* Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
*/
package net.corda.docs.tutorial.mocknetwork
import co.paralleluniverse.fibers.Suspendable
import com.google.common.collect.ImmutableList
import net.corda.core.contracts.requireThat
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.FlowSession
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.InitiatingFlow
import net.corda.core.identity.Party
import net.corda.core.utilities.unwrap
import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.rules.ExpectedException
class TutorialMockNetwork {
@InitiatingFlow
class FlowA(private val otherParty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
val session = initiateFlow(otherParty)
session.receive<Int>().unwrap {
requireThat { "Expected to receive 1" using (it == 1) }
}
session.receive<Int>().unwrap {
requireThat { "Expected to receive 2" using (it == 2) }
}
}
}
@InitiatedBy(FlowA::class)
class FlowB(private val session: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
session.send(1)
session.send(2)
}
}
private lateinit var mockNet: MockNetwork
private lateinit var nodeA: StartedMockNode
private lateinit var nodeB: StartedMockNode
@Rule
@JvmField
val expectedEx: ExpectedException = ExpectedException.none()
@Before
fun setUp() {
mockNet = MockNetwork(ImmutableList.of("net.corda.docs.tutorial.mocknetwork"))
nodeA = mockNet.createPartyNode()
nodeB = mockNet.createPartyNode()
}
@After
fun tearDown() {
mockNet.stopNodes()
}
// @Test
// fun `fail if initiated doesn't send back 1 on first result`() {
// DOCSTART 1
// TODO: Fix this test - accessing the MessagingService directly exposes internal interfaces
// nodeB.setMessagingServiceSpy(object : MessagingServiceSpy(nodeB.network) {
// override fun send(message: Message, target: MessageRecipients, retryId: Long?, sequenceKey: Any, additionalHeaders: Map<String, String>) {
// val messageData = message.data.deserialize<Any>() as? ExistingSessionMessage
// val payload = messageData?.payload
//
// if (payload is DataSessionMessage && payload.payload.deserialize() == 1) {
// val alteredMessageData = messageData.copy(payload = payload.copy(99.serialize())).serialize().bytes
// messagingService.send(InMemoryMessagingNetwork.InMemoryMessage(message.topic, OpaqueBytes(alteredMessageData), message.uniqueMessageId), target, retryId)
// } else {
// messagingService.send(message, target, retryId)
// }
// }
// })
// DOCEND 1
// val initiatingReceiveFlow = nodeA.startFlow(FlowA(nodeB.info.legalIdentities.first()))
//
// mockNet.runNetwork()
//
// expectedEx.expect(IllegalArgumentException::class.java)
// expectedEx.expectMessage("Expected to receive 1")
// initiatingReceiveFlow.getOrThrow()
// }
}

View File

@ -22,7 +22,7 @@ import net.corda.finance.contracts.Fix
import java.util.function.Predicate
fun main(args: Array<String>) {
// Typealias to make the example coherent.
// Type alias to make the example coherent.
val oracle = Any() as AbstractParty
val stx = Any() as SignedTransaction