mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
CORDA-939 - Dont expose FlowStateMachine via public API (#2438)
* Create CordaInternal attribute for properties on public classes that are not part of the api and apply to FlowLogic.stateMachine * Remove startFlow from public test api and replace with startFlowAndReturnFuture * Update api-current with changed signature * Change test used in documentation to use public test methods * Remove the rest of the unneccessary usages of the startFlow test utility * Remove extra whitespace * Rename startFlowAndReturnFuture back to startFlow * Update api * The annotation doesn't appear unless its marked as on the actual getter and setter * Updated docs and removed pointless attribute * Deleted whitespace
This commit is contained in:
@ -92,7 +92,7 @@ class BFTNotaryServiceTests {
|
||||
addOutputState(DummyContract.SingleOwnerState(owner = info.chooseIdentity()), DummyContract.PROGRAM_ID, AlwaysAcceptAttachmentConstraint)
|
||||
}
|
||||
// Create a new consensus while the redundant replica is sleeping:
|
||||
services.startFlow(NotaryFlow.Client(trivialTx)).resultFuture
|
||||
services.startFlow(NotaryFlow.Client(trivialTx))
|
||||
}
|
||||
mockNet.runNetwork()
|
||||
f.getOrThrow()
|
||||
@ -127,7 +127,7 @@ class BFTNotaryServiceTests {
|
||||
val flows = spendTxs.map { NotaryFlow.Client(it) }
|
||||
val stateMachines = flows.map { services.startFlow(it) }
|
||||
mockNet.runNetwork()
|
||||
val results = stateMachines.map { Try.on { it.resultFuture.getOrThrow() } }
|
||||
val results = stateMachines.map { Try.on { it.getOrThrow() } }
|
||||
val successfulIndex = results.mapIndexedNotNull { index, result ->
|
||||
if (result is Try.Success) {
|
||||
val signers = result.value.map { it.by }
|
||||
|
@ -44,7 +44,7 @@ class RaftNotaryServiceTests {
|
||||
val firstSpendTx = bankA.services.signInitialTransaction(firstTxBuilder)
|
||||
|
||||
val firstSpend = bankA.services.startFlow(NotaryFlow.Client(firstSpendTx))
|
||||
firstSpend.resultFuture.getOrThrow()
|
||||
firstSpend.getOrThrow()
|
||||
|
||||
val secondSpendBuilder = TransactionBuilder(defaultNotaryIdentity).withItems(inputState).run {
|
||||
val dummyState = DummyContract.SingleOwnerState(0, bankA.info.chooseIdentity())
|
||||
@ -55,7 +55,7 @@ class RaftNotaryServiceTests {
|
||||
val secondSpendTx = bankA.services.signInitialTransaction(secondSpendBuilder)
|
||||
val secondSpend = bankA.services.startFlow(NotaryFlow.Client(secondSpendTx))
|
||||
|
||||
val ex = assertFailsWith(NotaryException::class) { secondSpend.resultFuture.getOrThrow() }
|
||||
val ex = assertFailsWith(NotaryException::class) { secondSpend.getOrThrow() }
|
||||
val error = ex.error as NotaryError.Conflict
|
||||
assertEquals(error.txId, secondSpendTx.id)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class FlowVersioningTest : NodeBasedTest() {
|
||||
val bob = startNode(BOB_NAME, platformVersion = 3)
|
||||
bob.internals.installCoreFlow(PretendInitiatingCoreFlow::class, ::PretendInitiatedCoreFlow)
|
||||
val (alicePlatformVersionAccordingToBob, bobPlatformVersionAccordingToAlice) = alice.services.startFlow(
|
||||
PretendInitiatingCoreFlow(bob.info.chooseIdentity())).resultFuture.getOrThrow()
|
||||
PretendInitiatingCoreFlow(bob.info.chooseIdentity())).getOrThrow()
|
||||
assertThat(alicePlatformVersionAccordingToBob).isEqualTo(2)
|
||||
assertThat(bobPlatformVersionAccordingToAlice).isEqualTo(3)
|
||||
}
|
||||
|
@ -3,9 +3,7 @@ package net.corda.services.messaging
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.client.rpc.CordaRPCClient
|
||||
import net.corda.client.rpc.CordaRPCConnection
|
||||
import net.corda.core.crypto.generateKeyPair
|
||||
import net.corda.core.crypto.random63BitValue
|
||||
import net.corda.core.crypto.toStringShort
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.FlowSession
|
||||
import net.corda.core.flows.InitiatedBy
|
||||
@ -193,7 +191,7 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
bob.registerInitiatedFlow(ReceiveFlow::class.java)
|
||||
val bobParty = bob.info.chooseIdentity()
|
||||
// Perform a protocol exchange to force the peer queue to be created
|
||||
alice.services.startFlow(SendFlow(bobParty, 0)).resultFuture.getOrThrow()
|
||||
alice.services.startFlow(SendFlow(bobParty, 0)).getOrThrow()
|
||||
return bobParty
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class NetworkParametersTest {
|
||||
val alice = mockNet.createPartyNode(ALICE_NAME)
|
||||
assertThat(alice.services.networkMapCache.notaryIdentities).doesNotContain(fakeNotaryId)
|
||||
assertFails {
|
||||
alice.services.startFlow(CashIssueFlow(500.DOLLARS, OpaqueBytes.of(0x01), fakeNotaryId)).resultFuture.getOrThrow()
|
||||
alice.services.startFlow(CashIssueFlow(500.DOLLARS, OpaqueBytes.of(0x01), fakeNotaryId)).getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,7 +536,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
val buyerFlows: Observable<out FlowLogic<*>> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
|
||||
val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine }
|
||||
val seller = SellerInitiator(buyer, notary, assetToSell, 1000.DOLLARS, anonymous)
|
||||
val sellerResult = sellerNode.services.startFlow(seller).resultFuture
|
||||
val sellerResult = sellerNode.services.startFlow(seller)
|
||||
return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class NotaryChangeTests {
|
||||
|
||||
mockNet.runNetwork()
|
||||
|
||||
val newState = future.resultFuture.getOrThrow()
|
||||
val newState = future.getOrThrow()
|
||||
assertEquals(newState.state.notary, newNotary)
|
||||
val loadedStateA = clientNodeA.services.loadState(newState.ref)
|
||||
val loadedStateB = clientNodeB.services.loadState(newState.ref)
|
||||
@ -91,7 +91,7 @@ class NotaryChangeTests {
|
||||
mockNet.runNetwork()
|
||||
|
||||
assertThatExceptionOfType(StateReplacementException::class.java).isThrownBy {
|
||||
future.resultFuture.getOrThrow()
|
||||
future.getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class NotaryChangeTests {
|
||||
val flow = NotaryChangeFlow(state, newNotary)
|
||||
val future = clientNodeA.services.startFlow(flow)
|
||||
mockNet.runNetwork()
|
||||
val newState = future.resultFuture.getOrThrow()
|
||||
val newState = future.getOrThrow()
|
||||
assertEquals(newState.state.notary, newNotary)
|
||||
|
||||
val recordedTx = clientNodeA.services.validatedTransactions.getTransaction(newState.ref.txhash)!!
|
||||
@ -150,7 +150,7 @@ class NotaryChangeTests {
|
||||
val future = node.services.startFlow(flow)
|
||||
mockNet.runNetwork()
|
||||
|
||||
return future.resultFuture.getOrThrow()
|
||||
return future.getOrThrow()
|
||||
}
|
||||
|
||||
private fun moveState(state: StateAndRef<DummyContract.SingleOwnerState>, fromNode: StartedNode<*>, toNode: StartedNode<*>): StateAndRef<DummyContract.SingleOwnerState> {
|
||||
@ -161,7 +161,7 @@ class NotaryChangeTests {
|
||||
val future = fromNode.services.startFlow(notaryFlow)
|
||||
mockNet.runNetwork()
|
||||
|
||||
val notarySignature = future.resultFuture.getOrThrow()
|
||||
val notarySignature = future.getOrThrow()
|
||||
val finalTransaction = stx + notarySignature
|
||||
|
||||
fromNode.services.recordTransactions(finalTransaction)
|
||||
|
@ -143,8 +143,8 @@ class ScheduledFlowTests {
|
||||
val N = 100
|
||||
val futures = mutableListOf<CordaFuture<*>>()
|
||||
for (i in 0 until N) {
|
||||
futures.add(aliceNode.services.startFlow(InsertInitialStateFlow(bob, notary)).resultFuture)
|
||||
futures.add(bobNode.services.startFlow(InsertInitialStateFlow(alice, notary)).resultFuture)
|
||||
futures.add(aliceNode.services.startFlow(InsertInitialStateFlow(bob, notary)))
|
||||
futures.add(bobNode.services.startFlow(InsertInitialStateFlow(alice, notary)))
|
||||
}
|
||||
mockNet.waitQuiescent()
|
||||
|
||||
|
@ -38,7 +38,7 @@ import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetwork.MockNode
|
||||
import net.corda.testing.node.MockNodeParameters
|
||||
import net.corda.testing.node.pumpReceive
|
||||
import net.corda.testing.node.startFlow
|
||||
import net.corda.testing.node.internal.startFlow
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType
|
||||
|
@ -19,8 +19,8 @@ import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.core.dummyCommand
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNodeParameters
|
||||
import net.corda.testing.node.startFlow
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.node.startFlow
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@ -120,11 +120,11 @@ class NotaryServiceTests {
|
||||
// Note that the notary will only return identical signatures when using deterministic signature
|
||||
// schemes (e.g. EdDSA) and when deterministic metadata is attached (no timestamps or nonces).
|
||||
// We only really care that both signatures are over the same transaction and by the same notary.
|
||||
val sig1 = f1.resultFuture.getOrThrow().single()
|
||||
val sig1 = f1.getOrThrow().single()
|
||||
assertEquals(sig1.by, notary.owningKey)
|
||||
assertTrue(sig1.isValid(stx.id))
|
||||
|
||||
val sig2 = f2.resultFuture.getOrThrow().single()
|
||||
val sig2 = f2.getOrThrow().single()
|
||||
assertEquals(sig2.by, notary.owningKey)
|
||||
assertTrue(sig2.isValid(stx.id))
|
||||
}
|
||||
@ -153,7 +153,7 @@ class NotaryServiceTests {
|
||||
|
||||
mockNet.runNetwork()
|
||||
|
||||
val ex = assertFailsWith(NotaryException::class) { future.resultFuture.getOrThrow() }
|
||||
val ex = assertFailsWith(NotaryException::class) { future.getOrThrow() }
|
||||
val notaryError = ex.error as NotaryError.Conflict
|
||||
assertEquals(notaryError.txId, stx2.id)
|
||||
notaryError.conflict.verified()
|
||||
@ -161,7 +161,7 @@ class NotaryServiceTests {
|
||||
|
||||
private fun runNotaryClient(stx: SignedTransaction): CordaFuture<List<TransactionSignature>> {
|
||||
val flow = NotaryFlow.Client(stx)
|
||||
val future = aliceServices.startFlow(flow).resultFuture
|
||||
val future = aliceServices.startFlow(flow)
|
||||
mockNet.runNetwork()
|
||||
return future
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class ValidatingNotaryServiceTests {
|
||||
|
||||
private fun runClient(stx: SignedTransaction): CordaFuture<List<TransactionSignature>> {
|
||||
val flow = NotaryFlow.Client(stx)
|
||||
val future = aliceServices.startFlow(flow).resultFuture
|
||||
val future = aliceServices.startFlow(flow)
|
||||
mockNet.runNetwork()
|
||||
return future
|
||||
}
|
||||
|
Reference in New Issue
Block a user