Flow cleanup

* Change "for who" to "for whom"
* Don't pass parties to FinalityFlow, it can derive them automatically
* Create a basket of nodes instead of individually assembling nodes
* Switch two party trade flow tests to generate a full anonymous identity
This commit is contained in:
Ross Nicoll 2017-07-14 17:50:36 +01:00
parent 7aafcf8c57
commit dfbf06a66d
4 changed files with 17 additions and 11 deletions

View File

@ -78,7 +78,7 @@ open class FinalityFlow(val transactions: Iterable<SignedTransaction>,
/**
* Broadcast a transaction to the participants. By default calls [BroadcastTransactionFlow], however can be
* overridden for more complex transaction delivery protocols (for example where not all parties know each other).
* This implementation will filter out any participants for who there is no well known identity.
* This implementation will filter out any participants for whom there is no well known identity.
*
* @param participants the participants to send the transaction to. This is expected to include extra participants
* and exclude the local node.

View File

@ -145,7 +145,7 @@ object TwoPartyTradeFlow {
// Notarise and record the transaction.
progressTracker.currentStep = RECORDING
return subFlow(FinalityFlow(twiceSignedTx, setOf(otherParty, serviceHub.myInfo.legalIdentity))).single()
return subFlow(FinalityFlow(twiceSignedTx)).single()
}
@Suspendable

View File

@ -44,9 +44,10 @@ class IssuerFlowTest(val anonymous: Boolean) {
@Before
fun start() {
mockNet = MockNetwork(threadPerNode = true)
notaryNode = mockNet.createNotaryNode(null, DUMMY_NOTARY.name)
bankOfCordaNode = mockNet.createPartyNode(notaryNode.network.myAddress, BOC.name)
bankClientNode = mockNet.createPartyNode(notaryNode.network.myAddress, MEGA_CORP.name)
val basketOfNodes = mockNet.createSomeNodes(2)
bankOfCordaNode = basketOfNodes.partyNodes[0]
bankClientNode = basketOfNodes.partyNodes[1]
notaryNode = basketOfNodes.notaryNode
}
@After

View File

@ -8,6 +8,7 @@ import net.corda.core.contracts.*
import net.corda.core.crypto.DigitalSignature
import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.sign
import net.corda.core.crypto.toStringShort
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatedBy
import net.corda.core.flows.InitiatingFlow
@ -185,6 +186,9 @@ class TwoPartyTradeFlowTests {
val notaryNode = mockNet.createNotaryNode(null, DUMMY_NOTARY.name)
val aliceNode = mockNet.createPartyNode(notaryNode.network.myAddress, ALICE.name)
var bobNode = mockNet.createPartyNode(notaryNode.network.myAddress, BOB.name)
aliceNode.services.identityService.registerIdentity(bobNode.info.legalIdentityAndCert)
bobNode.services.identityService.registerIdentity(aliceNode.info.legalIdentityAndCert)
aliceNode.disableDBCloseOnStop()
bobNode.disableDBCloseOnStop()
@ -494,11 +498,12 @@ class TwoPartyTradeFlowTests {
sellerNode: MockNetwork.MockNode,
buyerNode: MockNetwork.MockNode,
assetToSell: StateAndRef<OwnableState>): RunResult {
sellerNode.services.identityService.registerIdentity(buyerNode.info.legalIdentityAndCert)
buyerNode.services.identityService.registerIdentity(sellerNode.info.legalIdentityAndCert)
val anonymousSeller = sellerNode.services.let { serviceHub ->
serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, false)
}
val buyerFlows: Observable<BuyerAcceptor> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine }
val seller = SellerInitiator(buyerNode.info.legalIdentity, notaryNode.info, assetToSell, 1000.DOLLARS)
val seller = SellerInitiator(buyerNode.info.legalIdentity, notaryNode.info, assetToSell, 1000.DOLLARS, anonymousSeller.identity)
val sellerResult = sellerNode.services.startFlow(seller).resultFuture
return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
}
@ -507,17 +512,17 @@ class TwoPartyTradeFlowTests {
class SellerInitiator(val buyer: Party,
val notary: NodeInfo,
val assetToSell: StateAndRef<OwnableState>,
val price: Amount<Currency>) : FlowLogic<SignedTransaction>() {
val price: Amount<Currency>,
val me: AbstractParty) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
send(buyer, Pair(notary.notaryIdentity, price))
val key = serviceHub.keyManagementService.freshKey()
return subFlow(Seller(
buyer,
notary,
assetToSell,
price,
AnonymousParty(key)))
me))
}
}