[CORDA-446] Remove mentions of networkmap node in DemoBench (#1969)

* [CORDA-446] Remove mentions of networkmap node in DemoBench
This commit is contained in:
Alberto Arri 2017-11-01 14:28:45 +00:00 committed by GitHub
parent 00e682a544
commit b925e6540d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 73 deletions

View File

@ -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))
}
}

View File

@ -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<User> = 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.
*/

View File

@ -37,8 +37,6 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
private val nodes = LinkedHashMap<String, NodeConfigWrapper>()
private val port = AtomicInteger(firstPort)
private var networkMapConfig: NetworkMapConfig? = null
val activeNodes: List<NodeConfigWrapper>
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<NotaryService>().noneOrSingle(),
networkMapService = networkMapConfig, // The first node becomes the network map
h2port = nodeData.h2Port.value,
issuableCurrencies = nodeData.extraServices.filterIsInstance<CurrencyIssuer>().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
}

View File

@ -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()) {

View File

@ -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<User> = listOf(user("guest"))
): NodeConfig {
return NodeConfig(
@ -93,7 +89,6 @@ class NodeConfigTest {
webAddress = localPort(webPort),
h2port = h2port,
notary = notary,
networkMapService = networkMap,
rpcUsers = users
)
}

View File

@ -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<User> = 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)