mirror of
https://github.com/corda/corda.git
synced 2025-06-19 15:43:52 +00:00
Retired getDefaultNotary test extension method.
Most uses where with MockNetwork which recently got a defaultNotaryIdentity property for dealing with the default single notary case. The remaining uses where in flows.
This commit is contained in:
@ -10,7 +10,6 @@ import net.corda.core.identity.groupAbstractPartyByWellKnownParty
|
|||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.core.utilities.unwrap
|
|
||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.*
|
import net.corda.testing.*
|
||||||
import net.corda.testing.contracts.DummyContract
|
import net.corda.testing.contracts.DummyContract
|
||||||
@ -55,60 +54,14 @@ class CollectSignaturesFlowTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// With this flow, the initiators sends an "offer" to the responder, who then initiates the collect signatures flow.
|
|
||||||
// This flow is a more simplified version of the "TwoPartyTrade" flow and is a useful example of how both the
|
|
||||||
// "collectSignaturesFlow" and "SignTransactionFlow" can be used in practise.
|
|
||||||
object TestFlow {
|
|
||||||
@InitiatingFlow
|
|
||||||
class Initiator(private val state: DummyContract.MultiOwnerState, private val otherParty: Party) : FlowLogic<SignedTransaction>() {
|
|
||||||
@Suspendable
|
|
||||||
override fun call(): SignedTransaction {
|
|
||||||
val session = initiateFlow(otherParty)
|
|
||||||
session.send(state)
|
|
||||||
|
|
||||||
val flow = object : SignTransactionFlow(session) {
|
|
||||||
@Suspendable override fun checkTransaction(stx: SignedTransaction) = requireThat {
|
|
||||||
val tx = stx.tx
|
|
||||||
val ltx = tx.toLedgerTransaction(serviceHub)
|
|
||||||
"There should only be one output state" using (tx.outputs.size == 1)
|
|
||||||
"There should only be one output state" using (tx.inputs.isEmpty())
|
|
||||||
val magicNumberState = ltx.outputsOfType<DummyContract.MultiOwnerState>().single()
|
|
||||||
"Must be 1337 or greater" using (magicNumberState.magicNumber >= 1337)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val stx = subFlow(flow)
|
|
||||||
return waitForLedgerCommit(stx.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@InitiatedBy(TestFlow.Initiator::class)
|
|
||||||
class Responder(private val initiatingSession: FlowSession) : FlowLogic<SignedTransaction>() {
|
|
||||||
@Suspendable
|
|
||||||
override fun call(): SignedTransaction {
|
|
||||||
val state = initiatingSession.receive<DummyContract.MultiOwnerState>().unwrap { it }
|
|
||||||
val notary = serviceHub.getDefaultNotary()
|
|
||||||
|
|
||||||
val myInputKeys = state.participants.map { it.owningKey }
|
|
||||||
val command = Command(DummyContract.Commands.Create(), myInputKeys)
|
|
||||||
val builder = TransactionBuilder(notary).withItems(StateAndContract(state, DummyContract.PROGRAM_ID), command)
|
|
||||||
val ptx = serviceHub.signInitialTransaction(builder)
|
|
||||||
val signature = subFlow(CollectSignatureFlow(ptx, initiatingSession, initiatingSession.counterparty.owningKey))
|
|
||||||
val stx = ptx + signature
|
|
||||||
return subFlow(FinalityFlow(stx))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// With this flow, the initiator starts the "CollectTransactionFlow". It is then the responders responsibility to
|
// With this flow, the initiator starts the "CollectTransactionFlow". It is then the responders responsibility to
|
||||||
// override "checkTransaction" and add whatever logic their require to verify the SignedTransaction they are
|
// override "checkTransaction" and add whatever logic their require to verify the SignedTransaction they are
|
||||||
// receiving off the wire.
|
// receiving off the wire.
|
||||||
object TestFlowTwo {
|
object TestFlow {
|
||||||
@InitiatingFlow
|
@InitiatingFlow
|
||||||
class Initiator(private val state: DummyContract.MultiOwnerState) : FlowLogic<SignedTransaction>() {
|
class Initiator(private val state: DummyContract.MultiOwnerState, private val notary: Party) : FlowLogic<SignedTransaction>() {
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): SignedTransaction {
|
override fun call(): SignedTransaction {
|
||||||
val notary = serviceHub.getDefaultNotary()
|
|
||||||
val myInputKeys = state.participants.map { it.owningKey }
|
val myInputKeys = state.participants.map { it.owningKey }
|
||||||
val command = Command(DummyContract.Commands.Create(), myInputKeys)
|
val command = Command(DummyContract.Commands.Create(), myInputKeys)
|
||||||
val builder = TransactionBuilder(notary).withItems(StateAndContract(state, DummyContract.PROGRAM_ID), command)
|
val builder = TransactionBuilder(notary).withItems(StateAndContract(state, DummyContract.PROGRAM_ID), command)
|
||||||
@ -119,7 +72,7 @@ class CollectSignaturesFlowTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@InitiatedBy(TestFlowTwo.Initiator::class)
|
@InitiatedBy(TestFlow.Initiator::class)
|
||||||
class Responder(private val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
class Responder(private val otherSideSession: FlowSession) : FlowLogic<Unit>() {
|
||||||
@Suspendable override fun call() {
|
@Suspendable override fun call() {
|
||||||
val signFlow = object : SignTransactionFlow(otherSideSession) {
|
val signFlow = object : SignTransactionFlow(otherSideSession) {
|
||||||
@ -149,11 +102,11 @@ class CollectSignaturesFlowTests {
|
|||||||
// Normally this is handled by TransactionKeyFlow, but here we have to manually let A know about the identity
|
// Normally this is handled by TransactionKeyFlow, but here we have to manually let A know about the identity
|
||||||
aliceNode.services.identityService.verifyAndRegisterIdentity(bConfidentialIdentity)
|
aliceNode.services.identityService.verifyAndRegisterIdentity(bConfidentialIdentity)
|
||||||
}
|
}
|
||||||
registerFlowOnAllNodes(TestFlowTwo.Responder::class)
|
registerFlowOnAllNodes(TestFlow.Responder::class)
|
||||||
val magicNumber = 1337
|
val magicNumber = 1337
|
||||||
val parties = listOf(alice, bConfidentialIdentity.party, charlie)
|
val parties = listOf(alice, bConfidentialIdentity.party, charlie)
|
||||||
val state = DummyContract.MultiOwnerState(magicNumber, parties)
|
val state = DummyContract.MultiOwnerState(magicNumber, parties)
|
||||||
val flow = aliceNode.services.startFlow(TestFlowTwo.Initiator(state))
|
val flow = aliceNode.services.startFlow(TestFlow.Initiator(state, notary))
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
val result = flow.resultFuture.getOrThrow()
|
val result = flow.resultFuture.getOrThrow()
|
||||||
result.verifyRequiredSignatures()
|
result.verifyRequiredSignatures()
|
||||||
|
@ -7,8 +7,11 @@ import net.corda.finance.POUNDS
|
|||||||
import net.corda.finance.contracts.asset.Cash
|
import net.corda.finance.contracts.asset.Cash
|
||||||
import net.corda.finance.issuedBy
|
import net.corda.finance.issuedBy
|
||||||
import net.corda.node.services.api.StartedNodeServices
|
import net.corda.node.services.api.StartedNodeServices
|
||||||
import net.corda.testing.*
|
import net.corda.testing.ALICE_NAME
|
||||||
|
import net.corda.testing.BOB_NAME
|
||||||
|
import net.corda.testing.CHARLIE
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
|
import net.corda.testing.singleIdentity
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -32,7 +35,7 @@ class FinalityFlowTests {
|
|||||||
bobServices = bobNode.services
|
bobServices = bobNode.services
|
||||||
alice = aliceNode.info.singleIdentity()
|
alice = aliceNode.info.singleIdentity()
|
||||||
bob = bobNode.info.singleIdentity()
|
bob = bobNode.info.singleIdentity()
|
||||||
notary = aliceServices.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -12,7 +12,6 @@ import net.corda.testing.MEGA_CORP
|
|||||||
import net.corda.testing.MINI_CORP
|
import net.corda.testing.MINI_CORP
|
||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.contracts.DummyContract
|
import net.corda.testing.contracts.DummyContract
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@ -44,7 +43,7 @@ class ResolveTransactionsFlowTest {
|
|||||||
miniCorpNode = mockNet.createPartyNode(MINI_CORP.name)
|
miniCorpNode = mockNet.createPartyNode(MINI_CORP.name)
|
||||||
megaCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
|
megaCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
|
||||||
miniCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
|
miniCorpNode.internals.registerInitiatedFlow(TestResponseFlow::class.java)
|
||||||
notary = notaryNode.services.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
megaCorp = megaCorpNode.info.chooseIdentity()
|
megaCorp = megaCorpNode.info.chooseIdentity()
|
||||||
miniCorp = miniCorpNode.info.chooseIdentity()
|
miniCorp = miniCorpNode.info.chooseIdentity()
|
||||||
}
|
}
|
||||||
@ -55,7 +54,6 @@ class ResolveTransactionsFlowTest {
|
|||||||
}
|
}
|
||||||
// DOCEND 3
|
// DOCEND 3
|
||||||
|
|
||||||
|
|
||||||
// DOCSTART 1
|
// DOCSTART 1
|
||||||
@Test
|
@Test
|
||||||
fun `resolve from two hashes`() {
|
fun `resolve from two hashes`() {
|
||||||
|
@ -9,7 +9,6 @@ import net.corda.finance.contracts.getCashBalances
|
|||||||
import net.corda.finance.flows.CashIssueFlow
|
import net.corda.finance.flows.CashIssueFlow
|
||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
@ -29,7 +28,7 @@ class CustomVaultQueryTest {
|
|||||||
nodeA = mockNet.createPartyNode()
|
nodeA = mockNet.createPartyNode()
|
||||||
nodeB = mockNet.createPartyNode()
|
nodeB = mockNet.createPartyNode()
|
||||||
nodeA.internals.registerInitiatedFlow(TopupIssuerFlow.TopupIssuer::class.java)
|
nodeA.internals.registerInitiatedFlow(TopupIssuerFlow.TopupIssuer::class.java)
|
||||||
notary = nodeA.services.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -9,7 +9,6 @@ import net.corda.finance.contracts.getCashBalances
|
|||||||
import net.corda.finance.flows.CashIssueFlow
|
import net.corda.finance.flows.CashIssueFlow
|
||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@ -28,7 +27,7 @@ class FxTransactionBuildTutorialTest {
|
|||||||
nodeA = mockNet.createPartyNode()
|
nodeA = mockNet.createPartyNode()
|
||||||
nodeB = mockNet.createPartyNode()
|
nodeB = mockNet.createPartyNode()
|
||||||
nodeB.internals.registerInitiatedFlow(ForeignExchangeRemoteFlow::class.java)
|
nodeB.internals.registerInitiatedFlow(ForeignExchangeRemoteFlow::class.java)
|
||||||
notary = nodeA.services.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -9,7 +9,6 @@ import net.corda.finance.contracts.asset.Cash
|
|||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.BOC
|
import net.corda.testing.BOC
|
||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
@ -33,7 +32,7 @@ class CashExitFlowTests {
|
|||||||
cordappPackages = listOf("net.corda.finance.contracts.asset"))
|
cordappPackages = listOf("net.corda.finance.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
||||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
||||||
notary = bankOfCordaNode.services.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
|
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
future.getOrThrow()
|
future.getOrThrow()
|
||||||
|
@ -97,7 +97,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
val notary = notaryNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val cashIssuer = bank.ref(1)
|
val cashIssuer = bank.ref(1)
|
||||||
val cpIssuer = bank.ref(1, 2, 3)
|
val cpIssuer = bank.ref(1, 2, 3)
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1)
|
val issuer = bank.ref(1)
|
||||||
val notary = aliceNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
|
|
||||||
aliceNode.internals.disableDBCloseOnStop()
|
aliceNode.internals.disableDBCloseOnStop()
|
||||||
bobNode.internals.disableDBCloseOnStop()
|
bobNode.internals.disableDBCloseOnStop()
|
||||||
@ -207,7 +207,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bobAddr = bobNode.network.myAddress as InMemoryMessagingNetwork.PeerHandle
|
val bobAddr = bobNode.network.myAddress as InMemoryMessagingNetwork.PeerHandle
|
||||||
mockNet.runNetwork() // Clear network map registration messages
|
mockNet.runNetwork() // Clear network map registration messages
|
||||||
|
|
||||||
val notary = notaryNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
@ -311,7 +311,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bobNode = makeNodeWithTracking(BOB_NAME)
|
val bobNode = makeNodeWithTracking(BOB_NAME)
|
||||||
val bankNode = makeNodeWithTracking(BOC_NAME)
|
val bankNode = makeNodeWithTracking(BOC_NAME)
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
val notary = aliceNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
@ -417,7 +417,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bobNode = makeNodeWithTracking(BOB_NAME)
|
val bobNode = makeNodeWithTracking(BOB_NAME)
|
||||||
val bankNode = makeNodeWithTracking(BOC_NAME)
|
val bankNode = makeNodeWithTracking(BOC_NAME)
|
||||||
|
|
||||||
val notary = aliceNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val alice: Party = aliceNode.info.singleIdentity()
|
val alice: Party = aliceNode.info.singleIdentity()
|
||||||
val bank: Party = bankNode.info.singleIdentity()
|
val bank: Party = bankNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
@ -569,7 +569,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
||||||
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
val bankNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
|
|
||||||
val notary = aliceNode.services.getDefaultNotary()
|
val notary = mockNet.defaultNotaryIdentity
|
||||||
val alice = aliceNode.info.singleIdentity()
|
val alice = aliceNode.info.singleIdentity()
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
@ -607,8 +607,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
node: StartedNode<*>,
|
node: StartedNode<*>,
|
||||||
notaryNode: StartedNode<*>,
|
notaryNode: StartedNode<*>,
|
||||||
vararg extraSigningNodes: StartedNode<*>): Map<SecureHash, SignedTransaction> {
|
vararg extraSigningNodes: StartedNode<*>): Map<SecureHash, SignedTransaction> {
|
||||||
|
val notaryParty = mockNet.defaultNotaryIdentity
|
||||||
val notaryParty = node.services.getDefaultNotary()
|
|
||||||
val signed = wtxToSign.map {
|
val signed = wtxToSign.map {
|
||||||
val id = it.id
|
val id = it.id
|
||||||
val sigs = mutableListOf<TransactionSignature>()
|
val sigs = mutableListOf<TransactionSignature>()
|
||||||
@ -714,7 +713,10 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RecordingTransactionStorage(val database: CordaPersistence, val delegate: WritableTransactionStorage) : WritableTransactionStorage, SingletonSerializeAsToken() {
|
class RecordingTransactionStorage(
|
||||||
|
private val database: CordaPersistence,
|
||||||
|
private val delegate: WritableTransactionStorage
|
||||||
|
) : WritableTransactionStorage, SingletonSerializeAsToken() {
|
||||||
override fun track(): DataFeed<List<SignedTransaction>, SignedTransaction> {
|
override fun track(): DataFeed<List<SignedTransaction>, SignedTransaction> {
|
||||||
return database.transaction {
|
return database.transaction {
|
||||||
delegate.track()
|
delegate.track()
|
||||||
|
@ -19,7 +19,6 @@ import net.corda.node.services.statemachine.StateMachineManager
|
|||||||
import net.corda.testing.chooseIdentity
|
import net.corda.testing.chooseIdentity
|
||||||
import net.corda.testing.contracts.DummyContract
|
import net.corda.testing.contracts.DummyContract
|
||||||
import net.corda.testing.dummyCommand
|
import net.corda.testing.dummyCommand
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
@ -34,9 +33,10 @@ class ScheduledFlowTests {
|
|||||||
val SORTING = Sort(listOf(Sort.SortColumn(SortAttribute.Standard(Sort.CommonStateAttribute.STATE_REF_TXN_ID), Sort.Direction.DESC)))
|
val SORTING = Sort(listOf(Sort.SortColumn(SortAttribute.Standard(Sort.CommonStateAttribute.STATE_REF_TXN_ID), Sort.Direction.DESC)))
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var mockNet: MockNetwork
|
private lateinit var mockNet: MockNetwork
|
||||||
lateinit var nodeA: StartedNode<MockNetwork.MockNode>
|
private lateinit var nodeA: StartedNode<MockNetwork.MockNode>
|
||||||
lateinit var nodeB: StartedNode<MockNetwork.MockNode>
|
private lateinit var nodeB: StartedNode<MockNetwork.MockNode>
|
||||||
|
private lateinit var notary: Party
|
||||||
|
|
||||||
data class ScheduledState(val creationTime: Instant,
|
data class ScheduledState(val creationTime: Instant,
|
||||||
val source: Party,
|
val source: Party,
|
||||||
@ -55,11 +55,10 @@ class ScheduledFlowTests {
|
|||||||
override val participants: List<Party> get() = listOf(source, destination)
|
override val participants: List<Party> get() = listOf(source, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
class InsertInitialStateFlow(private val destination: Party) : FlowLogic<Unit>() {
|
class InsertInitialStateFlow(private val destination: Party, private val notary: Party) : FlowLogic<Unit>() {
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call() {
|
override fun call() {
|
||||||
val scheduledState = ScheduledState(serviceHub.clock.instant(), ourIdentity, destination)
|
val scheduledState = ScheduledState(serviceHub.clock.instant(), ourIdentity, destination)
|
||||||
val notary = serviceHub.getDefaultNotary()
|
|
||||||
val builder = TransactionBuilder(notary)
|
val builder = TransactionBuilder(notary)
|
||||||
.addOutputState(scheduledState, DummyContract.PROGRAM_ID)
|
.addOutputState(scheduledState, DummyContract.PROGRAM_ID)
|
||||||
.addCommand(dummyCommand(ourIdentity.owningKey))
|
.addCommand(dummyCommand(ourIdentity.owningKey))
|
||||||
@ -93,12 +92,9 @@ class ScheduledFlowTests {
|
|||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.testing.contracts"))
|
mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.testing.contracts"))
|
||||||
val a = mockNet.createUnstartedNode()
|
nodeA = mockNet.createNode()
|
||||||
val b = mockNet.createUnstartedNode()
|
nodeB = mockNet.createNode()
|
||||||
|
notary = mockNet.defaultNotaryIdentity
|
||||||
mockNet.startNodes()
|
|
||||||
nodeA = a.started!!
|
|
||||||
nodeB = b.started!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@ -116,7 +112,7 @@ class ScheduledFlowTests {
|
|||||||
countScheduledFlows++
|
countScheduledFlows++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeA.services.startFlow(InsertInitialStateFlow(nodeB.info.chooseIdentity()))
|
nodeA.services.startFlow(InsertInitialStateFlow(nodeB.info.chooseIdentity(), notary))
|
||||||
mockNet.waitQuiescent()
|
mockNet.waitQuiescent()
|
||||||
val stateFromA = nodeA.database.transaction {
|
val stateFromA = nodeA.database.transaction {
|
||||||
nodeA.services.vaultService.queryBy<ScheduledState>().states.single()
|
nodeA.services.vaultService.queryBy<ScheduledState>().states.single()
|
||||||
@ -134,8 +130,8 @@ class ScheduledFlowTests {
|
|||||||
val N = 100
|
val N = 100
|
||||||
val futures = mutableListOf<CordaFuture<*>>()
|
val futures = mutableListOf<CordaFuture<*>>()
|
||||||
for (i in 0 until N) {
|
for (i in 0 until N) {
|
||||||
futures.add(nodeA.services.startFlow(InsertInitialStateFlow(nodeB.info.chooseIdentity())).resultFuture)
|
futures.add(nodeA.services.startFlow(InsertInitialStateFlow(nodeB.info.chooseIdentity(), notary)).resultFuture)
|
||||||
futures.add(nodeB.services.startFlow(InsertInitialStateFlow(nodeA.info.chooseIdentity())).resultFuture)
|
futures.add(nodeB.services.startFlow(InsertInitialStateFlow(nodeA.info.chooseIdentity(), notary)).resultFuture)
|
||||||
}
|
}
|
||||||
mockNet.waitQuiescent()
|
mockNet.waitQuiescent()
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class FlowFrameworkTests {
|
|||||||
// Extract identities
|
// Extract identities
|
||||||
alice = aliceNode.info.singleIdentity()
|
alice = aliceNode.info.singleIdentity()
|
||||||
bob = bobNode.info.singleIdentity()
|
bob = bobNode.info.singleIdentity()
|
||||||
notaryIdentity = aliceNode.services.getDefaultNotary()
|
notaryIdentity = mockNet.defaultNotaryIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -17,7 +17,6 @@ import net.corda.node.services.api.StartedNodeServices
|
|||||||
import net.corda.testing.ALICE_NAME
|
import net.corda.testing.ALICE_NAME
|
||||||
import net.corda.testing.contracts.DummyContract
|
import net.corda.testing.contracts.DummyContract
|
||||||
import net.corda.testing.dummyCommand
|
import net.corda.testing.dummyCommand
|
||||||
import net.corda.testing.getDefaultNotary
|
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNodeParameters
|
import net.corda.testing.node.MockNodeParameters
|
||||||
import net.corda.testing.singleIdentity
|
import net.corda.testing.singleIdentity
|
||||||
@ -42,7 +41,7 @@ class NotaryServiceTests {
|
|||||||
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
|
mockNet = MockNetwork(cordappPackages = listOf("net.corda.testing.contracts"))
|
||||||
aliceServices = mockNet.createNode(MockNodeParameters(legalName = ALICE_NAME)).services
|
aliceServices = mockNet.createNode(MockNodeParameters(legalName = ALICE_NAME)).services
|
||||||
notaryServices = mockNet.defaultNotaryNode.services //TODO get rid of that
|
notaryServices = mockNet.defaultNotaryNode.services //TODO get rid of that
|
||||||
notary = aliceServices.getDefaultNotary()
|
notary = mockNet.defaultNotaryIdentity
|
||||||
alice = aliceServices.myInfo.singleIdentity()
|
alice = aliceServices.myInfo.singleIdentity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import net.corda.core.identity.Party
|
|||||||
import net.corda.core.identity.PartyAndCertificate
|
import net.corda.core.identity.PartyAndCertificate
|
||||||
import net.corda.core.internal.cert
|
import net.corda.core.internal.cert
|
||||||
import net.corda.core.node.NodeInfo
|
import net.corda.core.node.NodeInfo
|
||||||
import net.corda.core.node.ServiceHub
|
|
||||||
import net.corda.core.node.services.IdentityService
|
import net.corda.core.node.services.IdentityService
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
import net.corda.core.utilities.OpaqueBytes
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
@ -178,8 +177,6 @@ fun NodeInfo.singleIdentityAndCert(): PartyAndCertificate = legalIdentitiesAndCe
|
|||||||
* Extract a single identity from the node info. Throws an error if the node has multiple identities.
|
* Extract a single identity from the node info. Throws an error if the node has multiple identities.
|
||||||
*/
|
*/
|
||||||
fun NodeInfo.singleIdentity(): Party = singleIdentityAndCert().party
|
fun NodeInfo.singleIdentity(): Party = singleIdentityAndCert().party
|
||||||
/** Returns the identity of the first notary found on the network */
|
|
||||||
fun ServiceHub.getDefaultNotary(): Party = networkMapCache.notaryIdentities.first()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method on a mock was called, but no behaviour was previously specified for that method.
|
* A method on a mock was called, but no behaviour was previously specified for that method.
|
||||||
|
Reference in New Issue
Block a user