diff --git a/node/src/main/kotlin/net/corda/node/internal/Node.kt b/node/src/main/kotlin/net/corda/node/internal/Node.kt index db94242f56..a00f5ff2d2 100644 --- a/node/src/main/kotlin/net/corda/node/internal/Node.kt +++ b/node/src/main/kotlin/net/corda/node/internal/Node.kt @@ -24,6 +24,7 @@ import net.corda.node.services.messaging.MessagingService import net.corda.node.services.messaging.NodeMessagingClient import net.corda.node.utilities.AddressUtils import net.corda.node.utilities.AffinityExecutor +import net.corda.node.utilities.TestClock import net.corda.nodeapi.ArtemisMessagingComponent import net.corda.nodeapi.ArtemisMessagingComponent.Companion.IP_REQUEST_PREFIX import net.corda.nodeapi.ArtemisMessagingComponent.Companion.PEER_USER @@ -58,8 +59,8 @@ import kotlin.system.exitProcess open class Node(override val configuration: FullNodeConfiguration, advertisedServices: Set, val versionInfo: VersionInfo, - clock: Clock = NodeClock(), - val initialiseSerialization: Boolean = true) : AbstractNode(configuration, advertisedServices, clock) { + val initialiseSerialization: Boolean = true +) : AbstractNode(configuration, advertisedServices, createClock(configuration)) { companion object { private val logger = loggerFor() var renderBasicInfoToConsole = true @@ -76,6 +77,10 @@ open class Node(override val configuration: FullNodeConfiguration, println("Corda will now exit...") exitProcess(1) } + + private fun createClock(configuration: FullNodeConfiguration): Clock { + return if (configuration.useTestClock) TestClock() else NodeClock() + } } override val log: Logger get() = logger diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index db1e54016d..5641cb8953 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -93,7 +93,7 @@ open class NodeStartup(val args: Array) { open protected fun preNetworkRegistration(conf: FullNodeConfiguration) = Unit open protected fun createNode(conf: FullNodeConfiguration, versionInfo: VersionInfo, services: Set): Node { - return Node(conf, services, versionInfo, if (conf.useTestClock) TestClock() else NodeClock()) + return Node(conf, services, versionInfo) } open protected fun startNode(conf: FullNodeConfiguration, versionInfo: VersionInfo, startTime: Long, cmdlineOptions: CmdLineOptions) { diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index 309490c07d..dc4c021c4b 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -7,6 +7,7 @@ import net.corda.core.toFuture import net.corda.core.internal.concurrent.transpose import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.getOrThrow +import net.corda.core.utilities.loggerFor import net.corda.core.utilities.seconds import net.corda.irs.api.NodeInterestRates import net.corda.irs.contract.InterestRateSwap @@ -29,6 +30,11 @@ import java.time.Duration import java.time.LocalDate class IRSDemoTest : IntegrationTestCategory { + + companion object { + val log = loggerFor() + } + val rpcUser = User("user", "password", emptySet()) val currentDate: LocalDate = LocalDate.now() val futureDate: LocalDate = currentDate.plusMonths(6) @@ -43,7 +49,7 @@ class IRSDemoTest : IntegrationTestCategory { startNode(DUMMY_BANK_B.name) ).transpose().getOrThrow() - println("All nodes started") + log.info("All nodes started") val (controllerAddr, nodeAAddr, nodeBAddr) = listOf( startWebserver(controller), @@ -51,7 +57,7 @@ class IRSDemoTest : IntegrationTestCategory { startWebserver(nodeB) ).transpose().getOrThrow().map { it.listenAddress } - println("All webservers started") + log.info("All webservers started") val (_, nodeAApi, nodeBApi) = listOf(controller, nodeA, nodeB).zip(listOf(controllerAddr, nodeAAddr, nodeBAddr)).map { val mapper = net.corda.jackson.JacksonSupport.createDefaultMapper(it.first.rpc) @@ -85,25 +91,25 @@ class IRSDemoTest : IntegrationTestCategory { val vaultUpdates = proxy.vaultTrackBy().updates return vaultUpdates.map { update -> - val irsStates = update.produced.map { it.state.data }.filterIsInstance() + val irsStates = update.produced.map { it.state.data } irsStates.mapNotNull { it.calculation.nextFixingDate() }.max() }.cache() } private fun runDateChange(nodeApi: HttpApi) { - println("Running date change against ${nodeApi.root}") + log.info("Running date change against ${nodeApi.root}") assertThat(nodeApi.putJson("demodate", "\"$futureDate\"")).isTrue() } private fun runTrade(nodeApi: HttpApi) { - println("Running trade against ${nodeApi.root}") + log.info("Running trade against ${nodeApi.root}") val fileContents = loadResourceFile("net/corda/irs/simulation/example-irs-trade.json") val tradeFile = fileContents.replace("tradeXXX", "trade1") assertThat(nodeApi.postJson("deals", tradeFile)).isTrue() } private fun runUploadRates(host: NetworkHostAndPort) { - println("Running upload rates against $host") + log.info("Running upload rates against $host") val fileContents = loadResourceFile("net/corda/irs/simulation/example.rates.txt") val url = URL("http://$host/api/irs/fixes") assertThat(uploadFile(url, fileContents)).isTrue() @@ -114,13 +120,13 @@ class IRSDemoTest : IntegrationTestCategory { } private fun getTradeCount(nodeApi: HttpApi): Int { - println("Getting trade count from ${nodeApi.root}") + log.info("Getting trade count from ${nodeApi.root}") val deals = nodeApi.getJson>("deals") return deals.size } private fun getTrades(nodeApi: HttpApi): Array { - println("Getting trades from ${nodeApi.root}") + log.info("Getting trades from ${nodeApi.root}") val deals = nodeApi.getJson>("deals") return deals } diff --git a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt index 3a14d967e0..44f3ad88e3 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -772,9 +772,8 @@ class DriverDSL( log.info("Starting in-process Node ${nodeConf.myLegalName.commonName}") // Write node.conf writeConfig(nodeConf.baseDirectory, "node.conf", config) - val clock: Clock = if (nodeConf.useTestClock) TestClock() else NodeClock() // TODO pass the version in? - val node = Node(nodeConf, nodeConf.calculateServices(), MOCK_VERSION_INFO, clock, initialiseSerialization = false) + val node = Node(nodeConf, nodeConf.calculateServices(), MOCK_VERSION_INFO, initialiseSerialization = false) node.start() val nodeThread = thread(name = nodeConf.myLegalName.commonName) { node.run() diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt index 7e8d3bedd1..7958a39c50 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt @@ -164,7 +164,7 @@ abstract class NodeBasedTest : TestDependencyInjectionBase() { val parsedConfig = config.parseAs() val node = Node(parsedConfig, parsedConfig.calculateServices(), MOCK_VERSION_INFO.copy(platformVersion = platformVersion), - if (parsedConfig.useTestClock) TestClock() else NodeClock(), initialiseSerialization = false) + initialiseSerialization = false) node.start() nodes += node thread(name = legalName.commonName) {