Added clock to the node

This commit is contained in:
Clinton Alexander
2016-10-18 15:26:32 +01:00
parent aad75c5152
commit 1d6b8de11e
3 changed files with 10 additions and 11 deletions

View File

@ -30,31 +30,31 @@ class DriverTests {
val notary = startNode("TestNotary", setOf(ServiceInfo(SimpleNotaryService.type))) val notary = startNode("TestNotary", setOf(ServiceInfo(SimpleNotaryService.type)))
val regulator = startNode("Regulator", setOf(ServiceInfo(RegulatorService.type))) val regulator = startNode("Regulator", setOf(ServiceInfo(RegulatorService.type)))
nodeMustBeUp(notary.get(), "TestNotary") nodeMustBeUp(notary.get().nodeInfo, "TestNotary")
nodeMustBeUp(regulator.get(), "Regulator") nodeMustBeUp(regulator.get().nodeInfo, "Regulator")
Pair(notary.get(), regulator.get()) Pair(notary.get(), regulator.get())
} }
nodeMustBeDown(notary) nodeMustBeDown(notary.nodeInfo)
nodeMustBeDown(regulator) nodeMustBeDown(regulator.nodeInfo)
} }
@Test @Test
fun startingNodeWithNoServicesWorks() { fun startingNodeWithNoServicesWorks() {
val noService = driver { val noService = driver {
val noService = startNode("NoService") val noService = startNode("NoService")
nodeMustBeUp(noService.get(), "NoService") nodeMustBeUp(noService.get().nodeInfo, "NoService")
noService.get() noService.get()
} }
nodeMustBeDown(noService) nodeMustBeDown(noService.nodeInfo)
} }
@Test @Test
fun randomFreePortAllocationWorks() { fun randomFreePortAllocationWorks() {
val nodeInfo = driver(portAllocation = PortAllocation.RandomFree()) { val nodeInfo = driver(portAllocation = PortAllocation.RandomFree()) {
val nodeInfo = startNode("NoService") val nodeInfo = startNode("NoService")
nodeMustBeUp(nodeInfo.get(), "NoService") nodeMustBeUp(nodeInfo.get().nodeInfo, "NoService")
nodeInfo.get() nodeInfo.get()
} }
nodeMustBeDown(nodeInfo) nodeMustBeDown(nodeInfo.nodeInfo)
} }
} }

View File

@ -331,7 +331,6 @@ open class DriverDSL(
configOverrides = mapOf( configOverrides = mapOf(
"myLegalName" to networkMapName, "myLegalName" to networkMapName,
"basedir" to Paths.get(nodeDirectory).normalize().toString(), "basedir" to Paths.get(nodeDirectory).normalize().toString(),
"clock" to clock,
"artemisAddress" to networkMapAddress.toString(), "artemisAddress" to networkMapAddress.toString(),
"webAddress" to apiAddress.toString(), "webAddress" to apiAddress.toString(),
"extraAdvertisedServiceIds" to "" "extraAdvertisedServiceIds" to ""

View File

@ -5,6 +5,7 @@ import com.r3corda.core.div
import com.r3corda.core.messaging.SingleMessageRecipient import com.r3corda.core.messaging.SingleMessageRecipient
import com.r3corda.core.node.services.ServiceInfo import com.r3corda.core.node.services.ServiceInfo
import com.r3corda.node.internal.Node import com.r3corda.node.internal.Node
import com.r3corda.node.serialization.NodeClock
import com.r3corda.node.services.messaging.NodeMessagingClient import com.r3corda.node.services.messaging.NodeMessagingClient
import com.r3corda.node.services.network.NetworkMapService import com.r3corda.node.services.network.NetworkMapService
import com.typesafe.config.Config import com.typesafe.config.Config
@ -31,7 +32,7 @@ interface NodeConfiguration : NodeSSLConfiguration {
val devMode: Boolean val devMode: Boolean
} }
class FullNodeConfiguration(config: Config) : NodeConfiguration { class FullNodeConfiguration(config: Config, val clock: Clock = NodeClock()) : NodeConfiguration {
override val basedir: Path by config override val basedir: Path by config
override val myLegalName: String by config override val myLegalName: String by config
override val nearestCity: String by config override val nearestCity: String by config
@ -47,7 +48,6 @@ class FullNodeConfiguration(config: Config) : NodeConfiguration {
val webAddress: HostAndPort by config val webAddress: HostAndPort by config
val messagingServerAddress: HostAndPort? by config.getOrElse { null } val messagingServerAddress: HostAndPort? by config.getOrElse { null }
val extraAdvertisedServiceIds: String by config val extraAdvertisedServiceIds: String by config
val clock: Clock by config
fun createNode(): Node { fun createNode(): Node {
val advertisedServices = mutableSetOf<ServiceInfo>() val advertisedServices = mutableSetOf<ServiceInfo>()