diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/InstallFactory.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/InstallFactory.kt index d2dba4a687..f7709a7ada 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/InstallFactory.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/InstallFactory.kt @@ -25,10 +25,6 @@ class InstallFactory : Controller() { val tempDir = Files.createTempDirectory(baseDir, ".node") - if (nodeConfig.isNetworkMap) { - log.info("Node '${nodeConfig.myLegalName}' is the network map") - } - return InstallConfig(tempDir, NodeConfigWrapper(tempDir, nodeConfig)) } } diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt index 504fdfab79..8ac6aeefdf 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeConfig.kt @@ -22,7 +22,6 @@ data class NodeConfig( /** This is not used by the node but by the webserver which looks at node.conf. */ val webAddress: NetworkHostAndPort, val notary: NotaryService?, - val networkMapService: NetworkMapConfig?, val h2port: Int, val rpcUsers: List = listOf(defaultUser), /** This is an extra config used by the Cash app. */ @@ -39,16 +38,9 @@ data class NodeConfig( @Suppress("unused") private val useTestClock = true - val isNetworkMap: Boolean get() = networkMapService == null - fun toText(): String = toConfig().root().render(renderOptions) } -/** - * This is a mirror of NetworkMapInfo. - */ -data class NetworkMapConfig(val legalName: CordaX500Name, val address: NetworkHostAndPort) - /** * This is a subset of NotaryConfig. It implements [ExtraService] to avoid unnecessary copying. */ diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeController.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeController.kt index 2830c969b8..59237e97a8 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeController.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/model/NodeController.kt @@ -37,8 +37,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { private val nodes = LinkedHashMap() private val port = AtomicInteger(firstPort) - private var networkMapConfig: NetworkMapConfig? = null - val activeNodes: List get() = nodes.values.filter { (it.state == NodeState.RUNNING) || (it.state == NodeState.STARTING) @@ -70,7 +68,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { rpcAddress = nodeData.rpcPort.toLocalAddress(), webAddress = nodeData.webPort.toLocalAddress(), notary = nodeData.extraServices.filterIsInstance().noneOrSingle(), - networkMapService = networkMapConfig, // The first node becomes the network map h2port = nodeData.h2Port.value, issuableCurrencies = nodeData.extraServices.filterIsInstance().map { it.currency.toString() } ) @@ -82,11 +79,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { return null } - if (nodeConfig.isNetworkMap) { - networkMapConfig = nodeConfig.let { NetworkMapConfig(it.myLegalName, it.p2pAddress) } - log.info("Network map provided by: ${nodeConfig.myLegalName}") - } - nodeInfoFilesCopier.addConfig(wrapper) return wrapper @@ -96,10 +88,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { config.state = NodeState.DEAD nodeInfoFilesCopier.removeConfig(config) - - if (config.nodeConfig.isNetworkMap) { - log.warning("Network map service (Node '${config.nodeConfig.myLegalName}') has exited.") - } } val nextPort: Int get() = port.andIncrement @@ -110,7 +98,7 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { fun nameExists(name: String) = keyExists(name.toKey()) - fun hasNetworkMap(): Boolean = networkMapConfig != null + fun hasNotary(): Boolean = activeNodes.any { it.nodeConfig.notary != null } fun runCorda(pty: R3Pty, config: NodeConfigWrapper): Boolean { try { @@ -141,7 +129,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { log.info("Changed base directory: $baseDir") // Wipe out any knowledge of previous nodes. - networkMapConfig = null nodes.clear() nodeInfoFilesCopier.reset() } @@ -157,10 +144,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() { updatePort(config.nodeConfig) - if (networkMapConfig == null && config.nodeConfig.isNetworkMap) { - networkMapConfig = config.nodeConfig.let { NetworkMapConfig(it.myLegalName, it.p2pAddress) } - } - return true } diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt index c9f993a5c2..cc728b4708 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt @@ -114,7 +114,7 @@ class NodeTabView : Fragment() { fieldset("Additional configuration") { styleClass.addAll("services-panel") - val extraServices = if (nodeController.hasNetworkMap()) { + val extraServices = if (nodeController.hasNotary()) { listOf(USD, GBP, CHF, EUR).map { CurrencyIssuer(it) } } else { listOf(NotaryService(true), NotaryService(false)) @@ -123,7 +123,7 @@ class NodeTabView : Fragment() { val servicesList = CheckListView(extraServices.observable()).apply { vboxConstraints { vGrow = Priority.ALWAYS } model.item.extraServices.set(checkModel.checkedItems) - if (!nodeController.hasNetworkMap()) { + if (!nodeController.hasNotary()) { checkModel.check(0) checkModel.checkedItems.addListener(ListChangeListener { change -> while (change.next()) { diff --git a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt index 92ed477be8..8ebcbaf2cc 100644 --- a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt +++ b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeConfigTest.kt @@ -7,7 +7,6 @@ import net.corda.core.utilities.NetworkHostAndPort import net.corda.node.services.config.parseAsNodeConfiguration import net.corda.nodeapi.User import net.corda.nodeapi.config.toConfig -import net.corda.testing.DUMMY_NOTARY import net.corda.webserver.WebServerConfig import org.assertj.core.api.Assertions.assertThat import org.junit.Test @@ -32,7 +31,6 @@ class NodeConfigTest { webPort = 20001, h2port = 30001, notary = NotaryService(validating = false), - networkMap = NetworkMapConfig(DUMMY_NOTARY.name, localPort(12345)), users = listOf(user("jenny")) ) @@ -60,7 +58,6 @@ class NodeConfigTest { webPort = 20001, h2port = 30001, notary = NotaryService(validating = false), - networkMap = NetworkMapConfig(DUMMY_NOTARY.name, localPort(12345)), users = listOf(user("jenny")) ) @@ -83,7 +80,6 @@ class NodeConfigTest { webPort: Int = -1, h2port: Int = -1, notary: NotaryService?, - networkMap: NetworkMapConfig?, users: List = listOf(user("guest")) ): NodeConfig { return NodeConfig( @@ -93,7 +89,6 @@ class NodeConfigTest { webAddress = localPort(webPort), h2port = h2port, notary = notary, - networkMapService = networkMap, rpcUsers = users ) } diff --git a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeControllerTest.kt b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeControllerTest.kt index bae103a317..6ed56f94e0 100644 --- a/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeControllerTest.kt +++ b/tools/demobench/src/test/kotlin/net/corda/demobench/model/NodeControllerTest.kt @@ -3,7 +3,6 @@ package net.corda.demobench.model import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.NetworkHostAndPort import net.corda.nodeapi.User -import net.corda.testing.DUMMY_NOTARY import org.junit.Test import java.nio.file.Path import java.nio.file.Paths @@ -24,6 +23,22 @@ class NodeControllerTest { assertNull(controller.validate(data)) } + @Test + fun `register notary`() { + assertFalse(controller.hasNotary()) + val config = createConfig(commonName = "Name", notary = NotaryService(false)) + controller.register(config) + assertTrue(controller.hasNotary()) + } + + @Test + fun `register non notary`() { + assertFalse(controller.hasNotary()) + val config = createConfig(commonName = "Name") + controller.register(config) + assertFalse(controller.hasNotary()) + } + @Test fun `test unique key after validate`() { val data = NodeData() @@ -48,17 +63,6 @@ class NodeControllerTest { assertTrue(controller.nameExists("organisation 1")) } - @Test - fun `test first validated node becomes network map`() { - val data = NodeData() - data.legalName.value = node1Name - data.p2pPort.value = 10000 - - assertFalse(controller.hasNetworkMap()) - controller.validate(data) - assertTrue(controller.hasNetworkMap()) - } - @Test fun `test register unique nodes`() { val config = createConfig(commonName = organisation2Name) @@ -88,28 +92,6 @@ class NodeControllerTest { assertTrue(controller.nameExists("organisation 2")) } - @Test - fun `test register network map node`() { - val config = createConfig(commonName = "Organisation is Network Map") - assertTrue(config.nodeConfig.isNetworkMap) - - assertFalse(controller.hasNetworkMap()) - controller.register(config) - assertTrue(controller.hasNetworkMap()) - } - - @Test - fun `test register non-network-map node`() { - val config = createConfig( - commonName = "Organisation is not Network Map", - networkMap = NetworkMapConfig(DUMMY_NOTARY.name, localPort(10000))) - assertFalse(config.nodeConfig.isNetworkMap) - - assertFalse(controller.hasNetworkMap()) - controller.register(config) - assertFalse(controller.hasNetworkMap()) - } - @Test fun `test valid ports`() { assertFalse(controller.isPortValid(NodeController.minPort - 1)) @@ -173,7 +155,6 @@ class NodeControllerTest { webPort: Int = 0, h2port: Int = 0, notary: NotaryService? = null, - networkMap: NetworkMapConfig? = null, users: List = listOf(user("guest")) ): NodeConfigWrapper { val nodeConfig = NodeConfig( @@ -187,7 +168,6 @@ class NodeControllerTest { webAddress = localPort(webPort), h2port = h2port, notary = notary, - networkMapService = networkMap, rpcUsers = users ) return NodeConfigWrapper(baseDir, nodeConfig)