mirror of
https://github.com/corda/corda.git
synced 2024-12-27 08:22:35 +00:00
CORDA-1837: Reject nodes that have the same organisation name in driver tests
* Reject nodes that have the same organisation name as a previously registered node rather than the same X500 name
(cherry picked from commit 40b922c1f2
)
This commit is contained in:
parent
0df77d5b64
commit
43272594f7
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<CordaX500Name, Observable<Int>>()
|
||||
private val nodeNames = mutableSetOf<CordaX500Name>()
|
||||
private val nodeOrgs = mutableSetOf<String>()
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user