mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
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:
parent
7aafcf8c57
commit
dfbf06a66d
@ -78,7 +78,7 @@ open class FinalityFlow(val transactions: Iterable<SignedTransaction>,
|
|||||||
/**
|
/**
|
||||||
* Broadcast a transaction to the participants. By default calls [BroadcastTransactionFlow], however can be
|
* 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).
|
* 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
|
* @param participants the participants to send the transaction to. This is expected to include extra participants
|
||||||
* and exclude the local node.
|
* and exclude the local node.
|
||||||
|
@ -145,7 +145,7 @@ object TwoPartyTradeFlow {
|
|||||||
|
|
||||||
// Notarise and record the transaction.
|
// Notarise and record the transaction.
|
||||||
progressTracker.currentStep = RECORDING
|
progressTracker.currentStep = RECORDING
|
||||||
return subFlow(FinalityFlow(twiceSignedTx, setOf(otherParty, serviceHub.myInfo.legalIdentity))).single()
|
return subFlow(FinalityFlow(twiceSignedTx)).single()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
|
@ -44,9 +44,10 @@ class IssuerFlowTest(val anonymous: Boolean) {
|
|||||||
@Before
|
@Before
|
||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(threadPerNode = true)
|
mockNet = MockNetwork(threadPerNode = true)
|
||||||
notaryNode = mockNet.createNotaryNode(null, DUMMY_NOTARY.name)
|
val basketOfNodes = mockNet.createSomeNodes(2)
|
||||||
bankOfCordaNode = mockNet.createPartyNode(notaryNode.network.myAddress, BOC.name)
|
bankOfCordaNode = basketOfNodes.partyNodes[0]
|
||||||
bankClientNode = mockNet.createPartyNode(notaryNode.network.myAddress, MEGA_CORP.name)
|
bankClientNode = basketOfNodes.partyNodes[1]
|
||||||
|
notaryNode = basketOfNodes.notaryNode
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -8,6 +8,7 @@ import net.corda.core.contracts.*
|
|||||||
import net.corda.core.crypto.DigitalSignature
|
import net.corda.core.crypto.DigitalSignature
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.crypto.sign
|
import net.corda.core.crypto.sign
|
||||||
|
import net.corda.core.crypto.toStringShort
|
||||||
import net.corda.core.flows.FlowLogic
|
import net.corda.core.flows.FlowLogic
|
||||||
import net.corda.core.flows.InitiatedBy
|
import net.corda.core.flows.InitiatedBy
|
||||||
import net.corda.core.flows.InitiatingFlow
|
import net.corda.core.flows.InitiatingFlow
|
||||||
@ -185,6 +186,9 @@ class TwoPartyTradeFlowTests {
|
|||||||
val notaryNode = mockNet.createNotaryNode(null, DUMMY_NOTARY.name)
|
val notaryNode = mockNet.createNotaryNode(null, DUMMY_NOTARY.name)
|
||||||
val aliceNode = mockNet.createPartyNode(notaryNode.network.myAddress, ALICE.name)
|
val aliceNode = mockNet.createPartyNode(notaryNode.network.myAddress, ALICE.name)
|
||||||
var bobNode = mockNet.createPartyNode(notaryNode.network.myAddress, BOB.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()
|
aliceNode.disableDBCloseOnStop()
|
||||||
bobNode.disableDBCloseOnStop()
|
bobNode.disableDBCloseOnStop()
|
||||||
|
|
||||||
@ -494,11 +498,12 @@ class TwoPartyTradeFlowTests {
|
|||||||
sellerNode: MockNetwork.MockNode,
|
sellerNode: MockNetwork.MockNode,
|
||||||
buyerNode: MockNetwork.MockNode,
|
buyerNode: MockNetwork.MockNode,
|
||||||
assetToSell: StateAndRef<OwnableState>): RunResult {
|
assetToSell: StateAndRef<OwnableState>): RunResult {
|
||||||
sellerNode.services.identityService.registerIdentity(buyerNode.info.legalIdentityAndCert)
|
val anonymousSeller = sellerNode.services.let { serviceHub ->
|
||||||
buyerNode.services.identityService.registerIdentity(sellerNode.info.legalIdentityAndCert)
|
serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, false)
|
||||||
|
}
|
||||||
val buyerFlows: Observable<BuyerAcceptor> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
|
val buyerFlows: Observable<BuyerAcceptor> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
|
||||||
val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine }
|
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
|
val sellerResult = sellerNode.services.startFlow(seller).resultFuture
|
||||||
return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
|
return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
|
||||||
}
|
}
|
||||||
@ -507,17 +512,17 @@ class TwoPartyTradeFlowTests {
|
|||||||
class SellerInitiator(val buyer: Party,
|
class SellerInitiator(val buyer: Party,
|
||||||
val notary: NodeInfo,
|
val notary: NodeInfo,
|
||||||
val assetToSell: StateAndRef<OwnableState>,
|
val assetToSell: StateAndRef<OwnableState>,
|
||||||
val price: Amount<Currency>) : FlowLogic<SignedTransaction>() {
|
val price: Amount<Currency>,
|
||||||
|
val me: AbstractParty) : FlowLogic<SignedTransaction>() {
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): SignedTransaction {
|
override fun call(): SignedTransaction {
|
||||||
send(buyer, Pair(notary.notaryIdentity, price))
|
send(buyer, Pair(notary.notaryIdentity, price))
|
||||||
val key = serviceHub.keyManagementService.freshKey()
|
|
||||||
return subFlow(Seller(
|
return subFlow(Seller(
|
||||||
buyer,
|
buyer,
|
||||||
notary,
|
notary,
|
||||||
assetToSell,
|
assetToSell,
|
||||||
price,
|
price,
|
||||||
AnonymousParty(key)))
|
me))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user