mirror of
https://github.com/corda/corda.git
synced 2025-06-17 06:38:21 +00:00
Standardise identities used in tests, demos, etc.
Standaridise the identity names of Alice, Bob and Charlie, notary, map service, etc. in order to ensure consistency across the code base and reduce number of places that have to be changed to introduce proper X.500 names. Move Alice, Bob & Charlie identities into the utilities package so they can be used in demos
This commit is contained in:
@ -6,6 +6,8 @@ import net.corda.core.list
|
||||
import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.readLines
|
||||
import net.corda.core.utilities.DUMMY_BANK_A
|
||||
import net.corda.core.utilities.DUMMY_NOTARY
|
||||
import net.corda.node.LOGS_DIRECTORY_NAME
|
||||
import net.corda.node.services.api.RegulatorService
|
||||
import net.corda.node.services.transactions.SimpleNotaryService
|
||||
@ -36,7 +38,7 @@ class DriverTests {
|
||||
@Test
|
||||
fun `simple node startup and shutdown`() {
|
||||
val (notary, regulator) = driver {
|
||||
val notary = startNode("TestNotary", setOf(ServiceInfo(SimpleNotaryService.type)))
|
||||
val notary = startNode(DUMMY_NOTARY.name, setOf(ServiceInfo(SimpleNotaryService.type)))
|
||||
val regulator = startNode("Regulator", setOf(ServiceInfo(RegulatorService.type)))
|
||||
|
||||
nodeMustBeUp(notary.getOrThrow().nodeInfo)
|
||||
@ -50,7 +52,7 @@ class DriverTests {
|
||||
@Test
|
||||
fun `starting node with no services`() {
|
||||
val noService = driver {
|
||||
val noService = startNode("NoService")
|
||||
val noService = startNode(DUMMY_BANK_A.name)
|
||||
nodeMustBeUp(noService.getOrThrow().nodeInfo)
|
||||
noService.getOrThrow()
|
||||
}
|
||||
@ -60,7 +62,7 @@ class DriverTests {
|
||||
@Test
|
||||
fun `random free port allocation`() {
|
||||
val nodeHandle = driver(portAllocation = PortAllocation.RandomFree) {
|
||||
val nodeInfo = startNode("NoService")
|
||||
val nodeInfo = startNode(DUMMY_BANK_A.name)
|
||||
nodeMustBeUp(nodeInfo.getOrThrow().nodeInfo)
|
||||
nodeInfo.getOrThrow()
|
||||
}
|
||||
@ -73,7 +75,7 @@ class DriverTests {
|
||||
val logConfigFile = Paths.get("..", "config", "dev", "log4j2.xml").toAbsolutePath()
|
||||
assertThat(logConfigFile).isRegularFile()
|
||||
driver(isDebug = true, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())) {
|
||||
val baseDirectory = startNode("Alice").getOrThrow().configuration.baseDirectory
|
||||
val baseDirectory = startNode(DUMMY_BANK_A.name).getOrThrow().configuration.baseDirectory
|
||||
val logFile = (baseDirectory / LOGS_DIRECTORY_NAME).list { it.sorted().findFirst().get() }
|
||||
val debugLinesPresent = logFile.readLines { lines -> lines.anyMatch { line -> line.startsWith("[DEBUG]") } }
|
||||
assertThat(debugLinesPresent).isTrue()
|
||||
|
@ -9,6 +9,7 @@ import net.corda.core.div
|
||||
import net.corda.core.getOrThrow
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.flows.NotaryError
|
||||
import net.corda.flows.NotaryException
|
||||
import net.corda.flows.NotaryFlow
|
||||
@ -30,7 +31,7 @@ class BFTNotaryServiceTests : NodeBasedTest() {
|
||||
@Test
|
||||
fun `detect double spend`() {
|
||||
val masterNode = startBFTNotaryCluster(notaryName, 4, BFTNonValidatingNotaryService.type).first()
|
||||
val alice = startNode("Alice").getOrThrow()
|
||||
val alice = startNode(ALICE.name).getOrThrow()
|
||||
|
||||
val notaryParty = alice.netMapCache.getNotary(notaryName)!!
|
||||
val notaryNodeKeyPair = databaseTransaction(masterNode.database) { masterNode.services.notaryIdentityKey }
|
||||
|
@ -10,6 +10,8 @@ import net.corda.core.messaging.StateMachineUpdate
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.serialization.OpaqueBytes
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.core.utilities.DUMMY_NOTARY
|
||||
import net.corda.flows.CashIssueFlow
|
||||
import net.corda.flows.CashPaymentFlow
|
||||
import net.corda.node.driver.NodeHandle
|
||||
@ -39,9 +41,9 @@ class DistributedServiceTests : DriverBasedTest() {
|
||||
startFlowPermission<CashIssueFlow>(),
|
||||
startFlowPermission<CashPaymentFlow>())
|
||||
)
|
||||
val aliceFuture = startNode("Alice", rpcUsers = listOf(testUser))
|
||||
val aliceFuture = startNode(ALICE.name, rpcUsers = listOf(testUser))
|
||||
val notariesFuture = startNotaryCluster(
|
||||
"Notary",
|
||||
DUMMY_NOTARY.name,
|
||||
rpcUsers = listOf(testUser),
|
||||
clusterSize = clusterSize,
|
||||
type = RaftValidatingNotaryService.type
|
||||
|
@ -8,6 +8,7 @@ import net.corda.core.contracts.TransactionType
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.getOrThrow
|
||||
import net.corda.core.map
|
||||
import net.corda.core.utilities.DUMMY_BANK_A
|
||||
import net.corda.flows.NotaryError
|
||||
import net.corda.flows.NotaryException
|
||||
import net.corda.flows.NotaryFlow
|
||||
@ -27,7 +28,7 @@ class RaftNotaryServiceTests : NodeBasedTest() {
|
||||
fun `detect double spend`() {
|
||||
val (masterNode, alice) = Futures.allAsList(
|
||||
startNotaryCluster(notaryName, 3).map { it.first() },
|
||||
startNode("Alice")
|
||||
startNode(DUMMY_BANK_A.name)
|
||||
).getOrThrow()
|
||||
|
||||
val notaryParty = alice.netMapCache.getNotary(notaryName)!!
|
||||
|
@ -11,6 +11,8 @@ import net.corda.core.getOrThrow
|
||||
import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.random63BitValue
|
||||
import net.corda.core.seconds
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.core.utilities.BOB
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.node.internal.Node
|
||||
import net.corda.nodeapi.ArtemisMessagingComponent.Companion.CLIENTS_PREFIX
|
||||
@ -49,7 +51,7 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
|
||||
@Before
|
||||
fun start() {
|
||||
alice = startNode("Alice", rpcUsers = extraRPCUsers + rpcUser).getOrThrow()
|
||||
alice = startNode(ALICE.name, rpcUsers = extraRPCUsers + rpcUser).getOrThrow()
|
||||
attacker = createAttacker()
|
||||
startAttacker(attacker)
|
||||
}
|
||||
@ -84,7 +86,7 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
|
||||
@Test
|
||||
fun `create queue for peer which has not been communicated with`() {
|
||||
val bob = startNode("Bob").getOrThrow()
|
||||
val bob = startNode(BOB.name).getOrThrow()
|
||||
assertAllQueueCreationAttacksFail("$PEERS_PREFIX${bob.info.legalIdentity.owningKey.toBase58String()}")
|
||||
}
|
||||
|
||||
@ -227,7 +229,7 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
}
|
||||
|
||||
private fun startBobAndCommunicateWithAlice(): Party {
|
||||
val bob = startNode("Bob").getOrThrow()
|
||||
val bob = startNode(BOB.name).getOrThrow()
|
||||
bob.services.registerFlowInitiator(SendFlow::class.java, ::ReceiveFlow)
|
||||
val bobParty = bob.info.legalIdentity
|
||||
// Perform a protocol exchange to force the peer queue to be created
|
||||
|
@ -11,6 +11,7 @@ import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.deserialize
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.core.utilities.*
|
||||
import net.corda.flows.ServiceRequestMessage
|
||||
import net.corda.flows.sendRequest
|
||||
import net.corda.node.internal.Node
|
||||
@ -26,7 +27,8 @@ import java.util.*
|
||||
class P2PMessagingTest : NodeBasedTest() {
|
||||
@Test
|
||||
fun `network map will work after restart`() {
|
||||
fun startNodes() = Futures.allAsList(startNode("NodeA"), startNode("NodeB"), startNode("Notary"))
|
||||
val identities = listOf(DUMMY_BANK_A, DUMMY_BANK_B, DUMMY_NOTARY)
|
||||
fun startNodes() = Futures.allAsList(identities.map { startNode(it.name) })
|
||||
|
||||
val startUpDuration = elapsedTime { startNodes().getOrThrow() }
|
||||
// Start the network map a second time - this will restore message queues from the journal.
|
||||
@ -40,7 +42,7 @@ class P2PMessagingTest : NodeBasedTest() {
|
||||
fun `communicating with a service running on the network map node`() {
|
||||
startNetworkMapNode(advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type)))
|
||||
networkMapNode.respondWith("Hello")
|
||||
val alice = startNode("Alice").getOrThrow()
|
||||
val alice = startNode(ALICE.name).getOrThrow()
|
||||
val serviceAddress = alice.services.networkMapCache.run {
|
||||
alice.net.getAddressOfParty(getPartyInfo(getAnyNotary()!!)!!)
|
||||
}
|
||||
@ -55,14 +57,14 @@ class P2PMessagingTest : NodeBasedTest() {
|
||||
|
||||
val root = tempFolder.root.toPath()
|
||||
ServiceIdentityGenerator.generateToDisk(
|
||||
listOf(root / "NetworkMap", root / "Service Node 2"),
|
||||
listOf(root / DUMMY_MAP.name, root / "Service Node 2"),
|
||||
RaftValidatingNotaryService.type.id,
|
||||
serviceName)
|
||||
|
||||
val distributedService = ServiceInfo(RaftValidatingNotaryService.type, serviceName)
|
||||
val notaryClusterAddress = freeLocalHostAndPort()
|
||||
startNetworkMapNode(
|
||||
"NetworkMap",
|
||||
DUMMY_MAP.name,
|
||||
advertisedServices = setOf(distributedService),
|
||||
configOverrides = mapOf("notaryNodeAddress" to notaryClusterAddress.toString()))
|
||||
val (serviceNode2, alice) = Futures.allAsList(
|
||||
@ -72,7 +74,7 @@ class P2PMessagingTest : NodeBasedTest() {
|
||||
configOverrides = mapOf(
|
||||
"notaryNodeAddress" to freeLocalHostAndPort().toString(),
|
||||
"notaryClusterAddresses" to listOf(notaryClusterAddress.toString()))),
|
||||
startNode("Alice")
|
||||
startNode(ALICE.name)
|
||||
).getOrThrow()
|
||||
|
||||
assertAllNodesAreUsed(listOf(networkMapNode, serviceNode2), serviceName, alice)
|
||||
|
@ -7,6 +7,7 @@ import net.corda.core.getOrThrow
|
||||
import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.random63BitValue
|
||||
import net.corda.core.seconds
|
||||
import net.corda.core.utilities.BOB
|
||||
import net.corda.flows.sendRequest
|
||||
import net.corda.node.internal.NetworkMapInfo
|
||||
import net.corda.node.services.config.configureWithDevSSLCertificate
|
||||
@ -29,7 +30,7 @@ class P2PSecurityTest : NodeBasedTest() {
|
||||
@Test
|
||||
fun `incorrect legal name for the network map service config`() {
|
||||
val incorrectNetworkMapName = random63BitValue().toString()
|
||||
val node = startNode("Bob", configOverrides = mapOf(
|
||||
val node = startNode(BOB.name, configOverrides = mapOf(
|
||||
"networkMapService" to mapOf(
|
||||
"address" to networkMapNode.configuration.p2pAddress.toString(),
|
||||
"legalName" to incorrectNetworkMapName
|
||||
|
@ -16,8 +16,7 @@ import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.utilities.ProcessUtilities
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.core.utilities.*
|
||||
import net.corda.node.LOGS_DIRECTORY_NAME
|
||||
import net.corda.node.services.config.ConfigHelper
|
||||
import net.corda.node.services.config.FullNodeConfiguration
|
||||
@ -145,8 +144,8 @@ sealed class PortAllocation {
|
||||
/**
|
||||
* [driver] allows one to start up nodes like this:
|
||||
* driver {
|
||||
* val noService = startNode("NoService")
|
||||
* val notary = startNode("Notary")
|
||||
* val noService = startNode(DUMMY_BANK_A.name)
|
||||
* val notary = startNode(DUMMY_NOTARY.name)
|
||||
*
|
||||
* (...)
|
||||
* }
|
||||
@ -344,7 +343,7 @@ class DriverDSL(
|
||||
val isDebug: Boolean,
|
||||
val automaticallyStartNetworkMap: Boolean
|
||||
) : DriverDSLInternalInterface {
|
||||
private val networkMapLegalName = "NetworkMapService"
|
||||
private val networkMapLegalName = DUMMY_MAP.name
|
||||
private val networkMapAddress = portAllocation.nextHostAndPort()
|
||||
val executorService: ListeningScheduledExecutorService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(2))
|
||||
val shutdownManager = ShutdownManager(executorService)
|
||||
@ -458,7 +457,7 @@ class DriverDSL(
|
||||
verifierType: VerifierType,
|
||||
rpcUsers: List<User>
|
||||
): ListenableFuture<Pair<Party, List<NodeHandle>>> {
|
||||
val nodeNames = (1..clusterSize).map { "Notary Node $it" }
|
||||
val nodeNames = (1..clusterSize).map { "${DUMMY_NOTARY.name} $it" }
|
||||
val paths = nodeNames.map { driverDirectory / it }
|
||||
ServiceIdentityGenerator.generateToDisk(paths, type.id, notaryName)
|
||||
|
||||
@ -539,9 +538,9 @@ class DriverDSL(
|
||||
|
||||
companion object {
|
||||
val name = arrayOf(
|
||||
"Alice",
|
||||
"Bob",
|
||||
"Bank"
|
||||
ALICE.name,
|
||||
BOB.name,
|
||||
DUMMY_BANK_A.name
|
||||
)
|
||||
|
||||
fun <A> pickA(array: Array<A>): A = array[Math.abs(Random().nextInt()) % array.size]
|
||||
|
@ -16,6 +16,8 @@ import net.corda.core.rootCause
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.transactions.WireTransaction
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.core.utilities.BOB
|
||||
import net.corda.core.utilities.DUMMY_NOTARY
|
||||
import net.corda.core.utilities.LogHelper
|
||||
import net.corda.core.utilities.TEST_TX_TIME
|
||||
|
@ -22,6 +22,8 @@ import net.corda.node.services.network.NetworkMapService.Companion.QUERY_TOPIC
|
||||
import net.corda.node.services.network.NetworkMapService.Companion.REGISTER_TOPIC
|
||||
import net.corda.node.services.network.NetworkMapService.Companion.SUBSCRIPTION_TOPIC
|
||||
import net.corda.node.services.network.NodeRegistration
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.core.utilities.BOB
|
||||
import net.corda.node.utilities.AddOrRemove
|
||||
import net.corda.node.utilities.AddOrRemove.ADD
|
||||
import net.corda.node.utilities.AddOrRemove.REMOVE
|
||||
@ -44,7 +46,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
@Before
|
||||
fun setup() {
|
||||
network = MockNetwork(defaultFactory = nodeFactory)
|
||||
network.createTwoNodes(firstNodeName = "map service", secondNodeName = "alice").apply {
|
||||
network.createTwoNodes(firstNodeName = "map service", secondNodeName = ALICE.name).apply {
|
||||
mapServiceNode = first
|
||||
alice = second
|
||||
}
|
||||
@ -110,7 +112,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
|
||||
@Test
|
||||
fun `de-register unknown node`() {
|
||||
val bob = newNodeSeparateFromNetworkMap("Bob")
|
||||
val bob = newNodeSeparateFromNetworkMap(BOB.name)
|
||||
val response = bob.registration(REMOVE)
|
||||
swizzle()
|
||||
assertThat(response.getOrThrow().error).isNotNull() // Make sure send error message is sent back
|
||||
@ -121,7 +123,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
fun `subscribed while new node registers`() {
|
||||
val updates = alice.subscribe()
|
||||
swizzle()
|
||||
val bob = addNewNodeToNetworkMap("Bob")
|
||||
val bob = addNewNodeToNetworkMap(BOB.name)
|
||||
swizzle()
|
||||
val update = updates.single()
|
||||
assertThat(update.mapVersion).isEqualTo(networkMapService.mapVersion)
|
||||
@ -130,7 +132,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
|
||||
@Test
|
||||
fun `subscribed while node de-registers`() {
|
||||
val bob = addNewNodeToNetworkMap("Bob")
|
||||
val bob = addNewNodeToNetworkMap(BOB.name)
|
||||
val updates = alice.subscribe()
|
||||
bob.registration(REMOVE)
|
||||
swizzle()
|
||||
@ -140,7 +142,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
@Test
|
||||
fun unsubscribe() {
|
||||
val updates = alice.subscribe()
|
||||
val bob = addNewNodeToNetworkMap("Bob")
|
||||
val bob = addNewNodeToNetworkMap(BOB.name)
|
||||
alice.unsubscribe()
|
||||
addNewNodeToNetworkMap("Charlie")
|
||||
swizzle()
|
||||
@ -151,7 +153,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
fun `surpass unacknowledged update limit`() {
|
||||
val subscriber = newNodeSeparateFromNetworkMap("Subscriber")
|
||||
val updates = subscriber.subscribe()
|
||||
val bob = addNewNodeToNetworkMap("Bob")
|
||||
val bob = addNewNodeToNetworkMap(BOB.name)
|
||||
var serial = updates.first().wireReg.verified().serial
|
||||
repeat(networkMapService.maxUnacknowledgedUpdates) {
|
||||
bob.registration(ADD, serial = ++serial)
|
||||
@ -165,7 +167,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
|
||||
fun `delay sending update ack until just before unacknowledged update limit`() {
|
||||
val subscriber = newNodeSeparateFromNetworkMap("Subscriber")
|
||||
val updates = subscriber.subscribe()
|
||||
val bob = addNewNodeToNetworkMap("Bob")
|
||||
val bob = addNewNodeToNetworkMap(BOB.name)
|
||||
var serial = updates.first().wireReg.verified().serial
|
||||
repeat(networkMapService.maxUnacknowledgedUpdates - 1) {
|
||||
bob.registration(ADD, serial = ++serial)
|
||||
|
@ -3,9 +3,9 @@ package net.corda.node.services
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.crypto.generateKeyPair
|
||||
import net.corda.node.services.identity.InMemoryIdentityService
|
||||
import net.corda.testing.ALICE
|
||||
import net.corda.core.utilities.ALICE
|
||||
import net.corda.core.utilities.BOB
|
||||
import net.corda.testing.ALICE_PUBKEY
|
||||
import net.corda.testing.BOB
|
||||
import net.corda.testing.BOB_PUBKEY
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
@ -13,11 +13,11 @@ import net.corda.node.services.events.NodeSchedulerService
|
||||
import net.corda.node.services.persistence.DBCheckpointStorage
|
||||
import net.corda.node.services.statemachine.StateMachineManager
|
||||
import net.corda.node.services.vault.NodeVaultService
|
||||
import net.corda.core.utilities.ALICE_KEY
|
||||
import net.corda.node.utilities.AddOrRemove
|
||||
import net.corda.node.utilities.AffinityExecutor
|
||||
import net.corda.node.utilities.configureDatabase
|
||||
import net.corda.node.utilities.databaseTransaction
|
||||
import net.corda.testing.ALICE_KEY
|
||||
import net.corda.testing.node.InMemoryMessagingNetwork
|
||||
import net.corda.testing.node.MockKeyManagementService
|
||||
import net.corda.testing.node.TestClock
|
||||
|
@ -10,12 +10,12 @@ import net.corda.core.node.services.VaultService
|
||||
import net.corda.core.node.services.consumedStates
|
||||
import net.corda.core.node.services.unconsumedStates
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.BOB_KEY
|
||||
import net.corda.core.utilities.DUMMY_NOTARY
|
||||
import net.corda.core.utilities.DUMMY_NOTARY_KEY
|
||||
import net.corda.core.utilities.LogHelper
|
||||
import net.corda.node.utilities.configureDatabase
|
||||
import net.corda.node.utilities.databaseTransaction
|
||||
import net.corda.testing.BOB_KEY
|
||||
import net.corda.testing.BOB_PUBKEY
|
||||
import net.corda.testing.MEGA_CORP
|
||||
import net.corda.testing.MEGA_CORP_KEY
|
||||
|
Reference in New Issue
Block a user