diff --git a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt index f438548171..82cb45c8da 100644 --- a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt +++ b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt @@ -125,22 +125,22 @@ class DriverTests { } @Test - fun `driver rejects multiple nodes with the same name`() { - + fun `driver rejects multiple nodes with the same name parallel`() { driver(DriverParameters(startNodesInProcess = true)) { - - assertThatThrownBy { listOf(newNode(DUMMY_BANK_A_NAME)(), newNode(DUMMY_BANK_B_NAME)(), newNode(DUMMY_BANK_A_NAME)()).transpose().getOrThrow() }.isInstanceOf(IllegalArgumentException::class.java) + val nodes = listOf(newNode(DUMMY_BANK_A_NAME), newNode(DUMMY_BANK_B_NAME), newNode(DUMMY_BANK_A_NAME)) + assertThatIllegalArgumentException().isThrownBy { + nodes.parallelStream().map { it.invoke() }.toList().transpose().getOrThrow() + } } } @Test - fun `driver rejects multiple nodes with the same name parallel`() { - - driver(DriverParameters(startNodesInProcess = true)) { - - val nodes = listOf(newNode(DUMMY_BANK_A_NAME), newNode(DUMMY_BANK_B_NAME), newNode(DUMMY_BANK_A_NAME)) - - assertThatThrownBy { nodes.parallelStream().map { it.invoke() }.toList().transpose().getOrThrow() }.isInstanceOf(IllegalArgumentException::class.java) + fun `driver rejects multiple nodes with the same organisation name`() { + driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) { + newNode(CordaX500Name(commonName = "Notary", organisation = "R3CEV", locality = "New York", country = "US"))().getOrThrow() + assertThatIllegalArgumentException().isThrownBy { + newNode(CordaX500Name(commonName = "Regulator", organisation = "R3CEV", locality = "New York", country = "US"))().getOrThrow() + } } } diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index e255cdd499..0f95bdd1bc 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -103,7 +103,7 @@ class DriverDSLImpl( private val cordappPackages = extraCordappPackagesToScan + getCallerPackage() // Map from a nodes legal name to an observable emitting the number of nodes in its network map. private val countObservables = mutableMapOf>() - private val nodeNames = mutableSetOf() + private val nodeOrgs = mutableSetOf() /** * Future which completes when the network map is available, whether a local one or one from the CZ. This future acts * as a gate to prevent nodes from starting too early. The value of the future is a [LocalNetworkMap] object, which @@ -194,11 +194,8 @@ class DriverDSLImpl( val p2pAddress = portAllocation.nextHostAndPort() // TODO: Derive name from the full picked name, don't just wrap the common name val name = providedName ?: CordaX500Name("${oneOf(names).organisation}-${p2pAddress.port}", "London", "GB") - synchronized(nodeNames) { - val wasANewNode = nodeNames.add(name) - if (!wasANewNode) { - throw IllegalArgumentException("Node with name $name is already started or starting.") - } + synchronized(nodeOrgs) { + require(nodeOrgs.add(name.organisation)) { "Node with organisation name ${name.organisation} is already started or starting" } } val registrationFuture = if (compatibilityZone?.rootCert != null) { // We don't need the network map to be available to be able to register the node @@ -664,8 +661,8 @@ class DriverDSLImpl( val onNodeExit: () -> Unit = { localNetworkMap?.nodeInfosCopier?.removeConfig(baseDirectory) countObservables.remove(config.corda.myLegalName) - synchronized(nodeNames) { - nodeNames.remove(config.corda.myLegalName) + synchronized(nodeOrgs) { + nodeOrgs -= config.corda.myLegalName.organisation } }