mirror of
https://github.com/corda/corda.git
synced 2025-03-22 20:15:19 +00:00
Enable anonymisation in integration testing tutorial
Enable anonymisation in integration testing tutorial, and as a requirement fix a bug where the counterparty anonymous identity was not registered by `TransactionKeyFlow`.
This commit is contained in:
parent
dfbf06a66d
commit
b7ee7d42a5
@ -31,7 +31,6 @@ class TransactionKeyFlow(val otherSide: Party,
|
|||||||
override fun call(): LinkedHashMap<Party, AnonymisedIdentity> {
|
override fun call(): LinkedHashMap<Party, AnonymisedIdentity> {
|
||||||
progressTracker.currentStep = AWAITING_KEY
|
progressTracker.currentStep = AWAITING_KEY
|
||||||
val legalIdentityAnonymous = serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, revocationEnabled)
|
val legalIdentityAnonymous = serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, revocationEnabled)
|
||||||
serviceHub.identityService.registerAnonymousIdentity(legalIdentityAnonymous.identity, serviceHub.myInfo.legalIdentity, legalIdentityAnonymous.certPath)
|
|
||||||
|
|
||||||
// Special case that if we're both parties, a single identity is generated
|
// Special case that if we're both parties, a single identity is generated
|
||||||
val identities = LinkedHashMap<Party, AnonymisedIdentity>()
|
val identities = LinkedHashMap<Party, AnonymisedIdentity>()
|
||||||
@ -39,6 +38,7 @@ class TransactionKeyFlow(val otherSide: Party,
|
|||||||
identities.put(otherSide, legalIdentityAnonymous)
|
identities.put(otherSide, legalIdentityAnonymous)
|
||||||
} else {
|
} else {
|
||||||
val otherSideAnonymous = sendAndReceive<AnonymisedIdentity>(otherSide, legalIdentityAnonymous).unwrap { validateIdentity(otherSide, it) }
|
val otherSideAnonymous = sendAndReceive<AnonymisedIdentity>(otherSide, legalIdentityAnonymous).unwrap { validateIdentity(otherSide, it) }
|
||||||
|
serviceHub.identityService.registerAnonymousIdentity(otherSideAnonymous.identity, otherSide, otherSideAnonymous.certPath)
|
||||||
identities.put(serviceHub.myInfo.legalIdentity, legalIdentityAnonymous)
|
identities.put(serviceHub.myInfo.legalIdentity, legalIdentityAnonymous)
|
||||||
identities.put(otherSide, otherSideAnonymous)
|
identities.put(otherSide, otherSideAnonymous)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import net.corda.core.getOrThrow
|
|||||||
import net.corda.core.messaging.startFlow
|
import net.corda.core.messaging.startFlow
|
||||||
import net.corda.core.node.services.ServiceInfo
|
import net.corda.core.node.services.ServiceInfo
|
||||||
import net.corda.core.node.services.Vault
|
import net.corda.core.node.services.Vault
|
||||||
|
import net.corda.core.node.services.vault.QueryCriteria
|
||||||
import net.corda.core.utilities.OpaqueBytes
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
import net.corda.testing.ALICE
|
import net.corda.testing.ALICE
|
||||||
import net.corda.testing.BOB
|
import net.corda.testing.BOB
|
||||||
@ -57,8 +58,9 @@ class IntegrationTestingTutorial {
|
|||||||
// END 2
|
// END 2
|
||||||
|
|
||||||
// START 3
|
// START 3
|
||||||
val bobVaultUpdates = bobProxy.vaultAndUpdates().second
|
val criteria = QueryCriteria.VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||||
val aliceVaultUpdates = aliceProxy.vaultAndUpdates().second
|
val (_, bobVaultUpdates) = bobProxy.vaultTrackByCriteria<Cash.State>(Cash.State::class.java, criteria)
|
||||||
|
val (_, aliceVaultUpdates) = aliceProxy.vaultTrackByCriteria<Cash.State>(Cash.State::class.java, criteria)
|
||||||
// END 3
|
// END 3
|
||||||
|
|
||||||
// START 4
|
// START 4
|
||||||
@ -70,8 +72,7 @@ class IntegrationTestingTutorial {
|
|||||||
i.DOLLARS,
|
i.DOLLARS,
|
||||||
issueRef,
|
issueRef,
|
||||||
bob.nodeInfo.legalIdentity,
|
bob.nodeInfo.legalIdentity,
|
||||||
notary.nodeInfo.notaryIdentity,
|
notary.nodeInfo.notaryIdentity
|
||||||
false // Not anonymised
|
|
||||||
).returnValue)
|
).returnValue)
|
||||||
}
|
}
|
||||||
}.forEach(Thread::join) // Ensure the stack of futures is populated.
|
}.forEach(Thread::join) // Ensure the stack of futures is populated.
|
||||||
@ -94,7 +95,7 @@ class IntegrationTestingTutorial {
|
|||||||
|
|
||||||
// START 5
|
// START 5
|
||||||
for (i in 1..10) {
|
for (i in 1..10) {
|
||||||
bobProxy.startFlow(::CashPaymentFlow, i.DOLLARS, alice.nodeInfo.legalIdentity, false).returnValue.getOrThrow()
|
bobProxy.startFlow(::CashPaymentFlow, i.DOLLARS, alice.nodeInfo.legalIdentity).returnValue.getOrThrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceVaultUpdates.expectEvents {
|
aliceVaultUpdates.expectEvents {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user